「Prometheus」:修訂間差異
跳至導覽
跳至搜尋
第6行: | 第6行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
export PROMETHEUS_VERSION=2.23.0; cd /tmp; wget https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz; tar xvf prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz; cd prometheus-${PROMETHEUS_VERSION}.linux-amd64; sudo cp -f prometheus promtool /usr/bin; sudo mkdir /etc/prometheus; sudo cp prometheus.yml /etc/prometheus/; sudo cp -R consoles/ console_libraries/ /etc/prometheus/; sudo useradd -r -U prometheus; sudo mkdir /var/lib/prometheus; sudo chown prometheus:prometheus /var/lib/prometheus; echo -e "[Unit]\nDescription=Prometheus Time Series Collection and Processing Server\nWants=network-online.target\nAfter=network-online.target\n\n[Service]\nUser=prometheus\nGroup=prometheus | export PROMETHEUS_VERSION=2.23.0; cd /tmp; wget https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz; tar xvf prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz; cd prometheus-${PROMETHEUS_VERSION}.linux-amd64; sudo cp -f prometheus promtool /usr/bin; sudo mkdir /etc/prometheus; sudo cp prometheus.yml /etc/prometheus/; sudo cp -R consoles/ console_libraries/ /etc/prometheus/; sudo useradd -r -U prometheus; sudo mkdir /var/lib/prometheus; sudo chown prometheus:prometheus /var/lib/prometheus; echo -e "[Unit]\nDescription=Prometheus Time Series Collection and Processing Server\nWants=network-online.target\nAfter=network-online.target\n\n[Service]\nUser=prometheus\nGroup=prometheus\nType=simple\nExecStart=/usr/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\n\n[Install]\nWantedBy=multi-user.target" | sudo tee /lib/systemd/system/prometheus.service; sudo systemctl daemon-reload; sudo systemctl enable prometheus; sudo service prometheus start | ||
</syntaxhighlight> | </syntaxhighlight> | ||
於 2021年9月25日 (六) 12:13 的修訂
Prometheus是一個TSDB。
安裝
Ubuntu 20.04系統內的Prometheus太舊(2.15),加上沒有適合的PPA可以用,這邊使用官方的binary安裝:
export PROMETHEUS_VERSION=2.23.0; cd /tmp; wget https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz; tar xvf prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz; cd prometheus-${PROMETHEUS_VERSION}.linux-amd64; sudo cp -f prometheus promtool /usr/bin; sudo mkdir /etc/prometheus; sudo cp prometheus.yml /etc/prometheus/; sudo cp -R consoles/ console_libraries/ /etc/prometheus/; sudo useradd -r -U prometheus; sudo mkdir /var/lib/prometheus; sudo chown prometheus:prometheus /var/lib/prometheus; echo -e "[Unit]\nDescription=Prometheus Time Series Collection and Processing Server\nWants=network-online.target\nAfter=network-online.target\n\n[Service]\nUser=prometheus\nGroup=prometheus\nType=simple\nExecStart=/usr/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\n\n[Install]\nWantedBy=multi-user.target" | sudo tee /lib/systemd/system/prometheus.service; sudo systemctl daemon-reload; sudo systemctl enable prometheus; sudo service prometheus start
另外一起裝Alertmanager:
export ALERTMANAGER_VERSION=0.23.0; cd /tmp; wget https://github.com/prometheus/alertmanager/releases/download/v${ALERTMANAGER_VERSION}/alertmanager-${ALERTMANAGER_VERSION}.linux-amd64.tar.gz; tar xvf alertmanager-${ALERTMANAGER_VERSION}.linux-amd64.tar.gz; cd alertmanager-${ALERTMANAGER_VERSION}.linux-amd64; sudo cp -f alertmanager amtool /usr/bin; sudo mkdir /etc/amtool; sudo cp alertmanager.yml /etc/amtool
設定
要注意官方安裝檔內的prometheus.yml
中scrape_interval
與evaluation_interval
預設是15s
(但不設定時預設是1m
),正常情況下5m
應該是夠用,可以考慮指定5m
降低頻率。
外部連結
- 官方網站 (英文)