标签:tag col default 实现 eof intro register ref 自定义标签
192.168.122.211 |
Consul Prometheus |
---|---|
192.168.122.212 |
node_export |
# consul
docker run --name consul -d -p 8500:8500 consul
useradd —M -s /sbin/nologin prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz -O /opt/prometheus
tar -xf prometheus-2.19.2.linux-amd64.tar.gz -O /opt
mv prometheus-2.19.2.linux-amd64/ prometheus
chown -R prometheus.prometheus /opt/prometheus
# 数据目录 SSD
mkdir -pv /opt/prometheus/data
cat << EOF > ./prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=prometheus
Restart=on-failure
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
EOF
systemctl link /opt/node_exporter/prometheus.service
wget https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz -O /opt/prometheus
mv node_exporter-1.0.1.linux-amd64 node_exporter
chown -R prometheus.prometheus /opt/prometheus
cat << EOF > ./node_exporter.service
#Prometheus Node Exporter Upstart script
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
ExecStart=/opt/prometheus/node_exporter/node_exporter
[Install]
WantedBy=default.target
EOF
systemctl link /opt/node_exporter/node_exporter.service
systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus
systemctl enable node_exporter
systemctl start node_exporter
#1 / 注册API
curl -X PUT -d ‘{"id": "node-exporter","name": "node-exporter-192.168.122.212","address": "192.168.122.212","port": 9100,"tags": ["test"],"checks": [{"http": "http://192.168.122.212:9100/metrics", "interval": "5s"}]}‘ http://192.168.122.211/v1/agent/service/register
#2 / 注销API 注销上边添加的 node-exporter服务
curl -X PUT http://192.168.122.211:8500/v1/agent/service/deregister/node-exporter
- job_name: ‘consul‘
consul_sd_configs:
- server: ‘192.168.112.212:8500‘
services: []
consul_sd_configs
来配置使用 Consul 服务发现类型,server
为 Consul 的服务地址
后续还会有很多问题如:
relabel_configs
来进行匹配区分、自定义标签信息添加到 Meta Data 数据 等详情见:
标签:tag col default 实现 eof intro register ref 自定义标签
原文地址:https://www.cnblogs.com/3rdworld/p/13229473.html