-
Log and trace with InfluxDB
InfluxDB writes log output, by default, to
stderr
, all logs are written tostderr
.(about stderr see refe No.1).You can also redirect the log output, as you would any output to stderr.
influxd 2>$HOME/my_log_file
-
HTTP access log
Use the HTTP access log to log HTTP request traffic separately from the other InfluxDB log output.
# HTTP access log format 172.13.8.13,172.39.5.169 - - [21/Jul/2019:03:01:27 +0000] "GET /query?db=metrics&q=SELECT+MEAN%28value%29+as+average_cpu%2C+MAX%28value%29+as+peak_cpu+FROM+%22foo.load%22+WHERE+time+%3E%3D+now%28%29+-+1m+AND+org_id+%21%3D+%27%27+AND+group_id+%21%3D+%27%27+GROUP+BY+org_id%2Cgroup_id HTTP/1.0" 200 11450 "-" "Baz Service" d6ca5a13-at63-11o9-8942-000000000000 9337349
When HTTP request logging is enabled, the HTTP logs are intermingled by default with internal InfluxDB logging.By redirecting the HTTP request log entries to a separate file, both log files are easier to read, monitor, and debug.
How to redirect HTTP request logging:
Locate the
[http]
section of your InfluxDB configuration file and set theaccess-log-path
option(Environment variable:INFLUXDB_HTTP_ACCESS_LOG_PATH
) to specify the path where HTTP log entries should be written.How to disable HTTP request logging:
Locate the
[http]
section ,uselog-enabled = false
(Environment variable :INFLUXDB_HTTP_LOG_ENABLED
)Docker内:
在docker-compose.yml文件内,设置
service-->influxdb-->environment
下INFLUXDB_HTTP_LOG_ENABLED:"false"
-
配置文件与环境变量
All of the configuration settings in the configuration file can be specified either in the configuration file or in an environment variable.
All of the InfluxDB-specific envirenment variables are prefixed with
INFLUXDB_
.The InfluxDB system has internal defaults for all of the settings in the configuration file. To view the default configuration settings, use the
influxd config
command(在InfluxDB安装环境运行,比如运行在Docker的就要进入Docker之后运行).The local InfluxDB configuration file is located here:
- Linux:
/etc/influxdb/influxdb.conf
- macOS:
/usr/local/etc/influxdb.conf
- Linux:
-
References
- 什么是stderr