Prometheus
簡(jiǎn)介
Prometheus是一個(gè)開(kāi)源的系統(tǒng)監(jiān)控和報(bào)警系統(tǒng),現(xiàn)在已經(jīng)加入到CNCF基金會(huì),成為繼k8s之后第二個(gè)在CNCF托管的項(xiàng)目,在kubernetes容器管理系統(tǒng)中,通常會(huì)搭配prometheus進(jìn)行監(jiān)控,同時(shí)也支持多種exporter采集數(shù)據(jù),還支持pushgateway進(jìn)行數(shù)據(jù)上報(bào),Prometheus性能足夠支撐上萬(wàn)臺(tái)規(guī)模的集群。
下載軟件包
wget https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz
安裝部署
解壓
tar zxvf prometheus-2.19.2.linux-amd64.tar.gz
mv prometheus-2.19.2.linux-amd64 /usr/local/prometheus
創(chuàng)建用戶
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus -R /usr/local/prometheus
創(chuàng)建Systemd服務(wù)
cat > /etc/systemd/system/prometheus.service <<EOF
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
修改配置文件prometheus.yml
前面部分基本沒(méi)改動(dòng),沿用默認(rèn)配置。
參數(shù) | 作用 |
---|---|
scrape_interval | 默認(rèn)抓取間隔, 15秒向目標(biāo)抓取一次數(shù)據(jù) |
scrape_configs | 這個(gè)配置是表示在這個(gè)配置內(nèi)的時(shí)間序例,每一條都會(huì)自動(dòng)添加上這個(gè){job_name:“prometheus”}的標(biāo)簽 - job_name: ‘prometheus’ |
job_name | 默認(rèn)抓取間隔, 15秒向目標(biāo)抓取一次數(shù)據(jù) |
scrape_interval | 監(jiān)控名稱,相當(dāng)于分組組名之類 (可手動(dòng)自定義添加) |
static_configs | 配置靜態(tài)獲取地址,與targets配合使用 |
file_sd_configs | 引用外部獲取地址,與files配合使用 |
files | 外部獲取地址文件指定,外部IP地址需要以json格式。 此方法優(yōu)點(diǎn)適合大集群規(guī)模,可以根據(jù)hosts文件,批量生成json文件??梢灾苯犹砑覫P地址,不用修改主配置,不用重啟prometheus |
最終配置文件如下:
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'linux_server' #自定義名稱,用于監(jiān)控linux基礎(chǔ)服務(wù)
file_sd_configs:
- files:
- configs/linux.json #linux機(jī)器IP地址json文件
- job_name: 'hdfs' #用于監(jiān)控HDFS組件
file_sd_configs:
- files:
- configs/hdfs.json #hdfs參數(shù)獲取地址
- job_name: 'hbase' #用于監(jiān)控Hbase組件
file_sd_configs:
- files:
- configs/hbase.json #hbase參數(shù)獲取地址
- job_name: 'yarn' #用于監(jiān)控Yarn組件
file_sd_configs:
- files:
- configs/yarn.json #yarn參數(shù)獲取地址
- job_name: 'zookeeper' #用于監(jiān)控zk組件
file_sd_configs:
- files:
- configs/zookeeper.json #zk參數(shù)獲取地址
- job_name: 'hive'
file_sd_configs:
- files:
- configs/hive.json
- job_name: 'kafka'
file_sd_configs:
- files:
- configs/kafka.json
- job_name: 'spark'
file_sd_configs:
- files:
- configs/spark.json
啟動(dòng)Prometheus
systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus
systemctl enable prometheus
node exporter
Exporter是Prometheus的指標(biāo)數(shù)據(jù)收集組件。它負(fù)責(zé)從目標(biāo)Jobs收集數(shù)據(jù),并把收集到的數(shù)據(jù)轉(zhuǎn)換為Prometheus支持的時(shí)序數(shù)據(jù)格式。 和傳統(tǒng)的指標(biāo)數(shù)據(jù)收集組件不同的是,他只負(fù)責(zé)收集,并不向Server端發(fā)送數(shù)據(jù),而是等待Prometheus Server 主動(dòng)抓取.
node-exporter 默認(rèn)的抓取url地址:http://ip:9100/metrics
另外,如果因?yàn)榄h(huán)境原因,網(wǎng)絡(luò)不可達(dá)的場(chǎng)景,Prometheus可以使用Pushgateway 這個(gè)組件推送node-exporter的指標(biāo)數(shù)據(jù)到遠(yuǎn)端Prometheus
node-exporter用于采集node的運(yùn)行指標(biāo),包括node的cpu、load、filesystem、meminfo、network等基礎(chǔ)監(jiān)控指標(biāo),類似于zabbix監(jiān)控系統(tǒng)的的zabbix-agent
node-exporter由Prometheus官方提供、維護(hù),屬于監(jiān)控指標(biāo)收集類UNIX內(nèi)核操作系統(tǒng)的必備的exporter。
下載軟件包
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
安裝部署
解壓
tar zxvf node_exporter-1.5.0.linux-amd64.tar.gz
mv node_exporter-1.5.0.linux-amd64 /usr/local/node_exporter
創(chuàng)建systemd服務(wù)
vim /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
啟動(dòng)node_exporter
systemctl daemon-reload
systemctl start node_exporter
systemctl status node_exporter
systemctl enable node_exporter
graphite_exporter
Graphite 來(lái)收集度量標(biāo)準(zhǔn),Grafana 則用于構(gòu)建儀表板,首先,需要配置 Spark 以將 metrics 報(bào)告到 Graphite。
prometheus 提供了一個(gè)插件(graphite_exporter),可以將 Graphite metrics 進(jìn)行轉(zhuǎn)化并寫(xiě)入 Prometheus (本文的方式)。
graphite_exporter 接收數(shù)據(jù)端口為9109
下載軟件包
https://github.com/prometheus/graphite_exporter/releases/download/v0.12.4/graphite_exporter-0.12.4.linux-amd64.tar.gz
安裝部署
解壓文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-400726.html
tar -xvzf graphite_exporter-0.12.4.linux-amd64.tar.gz
mv graphite_exporter-0.12.4.linux-amd64 /usr/local/graphite_exporter
創(chuàng)建systemd服務(wù)
vim /usr/lib/systemd/system/graphite_exporter.service
[Unit]
Description=prometheus graphite_exporter
[Service]
Type=simple
ExecStart=/usr/local/graphite_exporter/graphite_exporter --graphite.mapping-config=/usr/local/graphite_exporter/graphite_exporter_mapping
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
啟動(dòng) graphite_exporter
systemctl daemon-reload
systemctl restart graphite_exporter.service
systemctl enable graphite_exporter.service
systemctl status graphite_exporter
希望對(duì)正在查看文章的您有所幫助,記得關(guān)注、評(píng)論、收藏,謝謝您文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-400726.html
到了這里,關(guān)于【大數(shù)據(jù)監(jiān)控】Prometheus、Node_exporter、Graphite_exporter安裝部署詳細(xì)文檔的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!