官方文档:https://prometheus.io/docs/prometheus/latest/getting_started/
其他参考:CentOS7安装部署Prometheus+Grafana
1.安装Prometheus
官方网站下载二进制安装包:https://prometheus.io/download/
可以选择mac,linux和Windows版本
1 | https://github.com/prometheus/prometheus/releases/download/v2.36.1/prometheus-2.36.1.linux-amd64.tar.gz |
2.修改prometheus配置
配置文件为prometheus.yml
prometheus采集数据的方法分成推和拉
1.prometheus定时通过exporter暴露的HTTP端口主动去采集监控数据的方式就是拉
下面就是配置一个exporter采集任务的例子
1 | scrape_configs: |
2.程序主动上报metrics给prometheus的pushgateway则是推
要主动上报metrics首先要安装pushgateway,参考:prometheus-pushgateway安装
在官方的文档当中,pushgateway唯一推荐使用的场景是在批处理作业运行结果的采集上,其他的建议使用exporter:when-to-use-the-pushgateway