pushgateway配置

安装部署与写入独立的日志文件

下载

1
2
wget "https://github.com/prometheus/pushgateway/releases/download/v1.11.1/pushgateway-1.11.1.linux-amd64.tar.gz"
tar zxvf pushgateway-1.11.1.linux-amd64.tar.gz -C /opt/soft/

配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=pushgateway
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target

[Service]
User=prometheus
Group=prometheus
ExecStart=/opt/soft/pushgateway-1.11.1.linux-amd64/pushgateway
StandardOutput=syslog
StardardError=syslog
SyslogIdentifier=pushgateway
Restart=always

[Install]
WantedBy=multi-user.target
1
2
3
4
5
/etc/rsyslog.d/node-exporter.conf
if ($programname == "node-exporter")then{
action(type="omfile" file="/var/log/node-exporter.log")
stop
}
1
2
3
4
5
6
7
cat pushgateway.yml 
scrape_configs:
- job_name: "pushgateway"
honor_labels: true
static_configs:
- targets: ['127.0.0.1:9091']

写入metrics

1
2
3
echo "testcadqueue 111" | curl --data-binary @- http://127.0.0.1:9091/metrics/job/pushgateway/cad/joyplan
多标签写入:
echo "testcadqueue 111" | curl --data-binary @- http://127.0.0.1:9091/metrics/job/pushgateway/env/joyplan/type/cad/name/测试