簡體   English   中英

關於Prometheus中Pod內存利用率的自定義警報

[英]Custom alert for pod memory utilisation in Prometheus

我在Prometheus中為pod內存使用創建了警報規則。 警報在我的閑置頻道中完美顯示,但是其中沒有Pod的名稱,因此很難理解哪個Pod出現了問題。

它僅顯示[FIRING:35] (POD_MEMORY_HIGH_UTILIZATION default/k8s warning) 但是,當我查看Prometheus UI中的“警報”部分時,可以看到帶有其pod名稱的觸發規則。 有人可以幫忙嗎?

我的警報通知模板如下:

alertname: TargetDown
      alertname: POD_CPU_HIGH_UTILIZATION
      alertname:  POD_MEMORY_HIGH_UTILIZATION
receivers:

    - name: 'slack-notifications'

      slack_configs:

      - channel: '#devops'
        title: '{{ .CommonAnnotations.summary }}'
        text: '{{ .CommonAnnotations.description }}'

        send_resolved: true

我在警報通知模板中添加了選項title: '{{ .CommonAnnotations.summary }}' text: '{{ .CommonAnnotations.description }}' ,現在它顯示了說明。 我的描述是description: pod {{$labels.pod}} is using high memory 但只有顯示is using high memory 未指定廣告連播名稱

本文所述 ,您應該檢查警報規則並在必要時進行更新。 看一個例子:

ALERT ElasticacheCPUUtilisation
  IF aws_elasticache_cpuutilization_average > 80
  FOR 10m
  LABELS { severity = "warning" }
    ANNOTATIONS {
    summary = "ElastiCache CPU Utilisation Alert",
    description = "Elasticache CPU Usage has breach the threshold set (80%) on cluster id {{ $labels.cache_cluster_id }}, now at {{ $value }}%",
    runbook = "https://mywiki.com/ElasticacheCPUUtilisation",
  }

要為您的Prometheus GUI提供外部URL,請將CLI參數應用於Prometheus服務器並重新啟動它:

-web.external-url=http://externally-available-url:9090/

之后,您可以將這些值放入Alertmanager配置中。 看一個例子:

receivers:
  - name: 'iw-team-slack'
    slack_configs:
    - channel: alert-events
      send_resolved: true
      api_url: https://hooks.slack.com/services/<your_token>
      title: '[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] Monitoring Event Notification'
      text: >-
        {{ range .Alerts }}
           *Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
          *Description:* {{ .Annotations.description }}
          *Graph:* <{{ .GeneratorURL }}|:chart_with_upwards_trend:> *Runbook:* <{{ .Annotations.runbook }}|:spiral_note_pad:>
          *Details:*
          {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
          {{ end }}
        {{ end }}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM