coredns/plugin/errors
coredns[bot] 8f7f150bf3 auto go fmt
Signed-off-by: coredns[bot] <bot@bot.coredns.io>
2022-05-30 10:29:34 +00:00
..
benchmark_test.go Add benchmark test (#2610) 2019-02-25 06:57:27 -08:00
errors.go add configurable log level to errors plugin (#4718) 2021-07-09 14:23:02 +00:00
errors_test.go auto go fmt 2021-07-12 10:32:17 +00:00
log_test.go Clean up tests logging (#1979) 2018-07-19 16:23:06 +01:00
README.md recover from panic log including stacktrace to help finding the origin (#5392) 2022-05-24 14:36:36 +02:00
setup.go recover from panic log including stacktrace to help finding the origin (#5392) 2022-05-24 14:36:36 +02:00
setup_test.go auto go fmt 2022-05-30 10:29:34 +00:00

errors

Name

errors - enables error logging.

Description

Any errors encountered during the query processing will be printed to standard output. The errors of particular type can be consolidated and printed once per some period of time.

This plugin can only be used once per Server Block.

Syntax

The basic syntax is:

errors

Extra knobs are available with an expanded syntax:

errors {
	stacktrace
	consolidate DURATION REGEXP [LEVEL]
}

Option stacktrace will log a stacktrace during panic recovery.

Option consolidate allows collecting several error messages matching the regular expression REGEXP during DURATION. After the DURATION since receiving the first such message, the consolidated message will be printed to standard output with log level, which is configurable by optional option LEVEL. Supported options for LEVEL option are warning,error,info and debug.

2 errors like '^read udp .* i/o timeout$' occurred in last 30s

Multiple consolidate options with different DURATION and REGEXP are allowed. In case if some error message corresponds to several defined regular expressions the message will be associated with the first appropriate REGEXP.

For better performance, it's recommended to use the ^ or $ metacharacters in regular expression when filtering error messages by prefix or suffix, e.g. ^failed to .*, or .* timeout$.

Examples

Use the whoami to respond to queries in the example.org domain and Log errors to standard output.

example.org {
    whoami
    errors
}

Use the forward plugin to resolve queries via 8.8.8.8 and print consolidated messages for errors with suffix " i/o timeout" as warnings, and errors with prefix "Failed to " as errors.

. {
    forward . 8.8.8.8
    errors {
        consolidate 5m ".* i/o timeout$" warning
        consolidate 30s "^Failed to .+"
    }
}