Configure logging

edit

The logging section of the functionbeat.yml config file contains options for configuring the logging output.

For example, the following options configure Functionbeat to log all the debug messages related to event publishing:

logging.level: debug
logging.selectors: ["publisher"]

The logs generated by Functionbeat are written to the CloudWatch log group for the function running on Amazon Web Services (AWS). To view the logs, go to the the monitoring area of the AWS Lambda console and view the CloudWatch log group for the function.

Configuration options

edit

You can specify the following options in the logging section of the functionbeat.yml config file:

logging.level

edit

Minimum log level. One of debug, info, warning, or error. The default log level is info.

debug
Logs debug messages, including a detailed printout of all events flushed. Also logs informational messages, warnings, errors, and critical errors. When the log level is debug, you can specify a list of selectors to display debug messages for specific components. If no selectors are specified, the * selector is used to display debug messages for all components.
info
Logs informational messages, including the number of events that are published. Also logs any warnings, errors, or critical errors.
warning
Logs warnings, errors, and critical errors.
error
Logs errors and critical errors.

logging.selectors

edit

The list of debugging-only selector tags used by different Functionbeat components. Use * to enable debug output for all components. Use publisher to display debug messages related to event publishing.

The list of available selectors may change between releases, so avoid creating tests that depend on specific selectors.

To see which selectors are available, run Functionbeat in debug mode (set logging.level: debug in the configuration). The selector name appears after the log level and is enclosed in brackets.

To configure multiple selectors, use the following YAML list syntax:

logging.selectors: [ harvester, input ]

logging.metrics.enabled

edit

By default, Functionbeat periodically logs its internal metrics that have changed in the last period. For each metric that changed, the delta from the value at the beginning of the period is logged. Also, the total values for all non-zero internal metrics are logged on shutdown. Set this to false to disable this behavior. The default is true.

Here is an example log line:

2017-12-17T19:17:42.667-0500    INFO    [metrics]       log/log.go:110  Non-zero metrics in the last 30s: beat.info.uptime.ms=30004 beat.memstats.gc_next=5046416

Note that we currently offer no backwards compatible guarantees for the internal metrics and for this reason they are also not documented.

logging.metrics.period

edit

The period after which to log the internal metrics. The default is 30s.

logging.metrics.namespaces

edit

A list of metrics namespaces to report in the logs. Defaults to [stats]. stats contains general Beat metrics. dataset and inputs may be present in some Beats and contains module or input metrics.

logging.files.rotateonstartup

edit

If the log file already exists on startup, immediately rotate it and start writing to a new file instead of appending to the existing one. Defaults to true.

Logging format

edit

The logging format is generally the same for each logging output. The one exception is with the syslog output where the timestamp is not included in the message because syslog adds its own timestamp.

Each log message consists of the following parts:

  • Timestamp in ISO8601 format
  • Level
  • Logger name contained in brackets (Optional)
  • File name and line number of the caller
  • Message
  • Structured data encoded in JSON (Optional)

Below are some samples:

2017-12-17T18:54:16.241-0500 INFO logp/core_test.go:13 unnamed global logger

2017-12-17T18:54:16.242-0500 INFO [example] logp/core_test.go:16 some message

2017-12-17T18:54:16.242-0500 INFO [example] logp/core_test.go:19 some message {"x": 1}