在我添加--storage.tsdb.retention.time=1y
之前,普罗米修斯一直工作得很好。服务文件如下所示:
[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
重新启动服务后,以下内容将记录到journattl:
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.
操作系统版本是Centos 7,普罗米修斯版本是:
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
该服务实际上已启动,但保留时间设置为默认的15天。你知道为什么会发生这种事吗?
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
与我的文件进行比较。我在您的文件中没有看到--web.listen-address
和Environment变量。