【问题标题】:Alerts firing on Prometheus but not on Alertmanager在 Prometheus 上发出警报,但在 Alertmanager 上没有发出警报
【发布时间】:2020-10-14 11:12:01
【问题描述】:

我似乎不明白为什么 Alertmanager 没有收到来自 Prometheus 的警报。我希望能在这一挑战上得到迅速的帮助。我对使用 Prometheus 和 Alertmanager 还是很陌生。我正在使用 MsTeams 的 webhook 从 alertmanager 推送通知。

Alertmanager.yml

global:
  resolve_timeout: 5m


route:
  group_by: ['critical','severity']
  group_wait: 10s
  group_interval: 10s
  repeat_interval: 1h
  receiver: 'alert_channel'


receivers:
- name: 'alert_channel'
  webhook_configs:
  - url: 'http://localhost:2000/alert_channel'
    send_resolved: true

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).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - localhost:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
  - alert_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: 'kafka'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'

    static_configs:
    - targets: ['localhost:8080']
      labels:
        service: 'Kafka'

alertmanager.service

[Unit]
Description=Prometheus Alert Manager
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=alertmanager
Group=alertmanager
ExecStart=/usr/local/bin/alertmanager \
  --config.file=/etc/alertmanager/alertmanager.yml \
  --storage.path=/data/alertmanager \
  --web.listen-address=127.0.0.1:9093

Restart=always

[Install]
WantedBy=multi-user.target

alert_rules

groups:
- name: alert_rules
  rules:
  - alert: ServiceDown
    expr: up == 0
    for: 1m
    labels:
      severity: "critical"
    annotations:
      summary: "Service {{ $labels.service }} down!"
      description: "{{ $labels.service }} of job {{ $labels.job }} has been down for more than 1 minute."


  - alert: HostOutOfMemory
    expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 25
    for: 5m
    labels:
      severity: warning
    annotations:
      summary: "Host out of memory (instance {{ $labels.instance }})"
      description: "Node memory is filling up (< 25% left)\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"


  - alert: HostOutOfDiskSpace
    expr: (node_filesystem_avail_bytes{mountpoint="/"}  * 100) / node_filesystem_size_bytes{mountpoint="/"} < 40
    for: 1s
    labels:
      severity: warning
    annotations:
      summary: "Host out of disk space (instance {{ $labels.instance }})"
      description: "Disk is almost full (< 40% left)\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"

普罗米修斯警报

但我在 alertmanager 上看不到这些警报

我现在没有想法。请我需要帮助。自上周以来我一直在做这个。

【问题讨论】:

  • 考虑将一些规则(正在触发)添加到您的问题中
  • @trallnag 感谢您对此的关注。我已经附上了普罗米修斯的规则截图和下面的 .yml。

标签: monitoring prometheus microsoft-teams prometheus-alertmanager


【解决方案1】:

您的 Alertmanager 配置有误。 group_by 需要 标签名称 的集合,而我所看到的 critical 是标签值,而不是名称。所以只需删除 critical 就可以了。

也可以看看这篇博文,很有帮助的https://www.robustperception.io/whats-the-difference-between-group_interval-group_wait-and-repeat_interval


编辑 1

如果您希望接收器 alert_channel 仅接收严重性为 critical 的警报,您必须创建一个路由并具有 match 属性。

类似的东西:

route:
  group_by: ['...']  # good if very low volum
  group_wait: 15s
  group_interval: 5m
  repeat_interval: 1h
  routes:
    - match:
        - severity: critical
      receiver: alert_channel

编辑 2

如果这不起作用,试试这个:

route:
  group_by: ['...']
  group_wait: 15s
  group_interval: 5m
  repeat_interval: 1h
  receiver: alert_channel

这应该可行。检查你的 Prometheus 日志,看看你是否在那里找到提示

【讨论】:

  • 我尝试了您的建议,但仍然没有在 alertmanager 上看到警报。只显示“未找到警报组”。
  • 检查 Prometheus / Alertmanager 上的日志并将配置更改为编辑 2 中的配置
  • 它对我有用,就像在编辑 2 中一样,唯一的区别是我在单引号接收器之间有接收器名称:'alert_channel'
猜你喜欢
  • 2022-07-13
  • 1970-01-01
  • 2016-03-15
  • 2020-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多