Pushgateway是一個獨立的服務,Pushgateway位於應用程序發送指標和Prometheus服務器之間。linux
Pushgateway接收指標,而後將其做爲目標被Prometheus服務器拉取。能夠將其看做代理服務,或者與blackbox exporter的行爲相反, 它接收度量,而不是探測它們。json
一、安裝部署bash
cd /usr/loacl tar -xvf pushgateway-0.7.0.linux-amd64.tar.gz ln -s /usr/local/pushgateway-0.7.0.linux-amd64 /usr/local/pushgateway cd /usr/local/pushgateway;mkdir bin mv ./pushgateway bin data
二、啓動服務器
nohup /usr/local/pushgateway/bin/pushgateway --persistence.file=/usr/local/pushgateway/data/pushgateway.data > pushgateway.out 2>&1 &
三、插入數據curl
格式以下: /metrics/job/<jobname>{/<label>/<label>}url
echo 'user_counter{name="shhnwangjian"} 1' | curl --data-binary @- http://192.168.31.82:9091/metrics/job/shhnwangjian/label1/test
四、查詢數據spa
curl http://192.168.31.82:9091/metrics
五、配置prometheus.yml代理
- job_name: 'pushgateway' honor_labels: true file_sd_configs: - files: - targets/pushgateway/*.json refresh_interval: 5m
六、新增pushgateway.jsonblog
[{ "targets": ["192.168.31.82:9091"] }]
七、重載部署
curl -X POST http://127.0.0.1:9090/-/reload