Intelligent operation and maintenance-Pushgateway pushes monitoring indicators to the configuration of Prometheus

Looking for an example of Short-lived Jobs, configure it to push monitoring indicators to Pushgateway ?

1) Install pushgateway
#docker pull prom/pushgateway
#docker run -d   -p 9091:9091   prom/pushgateway

#访问http://172.17.0.41:9091
2) Add pushgateway in prometheus configuration file
  ...
  - job_name: pushgateway
    static_configs:
      - targets: ['172.17.0.41:9091']
        labels:
          instance: pushgateway
  ...
3) Push data from API to pushgateway
	Push 数据到 PushGateway 中,可以通过其提供的 API 标准接口来添加,默认 URL 地址为:http://<ip>:9091/metrics/job/<JOBNAME>{/<LABEL_NAME>/<LABEL_VALUE>},

This is a required item, which is the value of the job tag, which can be followed by any number of tag pairs. Generally, we will add an instance / <INSTANCE_NAME> instance name tag to facilitate the differentiation of various indicators.
Next, you can push a simple indicator data to PushGateway to test it.

#向 {job="some_job"} 添加单条数据:
#echo "some_metric 3.14" | curl --data-binary @- http://172.17.0.41:9091/metrics/job/some_job

#添加更多更复杂数据,通常数据会带上 instance, 表示来源位置:
cat <<EOF | curl --data-binary @- http://172.17.0.41:9091/metrics/job/some_job/instance/some_instance
# TYPE some_metric counter
some_metric{label="val1"} 42
# TYPE another_metric gauge
# HELP another_metric Just an example.
another_metric 2398.283
EOF

cat <<EOF | curl --data-binary @- http://172.17.0.41:9091/metrics/job/some_job/instance/some_instance
some_metric{label="val1"} 42
another_metric 2398.283
EOF

#删除某个组下的某实例的所有数据:
 curl -X DELETE http:/172.17.0.41:9091/metrics/job/some_job/instance/some_instance

#删除某个组下的所有数据:
curl -X DELETE http://172.17.0.41:9091/metrics/job/some_job
4) Screenshot of successful data push

Insert picture description here

Published 10 original articles · Likes0 · Visits 236

Guess you like

Origin blog.csdn.net/qq_27412807/article/details/105111814