Logging
By default prometheus logs to syslog, and it doesn’t have an option to set a logging to a file in this runbook we cover prometheus file logging
Prometheus can be configured to log different levels by default the level of log is info
and you can also control the log format, prometheus supports two formats
Many companies use some sort of log agent that collect logs from different services and send them to a indexing platform, like filebeat
for example, hence the need for prometheus to log in a file.
You can enable file logging using rsyslog configs
Rsyslog config
Create a config under /etc/rsyslog.d/10-prometheus.conf
This config tells rsyslog to redirect every log entry containing prometheus in the service name to a file “/var/log/prometheus/prometheus.log`
Be careful not to ship logs for another service named prometheus e.g prometheus-exporter
Debug rsyslog
You can mimic logs being produced to syslog using logger and tailing the prometheus file, and/or check logs for rsyslog.