0

Prometheus was working fine until I added --storage.tsdb.retention.time=1y. Service file looks like this:

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--storage.tsdb.retention.time=1y

[Install]
WantedBy=multi-user.target

The following is logged to journactl after restarting the service:

Mar 16 15:33:15 myserver.com systemd[1]: [/etc/systemd/system/prometheus.service:10] Trailing garbage, ignoring.
Mar 16 15:33:15 myserver.com systemd[1]: [/etc/systemd/system/prometheus.service:11] Unknown lvalue '--config.file /etc/prometheus/prometheus.yml  --storage.tsdb.path /var/lib/prometheus/  --web.console.templates' in section '
Service'
Mar 16 15:33:15 myserver.com systemd[1]: prometheus.service lacks both ExecStart= and ExecStop= setting. Refusing.

OS version is Centos 7 and Prometheus version is:

prometheus, version 2.33.4 (branch: HEAD, revision: 83032011a5d3e6102624fe58241a374a7201fee8)
  build user:       root@d13bf69e7be8
  build date:       20220222-16:51:28
  go version:       go1.17.7
  platform:         linux/amd6

The service actually starts, but the retention time is set to the default 15 days. Any idea on why this is happening?

tomi
  • 373
  • 1
  • 5
  • 16

1 Answers1

0
Type=simple
Environment="GOMAXPROCS=2"
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus \
  --web.console.templates=/etc/prometheus/consoles \
  --web.console.libraries=/etc/prometheus/console_libraries \
  --web.listen-address=0.0.0.0:9090 \
  --web.external-url= \
  --storage.tsdb.retention.time=30d

Compare with my file. I do not see --web.listen-address and Environment variable in your file.