# 1.Alerting with Prometheus is separated in to two parts

• Alerting rules is a file that formatted by yml,it's define some exp in to the yaml file.

the rule document in there: the rules doc

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

• configure immutable system parameters
• configuration file defines inhibition rules
• router editor

• 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

• Inhibition

• 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-1 Data structures

data

NameTypeNotes
StatusstringDefined as firing if at least one alert if firing.otherwise resolved
GroupLabelskvThe labels these alerts were grouped by
CommonLabelskvThe labels common to all of the alerts

NameTypeNotes
StatusstringDefines whether or not the alert is resolved or currently firing
LabelskvA set of labels to be attached to the alert
AnnotationskvA set of annotations for the alert
StartsAttime.TimeThe time the alert started firing
EndsAttime.TimeOnly set if the end time of an alert is know

kv

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

functions

NameArgsReturns
titlestringstrings.Title,capitalises first character of each word
toUpperstring-
toLowerstring-
matchpattern,stringRegexp.MatchString.Match a string using Regexp
reReplaceAllpattern,replacement,textRegexp.ReplaceAllString Regexp substitution,unanchored
joinsep string,s []stringstrings.join
safeHtmltext stringhtml/template.HTML
stringSlice...stringReturns the passed strings as a slice of strings

Q.E.D.