概述
- 记录在使用prometheus常用功能和实验点
配置热更新
- 启动配置热更新功能:–web.enable-lifecycle
- 通过http发送热更新指令:http://prometheus-server:9090/-/reload
注意该指令如正确,http响应码为200
如错误,则响应码为500,并返回错误信息
failed to reload config: couldn’t load configuration
(–config.file="/prometheus/etc/prometheus.yml"): parsing YAML file
/prometheus/etc/prometheus.yml: yaml: line 40: could not find expected
‘:’
- 服务端日志记录:
prometheus-server_1 | level=info ts=2020-02-18T14:15:54.663Z
caller=main.go:734 msg=“Loading configuration file”
filename=/prometheus/etc/prometheus.yml prometheus-server_1 |
level=info ts=2020-02-18T14:15:54.664Z caller=main.go:762
msg=“Completed loading of configuration file”
filename=/prometheus/etc/prometheus.yml
pushgateway 推送
- 环境:启动prometheus-gateway服务,监听端口为:9091
- 推送数据内容
cat <<EOF | curl --data-binary @- http://prometheus-gateway:9091/metrics/job/my_job/instance/my_instance
# TYPE my_metric counter
my_metric{label="val"} 88
EOF
- 服务端抓取结果
my_metric{exported_instance=“my_instance”,exported_job=“my_job”,instance=“gateway:9091”,job=“prometheus”,label=“val”} 88