about prometheus alerting

本贴最后更新于 1392 天前,其中的信息可能已经时异事殊

1.Alerting with Prometheus is separated in to two parts

1-1Alerting rules

  • Alerting rules is a file that formatted by yml,it's define some exp in to the yaml file.
  • Alerting rules is in Prometheus servers send alerts to an alert manager and alert manager managed those alerts.

the rule document in there: the rules doc

1-2Alerting Manager

  • AlertingManager is a command line tool and the command line tool flags has those functions

    • configure immutable system parameters
    • configuration file defines inhibition rules
    • configuration notification routing
    • configuration notification receivers
    • router editor
  • Alerting notifications steps

    • Setup and configure the alert manager
    • Configure Prometheus to talk to the alert manager
    • Create alerting rules in Prometheus

1-2-1 Configs

  • config.file: specify which configuration file to load ./alertmanager --config.file=alertmanager.yml
    • the file written in the YAML format and defined by the scheme described below
      • <duration>: a duration matching the regular expression [0-9]+(ms|[smhdwy])
      • <labelname>: a string matching the regular expression [a-zA-Z_][a-zA-Z0-9_]*
      • <labelvalue>: a string of unicode characters
      • <filepath>: a valid path in the current working directory
      • <boolean>: a boolean that can take the values true or false
      • <string>: a regular string
      • <secret>: a regular string that is a secret, such as a password
      • <tmpl_string>: a string which is template-expanded before usage
      • <tmpl_secret>: a string which is template-expanded before usage that is a secret
      • <int>: an integer value

there is the simple file and some configs

1-2-2 Cores

  • Grouping

    • Grouping categorizes alerts of similar nature into a single notification.
  • Inhibition

    • Inhibition is a concept of suppressing notifications for certain alerts if certain other alerts are already firing
  • Silences

    • Silences are a straightforward way to simply mute alerts for a given time.
    • A silence is configured based on matchers, just like the routing tree.
    • Silences are configured in the web interface of the Alert manager.

1-2-3 Notification template Reference

1-2-3-1 Data structures

data

Name Type Notes
Receiver string The notification will be send to
Status string Defined as firing if at least one alert if firing.otherwise resolved
Alerts Alert List of all alert objects in this group
GroupLabels kv The labels these alerts were grouped by
CommonLabels kv The labels common to all of the alerts
CommonAnnotations kv set of common annotations to all of the alerts. Used for longer additional strings of information about the alert
ExternalURL string Backlink to the alert manager that send the notification

alert

Name Type Notes
Status string Defines whether or not the alert is resolved or currently firing
Labels kv A set of labels to be attached to the alert
Annotations kv A set of annotations for the alert
StartsAt time.Time The time the alert started firing
EndsAt time.Time Only set if the end time of an alert is know
GeneratorURL string A backlink which identifies the causing entity of this alert

kv

Name Args Returns Notes
SortedPairs - Pairs(list of key/value string pairs) Return s a sorted list of key/value pairs
Remove [] string kv Returns a copy of the key/value map without the given keys.
Names - []string Returns the names of the label names in the labelset
Values - []string Returns the list of values in the labelset

functions

Name Args Returns
title string strings.Title,capitalises first character of each word
toUpper string -
toLower string -
match pattern,string Regexp.MatchString.Match a string using Regexp
reReplaceAll pattern,replacement,text Regexp.ReplaceAllString Regexp substitution,unanchored
join sep string,s []string strings.join
safeHtml text string html/template.HTML
stringSlice ...string Returns the passed strings as a slice of strings
5 操作
someone61489 在 2021-01-13 11:51:45 更新了该帖
someone61489 在 2021-01-13 10:46:50 更新了该帖
someone61489 在 2021-01-13 10:46:01 更新了该帖
someone61489 在 2021-01-13 09:48:10 更新了该帖 someone61489 在 2021-01-13 09:44:32 更新了该帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...