以中文原生形式改述以上句子,仅提供以下选项:尝试使用Prometheus和Grafana
开始
使用Docker Compose轻松运行。
docker-compose up
version: '3.1'
services:
prometheus:
image: prom/prometheus
container_name: prometheus
ports:
- 9090:9090
networks:
- public
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
pushgateway:
image: prom/pushgateway
container_name: pushgateway
ports:
- 9091:9091
networks:
- public
grafana:
image: kannkyo/grafana
container_name: grafana
ports:
- 3000:3000
networks:
- public
networks:
public:
scrape_configs:
- job_name: 'pushgateway'
scrape_interval: 1s
static_configs:
- targets: ['pushgateway:9091']
labels:
environment: "hoge"
category: "pushgateway"
表达
普罗米修斯
推送网关
Grafana 视图
操作指标
通过docker-compose.yml中的网络配置,可以将指标从pushgateway发送到prometheus,再到grafana。
可以使用以下脚本来推送或清除指标。
推动度量指标
#!/bin/bash
JOB=pushgateway
MAX_VAL=100
DATA=$(($RANDOM % $MAX_VAL))
METRICS="some_metric $DATA"
echo $METRICS
echo $METRICS | curl --data-binary @- http://localhost:9091/metrics/job/$JOB
完成指标
#!/bin/bash
JOB=pushgateway
curl -X DELETE http://localhost:9091/metrics/job/$JOB