欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 锐评 > docker部署prometheus

docker部署prometheus

2024/12/1 0:34:35 来源:https://blog.csdn.net/liulunan_lln/article/details/139682179  浏览:    关键词:docker部署prometheus

1.拉取镜像

docker pull prom/prometheus

2.创建配置文件

cd /root/prometheus
touch prometheus.yml
touch first_rules.yml

3.配置文件内容

  • prometheus.yml文件内容
# my global config
global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).
remote_write: # 使用远程存储,VictoriaMetrics时序数据库- url: http://xxx.xxx.xx.xxx:8480/insert/0/prometheusremote_read: # 使用远程读取,VictoriaMetrics时序数据库- url: http://xxx.xxx.xx.xxx:8481/select/0/prometheus# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets: # 告警push到alertmanager集群- xxx.xxx.xx.xxx:9093- xxx.xxx.xx.xxx:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:- "/etc/prometheus/rules/first_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]
  • first_rule.yml配置文件内容
groups:
- name: default_grouprules:- alert: sqlserver-defaultannotations:description: sqlserver-exporter............summary: sqlserver-exporter............expr: up{job="sqlserver-exporter"}<1for: 1mlabels:namespace: amcprom_id: "3"severity: emergency

4.prometheus容器启动

docker run -d --name=prometheus --restart=always -p 9090:9090 \
-v /root/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /root/prometheus/first_rules.yml:/etc/prometheus/rules/first_rules.yml \
prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.enable-lifecycle
  • 挂载prometheus.yml到/etc/prometheus/prometheus.yml
  • 挂载first_rules.yml到/etc/prometheus/prometheus.yml
  • –config.file=/etc/prometheus/prometheus.yml指定配置文件(不指定热加载配置项有问题)
  • –web.enable-lifecycle热加载

5.注意点

容器部署的prometheus在执行热加载的时候没有生效,二进制部署就不会出现。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com