配置promethues踩坑记录

promethues容器运行报错

报错信息

level=error ts=2021-03-02T09:42:35.130Z caller=main.go:293 msg=“Error loading config (–config.file=/etc/prometheus/prometheus.yml)” err=“parsing YAML file /etc/prometheus/prometheus.yml: yaml: unmarshal errors:\n line 5: field rules_files not found in type config.plain\n line 11: field targets not found in type config.AlertmanagerConfig”

prometheus.yml配置

global:
  scrape_interval:     60s
  evaluation_interval: 60s

rules_files:
  - /opt/prometheus/rules.yml
alerting:
    alertmanagers:
      - scheme: http
      - static_configs:
      - targets: ["localhost:9090"]

scrape_configs:
 - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
 - job_name: node
    static_configs:
      - targets: ['*.*.*.*:9100']
        labels:
          instance: yx01
      - targets: ['*.*.*.*:9100']
        labels:
          instance: yx02 
  • 第一处错误在第5行rules_files拼写错误,修改为rule_files
  • 第二处错误是格式错误,11行需要缩进
    在这里插入图片描述
    修改后
    配置promethues踩坑记录_第1张图片

AlertManger规则不显示

http://localhost:9090/alerts 不显示告警项
配置promethues踩坑记录_第2张图片

  • 使用绝对路径可能有问题,修改成相对路径

配置promethues踩坑记录_第3张图片
修改后
在这里插入图片描述

http://localhost:9093 alertmanager端接收不到告警
配置promethues踩坑记录_第4张图片

排查半天试了下将prometheus.yml中alertmanagers的地址localhost改为实际地址就可以接收到了
配置promethues踩坑记录_第5张图片
配置promethues踩坑记录_第6张图片

配置promethues踩坑记录_第7张图片
邮件也能接收
在这里插入图片描述

你可能感兴趣的:(运维,运维)