Manage InfluxDB logs
Learn how to configure, manage, and process your InfluxDB logs:
- Configure your InfluxDB log location
- Configure your log level
- Enable the Flux query log
- Use external tools to manage and process logs
- Log formats
Configure your InfluxDB log location
By default, InfluxDB outputs all logs to stdout. To view InfluxDB logs, view the output of the influxd process.
Write logs to a file
To write InfluxDB logs to a file, redirect stdout to a file when starting the InfluxDB service (influxd).
influxd 1> /path/to/influxdb.log
When logging to a file, InfluxDB uses the logfmt format.
Logs when running InfluxDB as a service
If you use a service manager to run InfluxDB, the service manager determines the location of logs.
Most Linux systems direct logs to the systemd
journal. To access these logs, use the following command:
sudo journalctl -u influxdb.service
For more information, see the journald.conf documentation.
When InfluxDB is run as a service, stdout is discarded by default (sent to /dev/null
). To write logs to a file:
Open the InfluxDB startup script (
/etc/default/influxdb
) in a text editor.Set the
STDOUT
environment variable to the path where you want to store the InfluxDB logs. For example:STDOUT=/var/log/influxdb/influxd.log
Save the changes to the startup script.
Restart the InfluxDB service to apply the changes.
service influxdb restart
Configure your log level
Use the log-level InfluxDB configuration option to specify the log levels the InfluxDB service outputs. InfluxDB supports the following log levels:
- debug: Output logs with debug, info, and error log levels.
- info: (Default) Output logs with info and error log levels.
- error: Output logs with the error log level only.
influxd flag Environment variable InfluxDB configuration file
influxd --log-level=info
export INFLUXD_LOG_LEVEL=info
log-level: info
log-level = "info"
{
"log-level": "info"
}
For information about configuring InfluxDB, see InfluxDB configuration options.
Enable the Flux query log
Use the flux-log-enabled configuration option to enable Flux query logging. InfluxDB outputs Flux query logs to stdout with all other InfluxDB logs.
influxd flag Environment variable InfluxDB configuration file
influxd --flux-log-enabled
export INFLUXD_FLUX_LOG_ENABLED=true
flux-log-enabled: true
flux-log-enabled = true
{
"flux-log-enabled": true
}
For information about configuring InfluxDB, see InfluxDB configuration options.
Use external tools to manage and process logs
Use the following popular tools to manage and process InfluxDB logs:
logrotate
logrotate simplifies the administration of log files and provides automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file hourly, daily, weekly, monthly or when the log file gets to a certain size.
hutils
hutils is a collection of command line utilities for working with logs with logfmt encoding, including:
- lcut: Extracts values from a logfmt trace based on a specified field name.
- lfmt: Reformats and highlights key sections of logfmt lines.
- ltap: Accesses messages from log providers in a consistent way to allow easy parsing by other utilities that operate on logfmt traces.
- lviz: Visualizes logfmt output by building a tree out of a dataset combining common sets of key-value pairs into shared parent nodes.
lnav (Log File Navigator)
lnav (Log File Navigator) is an advanced log file viewer useful for watching and analyzing log files from a terminal. The lnav viewer provides a single log view, automatic log format detection, filtering, timeline view, pretty-print view, and querying logs using SQL.
Log formats
InfluxDB outputs logs in one of two formats depending on the location of where logs are output.
Console/TTY
When logging to a terminal or other TTY devices, InfluxDB uses a console-friendly format.
Example console/TTY format
2022-09-29T21:58:29.936355Z info Welcome to InfluxDB {"log_id": "0dEoz3C0000", "version": "dev", "commit": "663d43d210", "build_date": "2022-09-29T21:58:29Z", "log_level": "info"}
2022-09-29T21:58:29.977671Z info Resources opened {"log_id": "0dEoz3C0000", "service": "bolt", "path": "/Users/exampleuser/.influxdbv2/influxd.bolt"}
2022-09-29T21:58:29.977891Z info Resources opened {"log_id": "0dEoz3C0000", "service": "sqlite", "path": "/Users/exampleuser/.influxdbv2/influxd.sqlite"}
2022-09-29T21:58:30.059709Z info Checking InfluxDB metadata for prior version. {"log_id": "0dEoz3C0000", "bolt_path": "/Users/exampleuser/.influxdbv2/influxd.bolt"}
logfmt
When logging to a file, InfluxDB uses logfmt, a machine-readable structured log format that provides simpler integrations with external tools like Splunk, Papertrail, Elasticsearch, and other third party tools.
Example logfmt format
ts=2022-09-29T16:54:16.021427Z lvl=info msg="Welcome to InfluxDB" log_id=0dEYZvqG000 version=dev commit=663d43d210 build_date=2022-09-29T16:54:15Z log_level=info
ts=2022-09-29T16:54:16.062239Z lvl=info msg="Resources opened" log_id=0dEYZvqG000 service=bolt path=/Users/exampleuser/.influxdbv2/influxd.bolt
ts=2022-09-29T16:54:16.062457Z lvl=info msg="Resources opened" log_id=0dEYZvqG000 service=sqlite path=/Users/exampleuser/.influxdbv2/influxd.sqlite
ts=2022-09-29T16:54:16.144430Z lvl=info msg="Checking InfluxDB metadata for prior version." log_id=0dEYZvqG000 bolt_path=/Users/exampleuser/.influxdbv2/influxd.bolt