1隆箩、下載:
下載地址:
https://prometheus.io/download/
可根據(jù)需求下載不同版本
wget https://github.com/prometheus/prometheus/releases/download/v2.39.1/prometheus-2.39.1.linux-amd64.tar.gz
tar -axvf prometheus-2.39.1.linux-amd64.tar.gz
2该贾、配置文件修改
這里以pulsar服務(wù)的yml 下面啟動(dòng)的時(shí)候會(huì)配置上這個(gè)文件, prometheus服務(wù)就會(huì)從這個(gè)配置文件中讀需要監(jiān)控的機(jī)器or服務(wù)
job_name 為node的節(jié)點(diǎn)就是上文在服務(wù)上安裝的node_exporter服務(wù)的地址
prometheus.yml
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
# scrape_timeout is set to the global default (10s).
external_labels:
cluster: 'bigdata-pulsar-cluster'
# Load and evaluate rules in these files every 'evaluation_interval' seconds.
# rule_files:
scrape_configs:
- job_name: "broker"
honor_labels: true # don't overwrite job & instance labels
static_configs:
- targets:
- 'IP1:PORT'
- 'IP2:PORT'
...
- job_name: "bookie"
honor_labels: true # don't overwrite job & instance labels
static_configs:
- targets:
- 'IP1:PORT'
- 'IP2:PORT'
...
- job_name: "zookeeper"
honor_labels: true
static_configs:
- targets:
- 'IP1:PORT'
- 'IP2:PORT'
...
- job_name: "node"
honor_labels: true # don't overwrite job & instance labels
static_configs:
- targets:
- 'IP1:PORT'
...
3、啟動(dòng)
# 注冊(cè)成系統(tǒng)服務(wù)
vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network.target
[Service]
ExecStart=/home/monitor/prometheus/prometheus-2.39.1.linux-amd64/prometheus --config.file "/home/monitor/prometheus/prometheus-2.39.1.linux-amd64/prometheus_pulsar.yml" --web.enable-lifecycle --web.listen-address=:8091 --storage.tsdb.retention=30d
User=root
[Install]
WantedBy=multi-user.target
# 參數(shù)說明:
web.listen-address=:8091 指定服務(wù)的端口捌臊,默認(rèn)9090
storage.tsdb.retention=30d 數(shù)據(jù)存儲(chǔ)的時(shí)間
web.enable-lifecycle 熱加載配置文件
config.file 指定yml文件的地址
# 重載/開機(jī)自啟/查看狀態(tài)/啟動(dòng)
systemctl daemon-reload
systemctl enable prometheus
systemctl status prometheus
systemctl start prometheus
4杨蛋、測(cè)試
# 查看服務(wù)是否啟動(dòng):
lsof -i:8091
ps -ef | grep prometheus
地址:
http://IP:8091/targets