docs-v2/content/influxdb/v2/admin/logs.md

8.2 KiB

title description menu weight
Manage InfluxDB logs Learn how to configure, manage, and process your InfluxDB logs.
influxdb_v2
name parent
Manage logs Administer InfluxDB
20

Learn how to configure, manage, and process your InfluxDB logs:

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

{{% note %}} When logging to a file, InfluxDB uses the logfmt format. {{% /note %}}

Logs when running InfluxDB as a service

If you use a service manager to run InfluxDB, the service manager determines the location of logs.

{{< tabs-wrapper >}} {{% tabs %}} systemd sysvinit {{% /tabs %}}

{{% tab-content %}}

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.

{{% /tab-content %}}

{{% tab-content %}}

When InfluxDB is run as a service, stdout is discarded by default (sent to /dev/null). To write logs to a file:

  1. Open the InfluxDB startup script (/etc/default/influxdb) in a text editor.

  2. Set the STDOUT environment variable to the path where you want to store the InfluxDB logs. For example:

    STDOUT=/var/log/influxdb/influxd.log
    
  3. Save the changes to the startup script.

  4. Restart the InfluxDB service to apply the changes.

    service influxdb restart
    

{{% /tab-content %}}

{{< /tabs-wrapper >}}

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.

{{< tabs-wrapper >}} {{% tabs "small" %}} influxd flag Environment variable InfluxDB configuration file {{% /tabs %}}

{{% tab-content %}}

influxd --log-level=info

{{% /tab-content %}}

{{% tab-content %}}

export INFLUXD_LOG_LEVEL=info

{{% /tab-content %}}

{{% tab-content %}}

{{< code-tabs-wrapper >}} {{% code-tabs %}} YAML TOML JSON {{% /code-tabs %}} {{% code-tab-content %}}

log-level: info

{{% /code-tab-content %}} {{% code-tab-content %}}

log-level = "info"

{{% /code-tab-content %}} {{% code-tab-content %}}

{
  "log-level": "info"
}

{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}

{{% /tab-content %}}

{{< /tabs-wrapper >}}

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.

{{< tabs-wrapper >}} {{% tabs "small" %}} influxd flag Environment variable InfluxDB configuration file {{% /tabs %}}

{{% tab-content %}}

influxd --flux-log-enabled

{{% /tab-content %}}

{{% tab-content %}}

export INFLUXD_FLUX_LOG_ENABLED=true

{{% /tab-content %}}

{{% tab-content %}}

{{< code-tabs-wrapper >}} {{% code-tabs %}} YAML TOML JSON {{% /code-tabs %}} {{% code-tab-content %}}

flux-log-enabled: true

{{% /code-tab-content %}} {{% code-tab-content %}}

flux-log-enabled = true

{{% /code-tab-content %}} {{% code-tab-content %}}

{
  "flux-log-enabled": true
}

{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}

{{% /tab-content %}}

{{< /tabs-wrapper >}}

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