1. system service로 운영 중인 prometheus
- 보관 주기를 설정하지 않으면 기본 보관 주기 15d로 설정된다.
- metric 보관 기간을 늘리고 싶다면 --storage.tsdb.retention.time=1y를 추가해 주면 된다.
vi /etc/systemd/system/prometheus.service
# 또는
vi /usr/lib/systemd/system/prometheus.service
# 등등
[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 \
--web.external-url=http://serverip:9090 \
--storage.tsdb.retention.time=1y # 추가
[Install]
WantedBy=multi-user.target
2. pod로 운영 중인 prometheus
- deployment를 수정해야함
- metric 보관 기간을 늘리고 싶다면 - --storage.tsdb.retention.time=90d를 추가해 주면 된다.
prometheus-server
- args:
- --storage.tsdb.retention.time=90d
대신 pod로 기동 중인 prometheus-server의 deployment를 수정하고 나면 추가로 해야 할 작업들이 있다.
2-1. deployment를 수정한 pod는 아마 정상적으로 기동 되지 않고 Status가 Error로 떠있을 것이다.
pod의 log를 확인하면 아래와 유사한 메시지가 보일 것이다.
level=info ts=2022-07-22T07:37:55.811Z caller=main.go:583 msg="Stopping scrape manager..."
level=info ts=2022-07-22T07:37:55.811Z caller=main.go:557 msg="Notify discovery manager stopped"
level=info ts=2022-07-22T07:37:55.811Z caller=web.go:523 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2022-07-22T07:37:55.811Z caller=main.go:543 msg="Scrape discovery manager stopped"
level=info ts=2022-07-22T07:37:55.811Z caller=manager.go:882 component="rule manager" msg="Stopping rule manager..."
level=info ts=2022-07-22T07:37:55.811Z caller=manager.go:892 component="rule manager" msg="Rule manager stopped"
level=info ts=2022-07-22T07:37:55.811Z caller=notifier.go:601 component=notifier msg="Stopping notification manager..."
level=info ts=2022-07-22T07:37:55.811Z caller=main.go:749 msg="Notifier manager stopped"
level=info ts=2022-07-22T07:37:55.811Z caller=main.go:577 msg="Scrape manager stopped"
level=error ts=2022-07-22T07:37:55.811Z caller=main.go:758 err="opening storage failed: lock DB directory: resource temporarily unavailable"
이런 경우는 pv, pvc에 연결되어 있는 경로로 가서 lock 파일만 삭제하고 다시 재기동을 해주면 된다.
2-2. pv, pvc에 아마 용량을 세팅해 뒀을 텐데 그 용량도 metric 기간이 늘어난 만큼 늘려줘야 한다.
참고로 내 경험상 dynamic으로 선언된 pv, pvc는 바로 용량 수정이 되지만 나머지 경우는 pv, pvc를 새로 생성해야 한다.
'모니터링(Grafana, Prometheus) > Prometheus' 카테고리의 다른 글
통합 Prometheus federate 옵션 (0) | 2023.07.04 |
---|---|
Prometheus 이슈 및 troubleshooting (0) | 2023.05.04 |
Prometheus Helm 설치 (0) | 2023.05.01 |
Prometheus Windows exporter 연결 (0) | 2023.04.30 |
Windows exporter 설치 옵션 (0) | 2023.04.28 |