|   0 评论   |   0 浏览


  • vmalert executes a list of given alerting or recording rules against configured address
  • some command line interface tool

configure vmalert

./bin/vmalert -rule=alter.rules \
    // PromSQL compatible datasource
    // Alert manager url
    // Alert manager replica rul
    // remote write compatible storage to persist rules
    //  PromSQL compatible datasource to restore alerts state from
    // External label to be applied for each rule
    -external.label=cluster=east-1 \
    // Multiple external labels may be set
    -external.label=replica=a \
    // Default evaluation interval if not specified in rules group

if you run multiple vmalert services for the same datastore or Alert manager - do not forget to specify different external.label flags in order to define which vmalert generated rules or alerts.


groups: [- <rule_group>]

each group has following attributes:

# the name of the group. Must be unique within a file
name: <string>
# How often rules in group are evaluated
[interval: <duration> | default = global.evaluation_interval ]
# How many rules execute at once.
# Increasing concurrency may speed
# up round execution speed
[ concurrency: <integer> | default = 1]
# rules
rules :
    [ - <rule> ...]


there are two types of rules : recording and alerting

alerting rules

# the name of the alert,Must be a valid metric name
alert: <string>
# the metricQL expression to evaluate
expr: <string>
# Alerts are considered firing once they have been returned for this long
# Alerts witch have not ye fired for long enough are considered pending
[ for:<duration> | default = 0s ]
# Labels to add or overwrite for each alert
# Annotations to add to each alert

recording rules

# The name of the time series to output to. Must be a valid metric name.
record: <string>

# The MetricsQL expression to evaluate.
expr: <string>

# Labels to add or overwrite before storing the result.
  [ <labelname>: <labelvalue> ]