2021-04-07 12:39:16 +02:00
---
2021-05-26 11:32:16 +02:00
sort: 4
2021-04-07 12:39:16 +02:00
---
# vmalert
2020-04-29 16:42:01 +02:00
2021-06-14 10:37:26 +02:00
`vmalert` executes a list of the given [alerting ](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/ )
2020-06-02 18:12:41 +02:00
or [recording ](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/ )
2022-08-08 09:45:21 +02:00
rules against configured `-datasource.url` compatible with Prometheus HTTP API. For sending alerting notifications
2022-03-13 14:56:01 +01:00
vmalert relies on [Alertmanager ](https://github.com/prometheus/alertmanager ) configured via `-notifier.url` flag.
2021-12-01 16:33:06 +01:00
Recording rules results are persisted via [remote write ](https://prometheus.io/docs/prometheus/latest/storage/#remote-storage-integrations )
protocol and require `-remoteWrite.url` to be configured.
Vmalert is heavily inspired by [Prometheus ](https://prometheus.io/docs/alerting/latest/overview/ )
2021-06-14 10:37:26 +02:00
implementation and aims to be compatible with its syntax.
2020-04-29 16:42:01 +02:00
2021-04-07 12:39:16 +02:00
## Features
2022-03-22 12:40:55 +01:00
2020-04-29 16:42:01 +02:00
* Integration with [VictoriaMetrics ](https://github.com/VictoriaMetrics/VictoriaMetrics ) TSDB;
2021-04-20 19:16:17 +02:00
* VictoriaMetrics [MetricsQL ](https://docs.victoriametrics.com/MetricsQL.html )
2022-05-14 18:56:31 +02:00
support and expressions validation;
2020-04-29 16:42:01 +02:00
* Prometheus [alerting rules definition format ](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#defining-alerting-rules )
2022-05-14 18:56:31 +02:00
support;
2022-02-22 19:07:04 +01:00
* Integration with [Alertmanager ](https://github.com/prometheus/alertmanager ) starting from [Alertmanager v0.16.0-aplha ](https://github.com/prometheus/alertmanager/releases/tag/v0.16.0-alpha.0 );
2021-04-20 19:16:17 +02:00
* Keeps the alerts [state on restarts ](#alerts-state-on-restarts );
2021-06-09 11:27:31 +02:00
* Graphite datasource can be used for alerting and recording rules. See [these docs ](#graphite );
* Recording and Alerting rules backfilling (aka `replay` ). See [these docs ](#rules-backfilling );
2022-08-08 09:45:21 +02:00
* Lightweight and without extra dependencies.
2022-05-14 11:38:44 +02:00
* Supports [reusable templates ](#reusable-templates ) for annotations.
2020-04-29 16:42:01 +02:00
2021-04-07 12:39:16 +02:00
## Limitations
2022-03-22 12:40:55 +01:00
2021-12-01 16:33:06 +01:00
* `vmalert` execute queries against remote datasource which has reliability risks because of the network.
2022-05-14 18:56:31 +02:00
It is recommended to configure alerts thresholds and rules expressions with the understanding that network
requests may fail;
2021-11-05 19:44:02 +01:00
* by default, rules execution is sequential within one group, but persistence of execution results to remote
2022-05-14 18:56:31 +02:00
storage is asynchronous. Hence, user shouldn't rely on chaining of recording rules when result of previous
recording rule is reused in the next one;
2020-06-10 18:37:43 +02:00
2021-04-07 12:39:16 +02:00
## QuickStart
2020-04-29 16:42:01 +02:00
To build `vmalert` from sources:
2022-03-22 12:40:55 +01:00
2022-06-19 21:57:53 +02:00
```console
2020-04-29 16:42:01 +02:00
git clone https://github.com/VictoriaMetrics/VictoriaMetrics
cd VictoriaMetrics
make vmalert
```
2022-03-22 12:40:55 +01:00
2021-12-01 16:33:06 +01:00
The build binary will be placed in `VictoriaMetrics/bin` folder.
2020-04-29 16:42:01 +02:00
To start using `vmalert` you will need the following things:
2022-03-22 12:40:55 +01:00
2020-06-02 18:12:41 +02:00
* list of rules - PromQL/MetricsQL expressions to execute;
2022-08-08 09:45:21 +02:00
* datasource address - reachable endpoint with [Prometheus HTTP API ](https://prometheus.io/docs/prometheus/latest/querying/api/#http-api ) support for running queries against;
2021-11-30 00:22:37 +01:00
* notifier address [optional] - reachable [Alert Manager ](https://github.com/prometheus/alertmanager ) instance for processing,
2022-05-14 18:56:31 +02:00
aggregating alerts, and sending notifications. Please note, notifier address also supports Consul and DNS Service Discovery via
[config file ](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmalert/notifier/config.go ).
2021-06-14 10:37:26 +02:00
* remote write address [optional] - [remote write ](https://prometheus.io/docs/prometheus/latest/storage/#remote-storage-integrations )
2022-06-16 13:30:28 +02:00
compatible storage to persist rules and alerts state info. To persist results to multiple destinations use vmagent
configured with multiple remote writes as a proxy;
2021-11-16 23:54:06 +01:00
* remote read address [optional] - MetricsQL compatible datasource to restore alerts state from.
2020-04-29 16:42:01 +02:00
Then configure `vmalert` accordingly:
2022-03-22 12:40:55 +01:00
2022-06-19 21:57:53 +02:00
```console
2021-06-14 10:37:26 +02:00
./bin/vmalert -rule=alert.rules \ # Path to the file with rules configuration. Supports wildcard
2022-08-08 09:45:21 +02:00
-datasource.url=http://localhost:8428 \ # Prometheus HTTP API compatible datasource
2021-11-30 00:22:37 +01:00
-notifier.url=http://localhost:9093 \ # AlertManager URL (required if alerting rules are used)
2020-07-30 20:56:48 +02:00
-notifier.url=http://127.0.0.1:9093 \ # AlertManager replica URL
2021-11-30 00:22:37 +01:00
-remoteWrite.url=http://localhost:8428 \ # Remote write compatible storage to persist rules and alerts state info (required if recording rules are used)
2022-08-08 09:45:21 +02:00
-remoteRead.url=http://localhost:8428 \ # Prometheus HTTP API compatible datasource to restore alerts state from
2020-07-30 20:56:48 +02:00
-external.label=cluster=east-1 \ # External label to be applied for each rule
2021-03-25 14:29:04 +01:00
-external.label=replica=a # Multiple external labels may be set
2020-04-29 16:42:01 +02:00
```
2022-05-30 08:16:07 +02:00
Note there's a separate `remoteWrite.url` to allow writing results of
2021-11-16 23:54:06 +01:00
alerting/recording rules into a different storage than the initial data that's
2021-12-01 16:33:06 +01:00
queried. This allows using `vmalert` to aggregate data from a short-term,
2021-11-16 23:54:06 +01:00
high-frequency, high-cardinality storage into a long-term storage with
decreased cardinality and a bigger interval between samples.
2021-11-05 19:44:02 +01:00
See the full list of configuration flags in [configuration ](#configuration ) section.
2021-06-14 10:37:26 +02:00
2020-07-30 20:56:48 +02:00
If you run multiple `vmalert` services for the same datastore or AlertManager - do not forget
2021-03-09 21:49:50 +01:00
to specify different `external.label` flags in order to define which `vmalert` generated rules or alerts.
2020-07-30 20:56:48 +02:00
2021-03-09 21:49:50 +01:00
Configuration for [recording ](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/ )
and [alerting ](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/ ) rules is very
similar to Prometheus rules and configured using YAML. Configuration examples may be found
2020-06-10 18:37:43 +02:00
in [testdata ](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmalert/config/testdata ) folder.
2021-06-14 10:37:26 +02:00
Every `rule` belongs to a `group` and every configuration file may contain arbitrary number of groups:
2022-03-22 12:40:55 +01:00
2020-06-10 18:37:43 +02:00
```yaml
groups:
[ - < rule_group > ]
```
2020-06-02 18:12:41 +02:00
2021-04-07 12:39:16 +02:00
### Groups
2020-04-29 16:42:01 +02:00
2021-06-14 10:37:26 +02:00
Each group has the following attributes:
2022-03-22 12:40:55 +01:00
2020-06-10 18:37:43 +02:00
```yaml
# The name of the group. Must be unique within a file.
name: < string >
2020-04-29 16:42:01 +02:00
2020-06-10 18:37:43 +02:00
# How often rules in the group are evaluated.
2021-06-14 10:37:26 +02:00
[ interval: < duration > | default = -evaluationInterval flag ]
2020-06-10 18:37:43 +02:00
2022-06-09 08:21:30 +02:00
# Limit the number of alerts an alerting rule and series a recording
# rule can produce. 0 is no limit.
[ limit: < int > | default = 0 ]
2021-06-14 10:37:26 +02:00
# How many rules execute at once within a group. Increasing concurrency may speed
2021-03-09 21:49:50 +01:00
# up round execution speed.
2020-06-10 18:37:43 +02:00
[ concurrency: < integer > | default = 1 ]
2021-02-03 20:12:14 +01:00
# Optional type for expressions inside the rules. Supported values: "graphite" and "prometheus".
2021-11-05 18:49:32 +01:00
# By default "prometheus" type is used.
2021-02-03 20:12:14 +01:00
[ type: < string > ]
2021-12-02 23:08:42 +01:00
# Optional list of HTTP URL parameters
# applied for all rules requests within a group
# For example:
# params:
# nocache: ["1"] # disable caching for vmselect
# denyPartialResponse: ["true"] # fail if one or more vmstorage nodes returned an error
# extra_label: ["env=dev"] # apply additional label filter "env=dev" for all requests
# see more details at https://docs.victoriametrics.com#prometheus-querying-api-enhancements
params:
[ < string > : [< string > , ...]]
2022-07-21 15:59:55 +02:00
# Optional list of HTTP headers in form `header-name: value`
# applied for all rules requests within a group
# For example:
# headers:
# - "CustomHeader: foo"
# - "CustomHeader2: bar"
# Headers set via this param have priority over headers set via `-datasource.headers` flag.
headers:
[ < string > , ...]
2021-08-31 13:52:34 +02:00
# Optional list of labels added to every rule within a group.
# It has priority over the external labels.
# Labels are commonly used for adding environment
# or tenant-specific tag.
labels:
[ < labelname > : < labelvalue > ... ]
2020-06-10 18:37:43 +02:00
rules:
[ - < rule > ... ]
```
2021-04-07 12:39:16 +02:00
### Rules
2020-06-10 18:37:43 +02:00
2021-06-14 10:37:26 +02:00
Every rule contains `expr` field for [PromQL ](https://prometheus.io/docs/prometheus/latest/querying/basics/ )
2022-08-08 09:45:21 +02:00
or [MetricsQL ](https://docs.victoriametrics.com/MetricsQL.html ) expression. `vmalert` will execute the configured
2021-06-14 10:37:26 +02:00
expression and then act according to the Rule type.
2020-06-10 18:37:43 +02:00
There are two types of Rules:
2022-03-22 12:40:55 +01:00
2021-03-09 21:49:50 +01:00
* [alerting ](https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/ ) -
2022-05-14 18:56:31 +02:00
Alerting rules allow defining alert conditions via `expr` field and to send notifications to
[Alertmanager ](https://github.com/prometheus/alertmanager ) if execution result is not empty.
2021-03-09 21:49:50 +01:00
* [recording ](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/ ) -
2022-05-14 18:56:31 +02:00
Recording rules allow defining `expr` which result will be then backfilled to configured
`-remoteWrite.url` . Recording rules are used to precompute frequently needed or computationally
expensive expressions and save their result as a new set of time series.
2020-06-10 18:37:43 +02:00
2021-12-01 16:33:06 +01:00
`vmalert` forbids defining duplicates - rules with the same combination of name, expression, and labels
2021-03-09 21:49:50 +01:00
within one group.
2020-06-18 22:54:44 +02:00
2021-04-07 12:39:16 +02:00
#### Alerting rules
2020-06-10 18:37:43 +02:00
2021-06-14 10:37:26 +02:00
The syntax for alerting rule is the following:
2022-03-22 12:40:55 +01:00
2020-06-10 18:37:43 +02:00
```yaml
# The name of the alert. Must be a valid metric name.
alert: < string >
2021-02-01 14:26:33 +01:00
# The expression to evaluate. The expression language depends on the type value.
2022-08-08 09:45:21 +02:00
# By default, PromQL/MetricsQL expression is used. If group.type="graphite", then the expression
2021-02-01 14:26:33 +01:00
# must contain valid Graphite expression.
2020-06-10 18:37:43 +02:00
expr: < string >
# Alerts are considered firing once they have been returned for this long.
2021-12-01 16:33:06 +01:00
# Alerts which have not yet been fired for long enough are considered pending.
2021-06-14 10:37:26 +02:00
# If param is omitted or set to 0 then alerts will be immediately considered
# as firing once they return.
2020-06-10 18:37:43 +02:00
[ for: < duration > | default = 0s ]
2020-06-02 18:12:41 +02:00
2022-09-13 15:25:43 +02:00
# Whether to print debug information into logs.
# Information includes alerts state changes and requests sent to the datasource.
# Please note, that if rule's query params contain sensitive
# information - it will be printed to logs.
# Is applicable to alerting rules only.
[ debug: < bool > | default = false ]
2020-06-10 18:37:43 +02:00
# Labels to add or overwrite for each alert.
labels:
[ < labelname > : < tmpl_string > ]
# Annotations to add to each alert.
annotations:
[ < labelname > : < tmpl_string > ]
2021-03-09 21:49:50 +01:00
```
2020-06-10 18:37:43 +02:00
2022-08-16 08:08:27 +02:00
#### Templating
It is allowed to use [Go templating ](https://golang.org/pkg/text/template/ ) in annotations to format data, iterate over
or execute expressions.
The following variables are available in templating:
2022-08-22 13:49:17 +02:00
| Variable | Description | Example |
|------------------------------------|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $value or .Value | The current alert's value. Avoid using value in labels, it may cause unexpected issues. | {% raw %}Number of connections is {{ $value }}{% endraw %} |
| $activeAt or .ActiveAt | The moment of [time ](https://pkg.go.dev/time ) when alert became active (`pending` or `firing` ). | {% raw %}http://vm-grafana.com/panelId=xx?from={{($activeAt.Add (parseDurationTime \"1h\")).Unix}}& to={{($activeAt.Add (parseDurationTime \"-1h\")).Unix}}{% endraw %} |
| $labels or .Labels | The list of labels of the current alert. Use as ".Labels.< label_name > ". | {% raw %}Too high number of connections for {{ .Labels.instance }}{% endraw %} |
| $alertID or .AlertID | The current alert's ID generated by vmalert. | {% raw %}Link: vmalert/alert?group_id={{.GroupID}}& alert_id={{.AlertID}}{% endraw %} |
| $groupID or .GroupID | The current alert's group ID generated by vmalert. | {% raw %}Link: vmalert/alert?group_id={{.GroupID}}& alert_id={{.AlertID}}{% endraw %} |
| $expr or .Expr | Alert's expression. Can be used for generating links to Grafana or other systems. | {% raw %}/api/v1/query?query={{ $expr| quotesEscape| queryEscape }}{% endraw %} |
| $externalLabels or .ExternalLabels | List of labels configured via `-external.label` command-line flag. | {% raw %}Issues with {{ $labels.instance }} (datacenter-{{ $externalLabels.dc }}){% endraw %} |
| $externalURL or .ExternalURL | URL configured via `-external.url` command-line flag. Used for cases when vmalert is hidden behind proxy. | {% raw %}Visit {{ $externalURL }} for more details{% endraw %} |
2022-08-16 08:08:27 +02:00
2021-04-10 14:46:08 +02:00
Additionally, `vmalert` provides some extra templating functions
2022-08-20 07:54:01 +02:00
listed [here ](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmalert/templates/template.go )
2022-08-16 08:08:27 +02:00
and [reusable templates ](#reusable-templates ).
2022-05-14 11:38:44 +02:00
#### Reusable templates
2022-05-14 18:56:31 +02:00
Like in Alertmanager you can define [reusable templates ](https://prometheus.io/docs/prometheus/latest/configuration/template_examples/#defining-reusable-templates )
to share same templates across annotations. Just define the templates in a file and
set the path via `-rule.templates` flag.
2022-05-14 19:29:09 +02:00
For example, template `grafana.filter` can be defined as following:
2022-05-14 11:38:44 +02:00
2022-05-16 09:27:19 +02:00
{% raw %}
2022-05-14 11:38:44 +02:00
```
{{ define "grafana.filter" -}}
{{- $labels := .arg0 -}}
{{- range $name, $label := . -}}
{{- if (ne $name "arg0") -}}
{{- ( or (index $labels $label) "All" ) | printf "& var-%s=%s" $label -}}
{{- end -}}
{{- end -}}
{{- end -}}
```
2022-05-16 09:27:19 +02:00
{% endraw %}
2022-05-14 11:38:44 +02:00
2022-05-14 19:29:09 +02:00
And then used in annotations:
2022-05-14 11:38:44 +02:00
2022-05-16 09:27:19 +02:00
{% raw %}
2022-05-14 11:38:44 +02:00
```yaml
groups:
- name: AlertGroupName
rules:
- alert: AlertName
expr: any_metric > 100
for: 30s
labels:
alertname: 'Any metric is too high'
severity: 'warning'
annotations:
dashboard: '{{ $externalURL }}/d/dashboard?orgId=1{{ template "grafana.filter" (args .CommonLabels "account_id" "any_label") }}'
```
2022-05-16 09:27:19 +02:00
{% endraw %}
2022-05-14 11:38:44 +02:00
2022-05-14 18:56:31 +02:00
The `-rule.templates` flag supports wildcards so multiple files with templates can be loaded.
The content of `-rule.templates` can be also [hot reloaded ](#hot-config-reload ).
2022-05-14 11:38:44 +02:00
2021-04-10 14:46:08 +02:00
2021-04-07 12:39:16 +02:00
#### Recording rules
2020-06-10 18:37:43 +02:00
The syntax for recording rules is following:
2022-03-22 12:40:55 +01:00
2020-06-10 18:37:43 +02:00
```yaml
# The name of the time series to output to. Must be a valid metric name.
record: < string >
2021-02-01 14:26:33 +01:00
# The expression to evaluate. The expression language depends on the type value.
2022-08-08 09:45:21 +02:00
# By default, MetricsQL expression is used. If group.type="graphite", then the expression
2021-02-01 14:26:33 +01:00
# must contain valid Graphite expression.
2020-06-10 18:37:43 +02:00
expr: < string >
# Labels to add or overwrite before storing the result.
labels:
[ < labelname > : < labelvalue > ]
```
2021-06-14 10:37:26 +02:00
For recording rules to work `-remoteWrite.url` must be specified.
2020-06-10 18:37:43 +02:00
2021-04-07 12:39:16 +02:00
### Alerts state on restarts
2020-10-13 17:34:25 +02:00
2021-06-14 10:37:26 +02:00
`vmalert` has no local storage, so alerts state is stored in the process memory. Hence, after restart of `vmalert`
2020-10-13 17:34:25 +02:00
the process alerts state will be lost. To avoid this situation, `vmalert` should be configured via the following flags:
2022-03-22 12:40:55 +01:00
2021-04-20 10:42:17 +02:00
* `-remoteWrite.url` - URL to VictoriaMetrics (Single) or vminsert (Cluster). `vmalert` will persist alerts state
2022-05-14 18:56:31 +02:00
into the configured address in the form of time series named `ALERTS` and `ALERTS_FOR_STATE` via remote-write protocol.
These are regular time series and maybe queried from VM just as any other time series.
The state is stored to the configured address on every rule evaluation.
2021-04-20 10:42:17 +02:00
* `-remoteRead.url` - URL to VictoriaMetrics (Single) or vmselect (Cluster). `vmalert` will try to restore alerts state
2022-05-14 18:56:31 +02:00
from configured address by querying time series with name `ALERTS_FOR_STATE` .
2020-10-13 17:34:25 +02:00
2021-12-01 16:33:06 +01:00
Both flags are required for proper state restoration. Restore process may fail if time series are missing
2021-08-16 13:20:57 +02:00
in configured `-remoteRead.url` , weren't updated in the last `1h` (controlled by `-remoteRead.lookback` )
2021-06-14 10:37:26 +02:00
or received state doesn't match current `vmalert` rules configuration.
2020-10-13 17:34:25 +02:00
2021-05-18 15:22:08 +02:00
### Multitenancy
2021-12-01 16:33:06 +01:00
There are the following approaches exist for alerting and recording rules across
2021-06-14 10:37:26 +02:00
[multiple tenants ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multitenancy ):
2021-05-18 15:22:08 +02:00
2021-08-16 13:20:57 +02:00
* To run a separate `vmalert` instance per each tenant.
The corresponding tenant must be specified in `-datasource.url` command-line flag
according to [these docs ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format ).
2021-06-14 10:37:26 +02:00
For example, `/path/to/vmalert -datasource.url=http://vmselect:8481/select/123/prometheus`
2021-08-16 13:20:57 +02:00
would run alerts against `AccountID=123` . For recording rules the `-remoteWrite.url` command-line
flag must contain the url for the specific tenant as well.
For example, `-remoteWrite.url=http://vminsert:8480/insert/123/prometheus` would write recording
2021-06-14 10:37:26 +02:00
rules to `AccountID=123` .
2021-05-18 15:22:08 +02:00
2021-08-16 13:20:57 +02:00
* To specify `tenant` parameter per each alerting and recording group if
2022-01-05 15:30:13 +01:00
[enterprise version of vmalert ](https://victoriametrics.com/products/enterprise/ ) is used
2021-06-14 10:37:26 +02:00
with `-clusterMode` command-line flag. For example:
2021-05-18 15:22:08 +02:00
```yaml
groups:
- name: rules_for_tenant_123
tenant: "123"
rules:
# Rules for accountID=123
- name: rules_for_tenant_456:789
tenant: "456:789"
rules:
# Rules for accountID=456, projectID=789
```
2021-08-16 13:20:57 +02:00
If `-clusterMode` is enabled, then `-datasource.url` , `-remoteRead.url` and `-remoteWrite.url` must
contain only the hostname without tenant id. For example: `-datasource.url=http://vmselect:8481` .
2021-09-10 16:57:14 +02:00
`vmalert` automatically adds the specified tenant to urls per each recording rule in this case.
2021-05-18 15:22:08 +02:00
2021-11-05 19:04:09 +01:00
If `-clusterMode` is enabled and the `tenant` in a particular group is missing, then the tenant value
is obtained from `-defaultTenant.prometheus` or `-defaultTenant.graphite` depending on the `type` of the group.
2021-08-16 13:20:57 +02:00
The enterprise version of vmalert is available in `vmutils-*-enterprise.tar.gz` files
at [release page ](https://github.com/VictoriaMetrics/VictoriaMetrics/releases ) and in `*-enterprise`
2021-06-14 10:37:26 +02:00
tags at [Docker Hub ](https://hub.docker.com/r/victoriametrics/vmalert/tags ).
2021-05-18 15:22:08 +02:00
2021-12-01 16:33:06 +01:00
### Topology examples
2022-03-22 12:40:55 +01:00
The following sections are showing how `vmalert` may be used and configured
for different scenarios.
Please note, not all flags in examples are required:
2021-12-01 16:33:06 +01:00
* `-remoteWrite.url` and `-remoteRead.url` are optional and are needed only if
2022-05-14 18:56:31 +02:00
you have recording rules or want to store [alerts state ](#alerts-state-on-restarts ) on `vmalert` restarts;
2021-12-01 16:33:06 +01:00
* `-notifier.url` is optional and is needed only if you have alerting rules.
#### Single-node VictoriaMetrics
2021-12-02 09:27:46 +01:00
The simplest configuration where one single-node VM server is used for
rules execution, storing recording rules results and alerts state.
2021-12-01 16:33:06 +01:00
`vmalert` configuration flags:
2022-03-22 12:40:55 +01:00
2021-12-01 16:33:06 +01:00
```
./bin/vmalert -rule=rules.yml \ # Path to the file with rules configuration. Supports wildcard
-datasource.url=http://victoriametrics:8428 \ # VM-single addr for executing rules expressions
-remoteWrite.url=http://victoriametrics:8428 \ # VM-single addr to persist alerts state and recording rules results
-remoteRead.url=http://victoriametrics:8428 \ # VM-single addr for restoring alerts state after restart
-notifier.url=http://alertmanager:9093 # AlertManager addr to send alerts when they trigger
```
2021-12-02 09:27:46 +01:00
< img alt = "vmalert single" width = "500" src = "vmalert_single.png" >
2021-12-01 16:33:06 +01:00
#### Cluster VictoriaMetrics
2021-12-02 09:27:46 +01:00
In [cluster mode ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html )
VictoriaMetrics has separate components for writing and reading path:
`vminsert` and `vmselect` components respectively. `vmselect` is used for executing rules expressions
and `vminsert` is used to persist recording rules results and alerts state.
2022-03-22 12:40:55 +01:00
Cluster mode could have multiple `vminsert` and `vmselect` components.
2021-12-01 16:33:06 +01:00
`vmalert` configuration flags:
2022-03-22 12:40:55 +01:00
2021-12-01 16:33:06 +01:00
```
./bin/vmalert -rule=rules.yml \ # Path to the file with rules configuration. Supports wildcard
-datasource.url=http://vmselect:8481/select/0/prometheus # vmselect addr for executing rules expressions
2022-03-05 21:35:10 +01:00
-remoteWrite.url=http://vminsert:8480/insert/0/prometheus # vminsert addr to persist alerts state and recording rules results
2021-12-01 16:33:06 +01:00
-remoteRead.url=http://vmselect:8481/select/0/prometheus # vmselect addr for restoring alerts state after restart
-notifier.url=http://alertmanager:9093 # AlertManager addr to send alerts when they trigger
```
2021-12-02 09:27:46 +01:00
< img alt = "vmalert cluster" src = "vmalert_cluster.png" >
In case when you want to spread the load on these components - add balancers before them and configure
2021-12-01 16:33:06 +01:00
`vmalert` with balancer's addresses. Please, see more about VM's cluster architecture
[here ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#architecture-overview ).
2021-12-02 09:27:46 +01:00
#### HA vmalert
2021-12-01 16:33:06 +01:00
2021-12-02 09:27:46 +01:00
For HA user can run multiple identically configured `vmalert` instances.
It means all of them will execute the same rules, write state and results to
the same destinations, and send alert notifications to multiple configured
Alertmanagers.
2021-12-01 16:33:06 +01:00
`vmalert` configuration flags:
2022-03-22 12:40:55 +01:00
2021-12-01 16:33:06 +01:00
```
./bin/vmalert -rule=rules.yml \ # Path to the file with rules configuration. Supports wildcard
-datasource.url=http://victoriametrics:8428 \ # VM-single addr for executing rules expressions
-remoteWrite.url=http://victoriametrics:8428 \ # VM-single addr to persist alerts state and recording rules results
-remoteRead.url=http://victoriametrics:8428 \ # VM-single addr for restoring alerts state after restart
-notifier.url=http://alertmanager1:9093 \ # Multiple AlertManager addresses to send alerts when they trigger
-notifier.url=http://alertmanagerN:9093 # The same alert will be sent to all configured notifiers
```
2021-12-02 09:27:46 +01:00
< img alt = "vmalert ha" width = "800px" src = "vmalert_ha.png" >
2021-12-01 16:33:06 +01:00
To avoid recording rules results and alerts state duplication in VictoriaMetrics server
don't forget to configure [deduplication ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#deduplication ).
2022-05-17 14:14:18 +02:00
The recommended value for `-dedup.minScrapeInterval` must be greater or equal to vmalert's `evaluation_interval` .
2022-07-07 00:13:05 +02:00
If you observe inconsistent or "jumping" values in series produced by vmalert, try disabling `-datasource.queryTimeAlignment`
command line flag. Because of alignment, two or more vmalert HA pairs will produce results with the same timestamps.
But due of backfilling (data delivered to the datasource with some delay) values of such results may differ,
which would affect deduplication logic and result into "jumping" datapoints.
2021-12-01 16:33:06 +01:00
Alertmanager will automatically deduplicate alerts with identical labels, so ensure that
all `vmalert` s are having the same config.
Don't forget to configure [cluster mode ](https://prometheus.io/docs/alerting/latest/alertmanager/ )
for Alertmanagers for better reliability.
2022-03-22 12:40:55 +01:00
This example uses single-node VM server for the sake of simplicity.
Check how to replace it with [cluster VictoriaMetrics ](#cluster-victoriametrics ) if needed.
2021-12-02 09:27:46 +01:00
2021-12-01 16:33:06 +01:00
#### Downsampling and aggregation via vmalert
2022-06-22 08:53:54 +02:00
`vmalert` can't modify existing data. But it can run arbitrary PromQL/MetricsQL queries
via [recording rules ](#recording-rules ) and backfill results to the configured `-remoteWrite.url` .
This ability allows to aggregate data. For example, the following rule will calculate the average value for
metric `http_requests` on the `5m` interval:
```yaml
- record: http_requests:avg5m
expr: avg_over_time(http_requests[5m])
```
Every time this rule will be evaluated, `vmalert` will backfill its results as a new time series `http_requests:avg5m`
to the configured `-remoteWrite.url` .
`vmalert` executes rules with specified interval (configured via flag `-evaluationInterval`
or as [group's ](#groups ) `interval` param). The interval helps to control "resolution" of the produced series.
This ability allows to downsample data. For example, the following config will execute the rule only once every `5m` :
```yaml
groups:
- name: my_group
interval: 5m
rules:
- record: http_requests:avg5m
expr: avg_over_time(http_requests[5m])
```
Ability of `vmalert` to be configured with different `datasource.url` and `remoteWrite.url` allows
reading data from one data source and backfilling results to another. This helps to build a system
for aggregating and downsampling the data.
2022-02-04 10:56:52 +01:00
The following example shows how to build a topology where `vmalert` will process data from one cluster
2021-12-02 09:27:46 +01:00
and write results into another. Such clusters may be called as "hot" (low retention,
high-speed disks, used for operative monitoring) and "cold" (long term retention,
slower/cheaper disks, low resolution data). With help of `vmalert` , user can setup
recording rules to process raw data from "hot" cluster (by applying additional transformations
or reducing resolution) and push results to "cold" cluster.
2021-12-01 16:33:06 +01:00
`vmalert` configuration flags:
2022-03-22 12:40:55 +01:00
2021-12-01 16:33:06 +01:00
```
./bin/vmalert -rule=downsampling-rules.yml \ # Path to the file with rules configuration. Supports wildcard
-datasource.url=http://raw-cluster-vmselect:8481/select/0/prometheus # vmselect addr for executing recordi ng rules expressions
2022-03-05 21:35:10 +01:00
-remoteWrite.url=http://aggregated-cluster-vminsert:8480/insert/0/prometheus # vminsert addr to persist recording rules results
2021-12-01 16:33:06 +01:00
```
2021-12-02 09:27:46 +01:00
< img alt = "vmalert multi cluster" src = "vmalert_multicluster.png" >
2021-12-01 16:33:06 +01:00
Please note, [replay ](#rules-backfilling ) feature may be used for transforming historical data.
Flags `-remoteRead.url` and `-notifier.url` are omitted since we assume only recording rules are used.
2021-05-18 15:22:08 +02:00
2022-02-04 10:56:52 +01:00
See also [downsampling docs ](https://docs.victoriametrics.com/#downsampling ).
2022-06-16 13:30:28 +02:00
#### Multiple remote writes
For persisting recording or alerting rule results `vmalert` requires `-remoteWrite.url` to be set.
But this flag supports only one destination. To persist rule results to multiple destinations
we recommend using [vmagent ](https://docs.victoriametrics.com/vmagent.html ) as fan-out proxy:
< img alt = "vmalert multiple remote write destinations" src = "vmalert_multiple_rw.png" >
In this topology, `vmalert` is configured to persist rule results to `vmagent` . And `vmagent`
is configured to fan-out received data to two or more destinations.
Using `vmagent` as a proxy provides additional benefits such as
[data persisting when storage is unreachable ](https://docs.victoriametrics.com/vmagent.html#replication-and-high-availability ),
or time series modification via [relabeling ](https://docs.victoriametrics.com/vmagent.html#relabeling ).
2021-11-05 19:44:02 +01:00
### Web
2020-06-10 18:37:43 +02:00
`vmalert` runs a web-server (`-httpListenAddr`) for serving metrics and alerts endpoints:
2022-03-22 12:40:55 +01:00
2021-09-09 15:16:25 +02:00
* `http://<vmalert-addr>` - UI;
2022-03-28 12:07:02 +02:00
* `http://<vmalert-addr>/api/v1/rules` - list of all loaded groups and rules;
2020-04-29 16:42:01 +02:00
* `http://<vmalert-addr>/api/v1/alerts` - list of all active alerts;
2022-08-17 20:24:00 +02:00
* `http://<vmalert-addr>/vmalert/api/v1/alert?group_id=<group_id>&alert_id=<alert_id>` - get alert status in JSON format.
2022-05-14 18:56:31 +02:00
Used as alert source in AlertManager.
2022-08-17 20:24:00 +02:00
* `http://<vmalert-addr>/vmalert/alert?group_id=<group_id>&alert_id=<alert_id>` - get alert status in web UI.
2022-09-14 14:04:24 +02:00
* `http://<vmalert-addr>/vmalert/rule?group_id=<group_id>&rule_id=<rule_id>` - get rule status in web UI.
2020-04-29 16:42:01 +02:00
* `http://<vmalert-addr>/metrics` - application metrics.
2020-05-13 21:55:35 +02:00
* `http://<vmalert-addr>/-/reload` - hot configuration reload.
2020-04-29 16:42:01 +02:00
2022-08-04 16:56:07 +02:00
`vmalert` web UI can be accessed from [single-node version of VictoriaMetrics ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html )
and from [cluster version of VictoriaMetrics ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html ).
This may be used for better integraion with Grafana unified alerting system. See the following docs for details:
* [How to query vmalert from single-node VictoriaMetrics ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#vmalert )
* [How to query vmalert from VictoriaMetrics cluster ](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#vmalert )
2021-04-07 12:39:16 +02:00
## Graphite
2021-02-01 14:26:33 +01:00
vmalert sends requests to `<-datasource.url>/render?format=json` during evaluation of alerting and recording rules
2021-02-03 20:12:14 +01:00
if the corresponding group or rule contains `type: "graphite"` config option. It is expected that the `<-datasource.url>/render`
2021-02-01 14:26:33 +01:00
implements [Graphite Render API ](https://graphite.readthedocs.io/en/stable/render_api.html ) for `format=json` .
2021-02-03 22:44:37 +01:00
When using vmalert with both `graphite` and `prometheus` rules configured against cluster version of VM do not forget
2021-12-01 16:33:06 +01:00
to set `-datasource.appendTypePrefix` flag to `true` , so vmalert can adjust URL prefix automatically based on the query type.
2021-02-01 14:26:33 +01:00
2021-06-09 11:27:31 +02:00
## Rules backfilling
vmalert supports alerting and recording rules backfilling (aka `replay` ). In replay mode vmalert
2021-11-05 19:44:02 +01:00
can read the same rules configuration as normal, evaluate them on the given time range and backfill
2021-06-09 11:27:31 +02:00
results via remote write to the configured storage. vmalert supports any PromQL/MetricsQL compatible
data source for backfilling.
### How it works
In `replay` mode vmalert works as a cli-tool and exits immediately after work is done.
To run vmalert in `replay` mode:
2022-03-22 12:40:55 +01:00
2021-06-09 11:27:31 +02:00
```
./bin/vmalert -rule=path/to/your.rules \ # path to files with rules you usually use with vmalert
2022-08-08 09:45:21 +02:00
-datasource.url=http://localhost:8428 \ # Prometheus HTTP API compatible datasource
2021-06-09 11:27:31 +02:00
-remoteWrite.url=http://localhost:8428 \ # remote write compatible storage to persist results
-replay.timeFrom=2021-05-11T07:21:43Z \ # time from begin replay
-replay.timeTo=2021-05-29T18:40:43Z # time to finish replay
```
The output of the command will look like the following:
2022-03-22 12:40:55 +01:00
2021-06-09 11:27:31 +02:00
```
Replay mode:
from: 2021-05-11 07:21:43 +0000 UTC # set by -replay.timeFrom
to: 2021-05-29 18:40:43 +0000 UTC # set by -replay.timeTo
max data points per request: 1000 # set by -replay.maxDatapointsPerQuery
Group "ReplayGroup"
interval: 1m0s
requests to make: 27
max range per request: 16h40m0s
> Rule "type:vm_cache_entries:rate5m" (ID: 1792509946081842725)
27 / 27 [----------------------------------------------------------------------------------------------------] 100.00% 78 p/s
> Rule "go_cgo_calls_count:rate5m" (ID: 17958425467471411582)
27 / 27 [-----------------------------------------------------------------------------------------------------] 100.00% ? p/s
Group "vmsingleReplay"
interval: 30s
requests to make: 54
max range per request: 8h20m0s
> Rule "RequestErrorsToAPI" (ID: 17645863024999990222)
54 / 54 [-----------------------------------------------------------------------------------------------------] 100.00% ? p/s
> Rule "TooManyLogs" (ID: 9042195394653477652)
54 / 54 [-----------------------------------------------------------------------------------------------------] 100.00% ? p/s
2021-06-07T09:59:12.098Z info app/vmalert/replay.go:68 replay finished! Imported 511734 samples
```
In `replay` mode all groups are executed sequentially one-by-one. Rules within the group are
executed sequentially as well (`concurrency` setting is ignored). Vmalert sends rule's expression
2022-06-19 22:12:10 +02:00
to [/query_range ](https://docs.victoriametrics.com/keyConcepts.html#range-query ) endpoint
2021-11-05 19:44:02 +01:00
of the configured `-datasource.url` . Returned data is then processed according to the rule type and
backfilled to `-remoteWrite.url` via [remote Write protocol ](https://prometheus.io/docs/prometheus/latest/storage/#remote-storage-integrations ).
2021-06-09 11:27:31 +02:00
Vmalert respects `evaluationInterval` value set by flag or per-group during the replay.
2021-09-01 11:02:28 +02:00
Vmalert automatically disables caching on VictoriaMetrics side by sending `nocache=1` param. It allows
to prevent cache pollution and unwanted time range boundaries adjustment during backfilling.
2021-06-09 11:27:31 +02:00
#### Recording rules
2021-12-01 16:33:06 +01:00
The result of recording rules `replay` should match with results of normal rules evaluation.
2021-06-09 11:27:31 +02:00
#### Alerting rules
2021-12-01 16:33:06 +01:00
The result of alerting rules `replay` is time series reflecting [alert's state ](#alerts-state-on-restarts ).
2021-06-09 11:27:31 +02:00
To see if `replayed` alert has fired in the past use the following PromQL/MetricsQL expression:
2022-03-22 12:40:55 +01:00
2021-06-09 11:27:31 +02:00
```
ALERTS{alertname="your_alertname", alertstate="firing"}
```
2022-03-22 12:40:55 +01:00
2021-06-09 11:27:31 +02:00
Execute the query against storage which was used for `-remoteWrite.url` during the `replay` .
### Additional configuration
There are following non-required `replay` flags:
* `-replay.maxDatapointsPerQuery` - the max number of data points expected to receive in one request.
2022-05-14 18:56:31 +02:00
In two words, it affects the max time range for every `/query_range` request. The higher the value,
the fewer requests will be issued during `replay` .
2021-06-09 11:27:31 +02:00
* `-replay.ruleRetryAttempts` - when datasource fails to respond vmalert will make this number of retries
2022-05-14 18:56:31 +02:00
per rule before giving up.
2021-06-09 11:27:31 +02:00
* `-replay.rulesDelay` - delay between sequential rules execution. Important in cases if there are chaining
2022-05-14 18:56:31 +02:00
(rules which depend on each other) rules. It is expected, that remote storage will be able to persist
previously accepted data during the delay, so data will be available for the subsequent queries.
Keep it equal or bigger than `-remoteWrite.flushInterval` .
2022-05-30 08:16:07 +02:00
* `-replay.disableProgressBar` - whether to disable progress bar which shows progress work.
2022-05-14 18:56:31 +02:00
Progress bar may generate a lot of log records, which is not formatted as standard VictoriaMetrics logger.
It could break logs parsing by external system and generate additional load on it.
2021-06-09 11:27:31 +02:00
2022-09-26 07:36:22 +02:00
See full description for these flags in `./vmalert -help` .
2021-06-09 11:27:31 +02:00
### Limitations
* Graphite engine isn't supported yet;
* `query` template function is disabled for performance reasons (might be changed in future);
2022-06-09 08:58:25 +02:00
* `limit` group's param has no effect during replay (might be changed in future);
2021-06-09 11:27:31 +02:00
2021-09-01 11:02:28 +02:00
## Monitoring
2021-10-18 09:24:52 +02:00
`vmalert` exports various metrics in Prometheus exposition format at `http://vmalert-host:8880/metrics` page.
We recommend setting up regular scraping of this page either through `vmagent` or by Prometheus so that the exported
2021-09-01 11:02:28 +02:00
metrics may be analyzed later.
2021-12-01 16:33:06 +01:00
Use the official [Grafana dashboard ](https://grafana.com/grafana/dashboards/14950 ) for `vmalert` overview. Graphs on this dashboard contain useful hints - hover the `i` icon at the top left corner of each graph in order to read it.
2021-10-18 09:24:52 +02:00
If you have suggestions for improvements or have found a bug - please open an issue on github or add
2021-09-01 11:02:28 +02:00
a review to the dashboard.
2022-09-15 16:15:39 +02:00
## Troubleshooting
vmalert executes configured rules within certain intervals. It is expected that at the moment when rule is executed,
the data is already present in configured `-datasource.url` :
< img alt = "vmalert expected evaluation" src = "vmalert_ts_normal.gif" >
Usually, troubles start to appear when data in `-datasource.url` is delayed or absent. In such cases, evaluations
may get empty response from datasource and produce empty recording rules or reset alerts state:
< img alt = "vmalert evaluation when data is delayed" src = "vmalert_ts_data_delay.gif" >
2022-09-26 07:36:22 +02:00
_By default recently written samples to VictoriaMetrics aren't visible for queries for up to 30s.
This behavior is controlled by `-search.latencyOffset` command-line flag on vmselect. Usually, this results into
a 30s shift for recording rules results.
Note that too small value passed to `-search.latencyOffset` may lead to incomplete query results._
2022-09-23 09:49:14 +02:00
2022-09-15 16:15:39 +02:00
Try the following recommendations in such cases:
* Always configure group's `evaluationInterval` to be bigger or equal to `scrape_interval` at which metrics
are delivered to the datasource;
* If you know in advance, that data in datasource is delayed - try changing vmalert's `-datasource.lookback`
command-line flag to add a time shift for evaluations;
* If time intervals between datapoints in datasource are irregular - try changing vmalert's `-datasource.queryStep`
command-line flag to specify how far search query can lookback for the recent datapoint. By default, this value
2022-09-26 07:46:21 +02:00
is equal to group's evaluation interval.
2022-09-15 16:15:39 +02:00
Sometimes, it is not clear why some specific alert fired or didn't fire. It is very important to remember, that
alerts with `for: 0` fire immediately when their expression becomes true. And alerts with `for > 0` will fire only
after multiple consecutive evaluations, and at each evaluation their expression must be true. If at least one evaluation
becomes false, then alert's state resets to the initial state.
If `-remoteWrite.url` command-line flag is configured, vmalert will persist alert's state in form of time series
`ALERTS` and `ALERTS_FOR_STATE` to the specified destination. Such time series can be then queried via
[vmui ](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#vmui ) or Grafana to track how alerts state
changed in time.
vmalert also stores last N state updates for each rule. To check updates, click on `Details` link next to rule's name
on `/vmalert/groups` page and check the `Last updates` section:
< img alt = "vmalert state" src = "vmalert_state.png" >
Rows in the section represent ordered rule evaluations and their results. The column `curl` contains an example of
HTTP request sent by vmalert to the `-datasource.url` during evaluation. If specific state shows that there were
no samples returned and curl command returns data - then it is very likely there was no data in datasource on the
moment when rule was evaluated.
vmalert also alows configuring more detailed logging for specific rule. Just set `debug: true` in rule's configuration
and vmalert will start printing additional log messages:
```terminal
2022-09-15T13:35:41.155Z DEBUG rule "TestGroup":"Conns" (2601299393013563564) at 2022-09-15T15:35:41+02:00: query returned 0 samples (elapsed: 5.896041ms)
2022-09-15T13:35:56.149Z DEBUG datasource request: executing POST request with params "denyPartialResponse=true& query=sum%28vm_tcplistener_conns%7Binstance%3D%22localhost%3A8429%22%7D%29+by%28instance%29+%3E+0& step=15s& time=1663248945"
2022-09-15T13:35:56.178Z DEBUG rule "TestGroup":"Conns" (2601299393013563564) at 2022-09-15T15:35:56+02:00: query returned 1 samples (elapsed: 28.368208ms)
2022-09-15T13:35:56.178Z DEBUG datasource request: executing POST request with params "denyPartialResponse=true& query=sum%28vm_tcplistener_conns%7Binstance%3D%22localhost%3A8429%22%7D%29& step=15s& time=1663248945"
2022-09-15T13:35:56.179Z DEBUG rule "TestGroup":"Conns" (2601299393013563564) at 2022-09-15T15:35:56+02:00: alert 10705778000901301787 {alertgroup="TestGroup",alertname="Conns",cluster="east-1",instance="localhost:8429",replica="a"} created in state PENDING
...
2022-09-15T13:36:56.153Z DEBUG rule "TestGroup":"Conns" (2601299393013563564) at 2022-09-15T15:36:56+02:00: alert 10705778000901301787 {alertgroup="TestGroup",alertname="Conns",cluster="east-1",instance="localhost:8429",replica="a"} PENDING => FIRING: 1m0s since becoming active at 2022-09-15 15:35:56.126006 +0200 CEST m=+39.384575417
```
2022-08-24 13:07:33 +02:00
## Profiling
`vmalert` provides handlers for collecting the following [Go profiles ](https://blog.golang.org/profiling-go-programs ):
* Memory profile. It can be collected with the following command (replace `0.0.0.0` with hostname if needed):
< div class = "with-copy" markdown = "1" >
```console
curl http://0.0.0.0:8880/debug/pprof/heap > mem.pprof
```
< / div >
* CPU profile. It can be collected with the following command (replace `0.0.0.0` with hostname if needed):
< div class = "with-copy" markdown = "1" >
```console
curl http://0.0.0.0:8880/debug/pprof/profile > cpu.pprof
```
< / div >
The command for collecting CPU profile waits for 30 seconds before returning.
The collected profiles may be analyzed with [go tool pprof ](https://github.com/google/pprof ).
It is safe sharing the collected profiles from security point of view, since they do not contain sensitive information.
2021-04-07 12:39:16 +02:00
## Configuration
2020-04-29 16:42:01 +02:00
2021-12-02 23:08:42 +01:00
### Flags
2021-06-14 10:37:26 +02:00
Pass `-help` to `vmalert` in order to see the full list of supported
command-line flags with their descriptions.
2020-04-29 16:42:01 +02:00
The shortlist of configuration flags is the following:
2022-08-16 10:44:08 +02:00
{% raw %}
2020-04-29 16:42:01 +02:00
```
2022-08-08 13:02:03 +02:00
-clusterMode
2022-09-15 12:00:36 +02:00
If clusterMode is enabled, then vmalert automatically adds the tenant specified in config groups to -datasource.url, -remoteWrite.url and -remoteRead.url. See https://docs.victoriametrics.com/vmalert.html#multitenancy . This flag is available only in enterprise version of VictoriaMetrics
2022-02-08 14:37:38 +01:00
-configCheckInterval duration
2022-08-08 13:02:03 +02:00
Interval for checking for changes in '-rule' or '-notifier.config' files. By default the checking is disabled. Send SIGHUP signal in order to force config check for changes.
2021-02-03 22:44:37 +01:00
-datasource.appendTypePrefix
2022-08-08 13:02:03 +02:00
Whether to add type prefix to -datasource.url based on the query type. Set to true if sending different query types to the vmselect URL.
2020-04-29 16:42:01 +02:00
-datasource.basicAuth.password string
2022-08-08 13:02:03 +02:00
Optional basic auth password for -datasource.url
2021-09-14 13:47:40 +02:00
-datasource.basicAuth.passwordFile string
2022-08-08 13:02:03 +02:00
Optional path to basic auth password to use for -datasource.url
2020-04-29 16:42:01 +02:00
-datasource.basicAuth.username string
2022-08-08 13:02:03 +02:00
Optional basic auth username for -datasource.url
2021-09-14 13:47:40 +02:00
-datasource.bearerToken string
2022-08-08 13:02:03 +02:00
Optional bearer auth token to use for -datasource.url.
2021-09-14 13:47:40 +02:00
-datasource.bearerTokenFile string
2022-08-08 13:02:03 +02:00
Optional path to bearer token file to use for -datasource.url.
2022-04-04 11:59:04 +02:00
-datasource.disableKeepAlive
2022-08-08 13:02:03 +02:00
Whether to disable long-lived connections to the datasource. If true, disables HTTP keep-alives and will only use the connection to the server for a single HTTP request.
2022-07-21 13:57:53 +02:00
-datasource.headers string
2022-08-08 13:02:03 +02:00
Optional HTTP extraHeaders to send with each request to the corresponding -datasource.url. For example, -datasource.headers='My-Auth:foobar' would send 'My-Auth: foobar' HTTP header with every request to the corresponding -datasource.url. Multiple headers must be delimited by '^^': -datasource.headers='header1:value1^^header2:value2'
2020-09-30 08:50:29 +02:00
-datasource.lookback duration
2022-08-08 13:02:03 +02:00
Lookback defines how far into the past to look when evaluating queries. For example, if the datasource.lookback=5m then param "time" with value now()-5m will be added to every query.
2020-09-30 08:50:29 +02:00
-datasource.maxIdleConnections int
2022-08-08 13:02:03 +02:00
Defines the number of idle (keep-alive connections) to each configured datasource. Consider setting this value equal to the value: groups_total * group.concurrency. Too low a value may result in a high number of sockets in TIME_WAIT state. (default 100)
2022-03-10 12:09:12 +01:00
-datasource.oauth2.clientID string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientID to use for -datasource.url.
2022-03-10 12:09:12 +01:00
-datasource.oauth2.clientSecret string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecret to use for -datasource.url.
2022-03-10 12:09:12 +01:00
-datasource.oauth2.clientSecretFile string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecretFile to use for -datasource.url.
2022-03-10 12:09:12 +01:00
-datasource.oauth2.scopes string
2022-08-08 13:02:03 +02:00
Optional OAuth2 scopes to use for -datasource.url. Scopes must be delimited by ';'
2022-03-10 12:09:12 +01:00
-datasource.oauth2.tokenUrl string
2022-08-08 13:02:03 +02:00
Optional OAuth2 tokenURL to use for -datasource.url.
2021-03-01 16:01:27 +01:00
-datasource.queryStep duration
2022-09-26 07:46:21 +02:00
How far a value can fallback to when evaluating queries. For example, if -datasource.queryStep=15s then param "step" with value "15s" will be added to every query. If set to 0, rule's evaluation interval will be used instead. (default 5m0s)
2022-03-16 11:30:02 +01:00
-datasource.queryTimeAlignment
2022-08-08 13:02:03 +02:00
Whether to align "time" parameter with evaluation interval.Alignment supposed to produce deterministic results despite of number of vmalert replicas or time they were started. See more details here https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1257 (default true)
2021-05-10 10:18:26 +02:00
-datasource.roundDigits int
2022-08-08 13:02:03 +02:00
Adds "round_digits" GET param to datasource requests. In VM "round_digits" limits the number of digits after the decimal point in response values.
2022-08-11 13:30:32 +02:00
-datasource.showURL
Whether to show -datasource.url in the exported metrics. It is hidden by default, since it can contain sensitive info such as auth key
2020-08-14 18:13:24 +02:00
-datasource.tlsCAFile string
2022-08-08 13:02:03 +02:00
Optional path to TLS CA file to use for verifying connections to -datasource.url. By default, system CA is used
2020-08-14 18:13:24 +02:00
-datasource.tlsCertFile string
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate file to use when connecting to -datasource.url
2020-06-23 21:48:25 +02:00
-datasource.tlsInsecureSkipVerify
2022-08-08 13:02:03 +02:00
Whether to skip tls verification when connecting to -datasource.url
2020-08-14 18:13:24 +02:00
-datasource.tlsKeyFile string
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate key to use when connecting to -datasource.url
2020-08-14 18:13:24 +02:00
-datasource.tlsServerName string
2022-08-08 13:02:03 +02:00
Optional TLS server name to use for connections to -datasource.url. By default, the server name from -datasource.url is used
2020-05-05 06:50:57 +02:00
-datasource.url string
2022-08-11 13:30:32 +02:00
Datasource compatible with Prometheus HTTP API. It can be single node VictoriaMetrics or vmselect URL. Required parameter. E.g. http://127.0.0.1:8428 . See also '-datasource.disablePathAppend', '-datasource.showURL'.
2022-08-08 13:02:03 +02:00
-defaultTenant.graphite string
2022-09-15 12:00:36 +02:00
Default tenant for Graphite alerting groups. See https://docs.victoriametrics.com/vmalert.html#multitenancy .This flag is available only in enterprise version of VictoriaMetrics
2022-08-08 13:02:03 +02:00
-defaultTenant.prometheus string
2022-09-15 12:00:36 +02:00
Default tenant for Prometheus alerting groups. See https://docs.victoriametrics.com/vmalert.html#multitenancy . This flag is available only in enterprise version of VictoriaMetrics
2021-08-21 19:24:56 +02:00
-disableAlertgroupLabel
2022-08-08 13:02:03 +02:00
Whether to disable adding group's Name as label to generated alerts and time series.
2022-09-15 12:00:36 +02:00
-dryRun
2022-08-08 13:02:03 +02:00
Whether to check only config files without running vmalert. The rules file are validated. The -rule flag must be specified.
2020-08-14 18:13:24 +02:00
-enableTCP6
2022-08-08 13:02:03 +02:00
Whether to enable IPv6 for listening and dialing. By default only IPv4 TCP and UDP is used
2020-08-14 18:13:24 +02:00
-envflag.enable
2022-08-08 13:02:03 +02:00
Whether to enable reading flags from environment variables additionally to command line. Command line flag values have priority over values from environment vars. Flags are read only from command line if this flag isn't set. See https://docs.victoriametrics.com/#environment-variables for more details
2020-08-14 18:13:24 +02:00
-envflag.prefix string
2022-08-08 13:02:03 +02:00
Prefix for environment variables if -envflag.enable is set
-eula
2022-09-15 12:00:36 +02:00
By specifying this flag, you confirm that you have an enterprise license and accept the EULA https://victoriametrics.com/assets/VM_EULA.pdf . This flag is available only in enterprise version of VictoriaMetrics
2020-04-29 16:42:01 +02:00
-evaluationInterval duration
2022-08-08 13:02:03 +02:00
How often to evaluate the rules (default 1m0s)
2020-08-14 18:13:24 +02:00
-external.alert.source string
2022-09-15 12:00:36 +02:00
External Alert Source allows to override the Source link for alerts sent to AlertManager for cases where you want to build a custom link to Grafana, Prometheus or any other service.
Supports templating. For example, link to Grafana: 'explore?orgId=1& left=[\"now-1h\",\"now\",\"VictoriaMetrics\",{\"expr\": \"{{$expr|quotesEscape|crlfEscape|queryEscape}}\"},{\"mode\":\"Metrics\"},{\"ui\":[true,true,true,\"none\"]}]'.
If empty 'vmalert/alert?group_id={{.GroupID}}& alert_id={{.AlertID}}' is used.
2020-07-30 20:56:48 +02:00
-external.label array
2022-08-08 13:02:03 +02:00
Optional label in the form 'Name=value' to add to all generated recording rules and alerts. Pass multiple -label flags in order to add multiple label sets.
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-external.url string
2022-08-08 13:02:03 +02:00
External URL is used as alert's source for sent alerts to the notifier
-flagsAuthKey string
Auth key for /flags endpoint. It must be passed via authKey query arg. It overrides httpAuth.* settings
-fs.disableMmap
Whether to use pread() instead of mmap() for reading data files. By default mmap() is used for 64-bit arches and pread() is used for 32-bit arches, since they cannot read data files bigger than 2^32 bytes in memory. mmap() is usually faster for reading small data chunks than pread()
-http.connTimeout duration
Incoming http connections are closed after the configured timeout. This may help to spread the incoming load among a cluster of services behind a load balancer. Please note that the real timeout may be bigger by up to 10% as a protection against the thundering herd problem (default 2m0s)
-http.disableResponseCompression
Disable compression of HTTP responses to save CPU resources. By default compression is enabled to save network bandwidth
-http.idleConnTimeout duration
Timeout for incoming idle http connections (default 1m0s)
-http.maxGracefulShutdownDuration duration
The maximum duration for a graceful shutdown of the HTTP server. A highly loaded server may require increased value for a graceful shutdown (default 7s)
-http.pathPrefix string
An optional prefix to add to all the paths handled by http server. For example, if '-http.pathPrefix=/foo/bar' is set, then all the http requests will be handled on '/foo/bar/*' paths. This may be useful for proxied requests. See https://www.robustperception.io/using-external-urls-and-proxies-with-prometheus
-http.shutdownDelay duration
Optional delay before http server shutdown. During this delay, the server returns non-OK responses from /health page, so load balancers can route new requests to other servers
2020-08-14 18:13:24 +02:00
-httpAuth.password string
2022-08-08 13:02:03 +02:00
Password for HTTP Basic Auth. The authentication is disabled if -httpAuth.username is empty
2020-08-14 18:13:24 +02:00
-httpAuth.username string
2022-08-08 13:02:03 +02:00
Username for HTTP Basic Auth. The authentication is disabled if empty. See also -httpAuth.password
2020-04-29 16:42:01 +02:00
-httpListenAddr string
2022-08-08 13:02:03 +02:00
Address to listen for http connections (default ":8880")
-loggerDisableTimestamps
Whether to disable writing timestamps in logs
-loggerErrorsPerSecondLimit int
Per-second limit on the number of ERROR messages. If more than the given number of errors are emitted per second, the remaining errors are suppressed. Zero values disable the rate limit
-loggerFormat string
Format for logs. Possible values: default, json (default "default")
-loggerLevel string
Minimum level of errors to log. Possible values: INFO, WARN, ERROR, FATAL, PANIC (default "INFO")
-loggerOutput string
Output for the logs. Supported values: stderr, stdout (default "stderr")
-loggerTimezone string
Timezone to use for timestamps in logs. Timezone must be a valid IANA Time Zone. For example: America/New_York, Europe/Berlin, Etc/GMT+3 or Local (default "UTC")
-loggerWarnsPerSecondLimit int
Per-second limit on the number of WARN messages. If more than the given number of warns are emitted per second, then the remaining warns are suppressed. Zero values disable the rate limit
-memory.allowedBytes size
Allowed size of system memory VictoriaMetrics caches may occupy. This option overrides -memory.allowedPercent if set to a non-zero value. Too low a value may increase the cache miss rate usually resulting in higher CPU and disk IO usage. Too high a value may evict too much data from OS page cache resulting in higher disk IO usage
Supports the following optional suffixes for size values: KB, MB, GB, KiB, MiB, GiB (default 0)
-memory.allowedPercent float
Allowed percent of system memory VictoriaMetrics caches may occupy. See also -memory.allowedBytes. Too low a value may increase cache miss rate usually resulting in higher CPU and disk IO usage. Too high a value may evict too much data from OS page cache which will result in higher disk IO usage (default 60)
2020-06-02 18:12:41 +02:00
-metricsAuthKey string
2022-08-08 13:02:03 +02:00
Auth key for /metrics endpoint. It must be passed via authKey query arg. It overrides httpAuth.* settings
2020-08-14 18:13:24 +02:00
-notifier.basicAuth.password array
2022-08-08 13:02:03 +02:00
Optional basic auth password for -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-02-02 22:26:16 +01:00
-notifier.basicAuth.passwordFile array
2022-08-08 13:02:03 +02:00
Optional path to basic auth password file for -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-notifier.basicAuth.username array
2022-08-08 13:02:03 +02:00
Optional basic auth username for -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-03-10 12:09:12 +01:00
-notifier.bearerToken array
2022-08-08 13:02:03 +02:00
Optional bearer token for -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-03-10 12:09:12 +01:00
-notifier.bearerTokenFile array
2022-08-08 13:02:03 +02:00
Optional path to bearer token file for -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-02-08 14:37:38 +01:00
-notifier.config string
2022-08-08 13:02:03 +02:00
Path to configuration file for notifiers
2022-03-10 12:09:12 +01:00
-notifier.oauth2.clientID array
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientID to use for -notifier.url. If multiple args are set, then they are applied independently for the corresponding -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-03-10 12:09:12 +01:00
-notifier.oauth2.clientSecret array
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecret to use for -notifier.url. If multiple args are set, then they are applied independently for the corresponding -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-03-10 12:09:12 +01:00
-notifier.oauth2.clientSecretFile array
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecretFile to use for -notifier.url. If multiple args are set, then they are applied independently for the corresponding -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-03-10 12:09:12 +01:00
-notifier.oauth2.scopes array
2022-08-08 13:02:03 +02:00
Optional OAuth2 scopes to use for -notifier.url. Scopes must be delimited by ';'. If multiple args are set, then they are applied independently for the corresponding -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-03-10 12:09:12 +01:00
-notifier.oauth2.tokenUrl array
2022-08-08 13:02:03 +02:00
Optional OAuth2 tokenURL to use for -notifier.url. If multiple args are set, then they are applied independently for the corresponding -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2022-02-08 14:37:38 +01:00
-notifier.suppressDuplicateTargetErrors
2022-08-08 13:02:03 +02:00
Whether to suppress 'duplicate target' errors during discovery
2020-08-14 18:13:24 +02:00
-notifier.tlsCAFile array
2022-08-08 13:02:03 +02:00
Optional path to TLS CA file to use for verifying connections to -notifier.url. By default system CA is used
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-notifier.tlsCertFile array
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate file to use when connecting to -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2020-12-22 21:32:10 +01:00
-notifier.tlsInsecureSkipVerify array
2022-08-08 13:02:03 +02:00
Whether to skip tls verification when connecting to -notifier.url
Supports array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-notifier.tlsKeyFile array
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate key to use when connecting to -notifier.url
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-notifier.tlsServerName array
2022-08-08 13:02:03 +02:00
Optional TLS server name to use for connections to -notifier.url. By default the server name from -notifier.url is used
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-notifier.url array
2022-08-08 13:02:03 +02:00
Prometheus alertmanager URL, e.g. http://127.0.0.1:9093
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-pprofAuthKey string
2022-08-08 13:02:03 +02:00
Auth key for /debug/pprof/* endpoints. It must be passed via authKey query arg. It overrides httpAuth.* settings
-promscrape.consul.waitTime duration
Wait time used by Consul service discovery. Default value is used if not set
-promscrape.consulSDCheckInterval duration
2022-09-15 12:00:36 +02:00
Interval for checking for changes in Consul. This works only if consul_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs.html#consul_sd_configs for details (default 30s)
2022-08-08 13:02:03 +02:00
-promscrape.discovery.concurrency int
The maximum number of concurrent requests to Prometheus autodiscovery API (Consul, Kubernetes, etc.) (default 100)
-promscrape.discovery.concurrentWaitTime duration
The maximum duration for waiting to perform API requests if more than -promscrape.discovery.concurrency requests are simultaneously performed (default 1m0s)
-promscrape.dnsSDCheckInterval duration
2022-09-15 12:00:36 +02:00
Interval for checking for changes in dns. This works only if dns_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs.html#dns_sd_configs for details (default 30s)
2022-08-08 13:02:03 +02:00
-pushmetrics.extraLabel array
Optional labels to add to metrics pushed to -pushmetrics.url . For example, -pushmetrics.extraLabel='instance="foo"' adds instance="foo" label to all the metrics pushed to -pushmetrics.url
Supports an array of values separated by comma or specified via multiple flags.
-pushmetrics.interval duration
Interval for pushing metrics to -pushmetrics.url (default 10s)
-pushmetrics.url array
Optional URL to push metrics exposed at /metrics page. See https://docs.victoriametrics.com/#push-metrics . By default metrics exposed at /metrics page aren't pushed to any remote storage
Supports an array of values separated by comma or specified via multiple flags.
2020-05-13 21:55:35 +02:00
-remoteRead.basicAuth.password string
2022-08-08 13:02:03 +02:00
Optional basic auth password for -remoteRead.url
2021-09-14 13:47:40 +02:00
-remoteRead.basicAuth.passwordFile string
2022-08-08 13:02:03 +02:00
Optional path to basic auth password to use for -remoteRead.url
2020-05-13 21:55:35 +02:00
-remoteRead.basicAuth.username string
2022-08-08 13:02:03 +02:00
Optional basic auth username for -remoteRead.url
2021-09-14 13:47:40 +02:00
-remoteRead.bearerToken string
2022-08-08 13:02:03 +02:00
Optional bearer auth token to use for -remoteRead.url.
2021-09-14 13:47:40 +02:00
-remoteRead.bearerTokenFile string
2022-08-08 13:02:03 +02:00
Optional path to bearer token file to use for -remoteRead.url.
2021-10-18 09:24:52 +02:00
-remoteRead.disablePathAppend
2022-08-08 13:02:03 +02:00
Whether to disable automatic appending of '/api/v1/query' path to the configured -datasource.url and -remoteRead.url
2022-07-21 13:57:53 +02:00
-remoteRead.headers string
2022-08-08 13:02:03 +02:00
Optional HTTP headers to send with each request to the corresponding -remoteRead.url. For example, -remoteRead.headers='My-Auth:foobar' would send 'My-Auth: foobar' HTTP header with every request to the corresponding -remoteRead.url. Multiple headers must be delimited by '^^': -remoteRead.headers='header1:value1^^header2:value2'
2021-05-10 10:18:26 +02:00
-remoteRead.ignoreRestoreErrors
2022-08-08 13:02:03 +02:00
Whether to ignore errors from remote storage when restoring alerts state on startup. (default true)
2020-05-13 21:55:35 +02:00
-remoteRead.lookback duration
2022-08-08 13:02:03 +02:00
Lookback defines how far to look into past for alerts timeseries. For example, if lookback=1h then range from now() to now()-1h will be scanned. (default 1h0m0s)
2022-03-10 12:09:12 +01:00
-remoteRead.oauth2.clientID string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientID to use for -remoteRead.url.
2022-03-10 12:09:12 +01:00
-remoteRead.oauth2.clientSecret string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecret to use for -remoteRead.url.
2022-03-10 12:09:12 +01:00
-remoteRead.oauth2.clientSecretFile string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecretFile to use for -remoteRead.url.
2022-03-10 12:09:12 +01:00
-remoteRead.oauth2.scopes string
2022-08-08 13:02:03 +02:00
Optional OAuth2 scopes to use for -remoteRead.url. Scopes must be delimited by ';'.
2022-03-10 12:09:12 +01:00
-remoteRead.oauth2.tokenUrl string
2022-08-08 13:02:03 +02:00
Optional OAuth2 tokenURL to use for -remoteRead.url.
2022-08-11 13:30:32 +02:00
-remoteRead.showURL
Whether to show -remoteRead.url in the exported metrics. It is hidden by default, since it can contain sensitive info such as auth key
2020-08-14 18:13:24 +02:00
-remoteRead.tlsCAFile string
2022-08-08 13:02:03 +02:00
Optional path to TLS CA file to use for verifying connections to -remoteRead.url. By default system CA is used
2020-08-14 18:13:24 +02:00
-remoteRead.tlsCertFile string
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate file to use when connecting to -remoteRead.url
2020-06-23 21:48:25 +02:00
-remoteRead.tlsInsecureSkipVerify
2022-08-08 13:02:03 +02:00
Whether to skip tls verification when connecting to -remoteRead.url
2020-08-14 18:13:24 +02:00
-remoteRead.tlsKeyFile string
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate key to use when connecting to -remoteRead.url
2020-08-14 18:13:24 +02:00
-remoteRead.tlsServerName string
2022-08-08 13:02:03 +02:00
Optional TLS server name to use for connections to -remoteRead.url. By default the server name from -remoteRead.url is used
2020-05-13 21:55:35 +02:00
-remoteRead.url vmalert
2022-08-11 13:30:32 +02:00
Optional URL to datasource compatible with Prometheus HTTP API. It can be single node VictoriaMetrics or vmselect.Remote read is used to restore alerts state.This configuration makes sense only if vmalert was configured with `remoteWrite.url` before and has been successfully persisted its state. E.g. http://127.0.0.1:8428. See also '-remoteRead.disablePathAppend', '-remoteRead.showURL'.
2020-05-13 21:55:35 +02:00
-remoteWrite.basicAuth.password string
2022-08-08 13:02:03 +02:00
Optional basic auth password for -remoteWrite.url
2021-09-14 13:47:40 +02:00
-remoteWrite.basicAuth.passwordFile string
2022-08-08 13:02:03 +02:00
Optional path to basic auth password to use for -remoteWrite.url
2020-05-13 21:55:35 +02:00
-remoteWrite.basicAuth.username string
2022-08-08 13:02:03 +02:00
Optional basic auth username for -remoteWrite.url
2021-09-14 13:47:40 +02:00
-remoteWrite.bearerToken string
2022-08-08 13:02:03 +02:00
Optional bearer auth token to use for -remoteWrite.url.
2021-09-14 13:47:40 +02:00
-remoteWrite.bearerTokenFile string
2022-08-08 13:02:03 +02:00
Optional path to bearer token file to use for -remoteWrite.url.
2020-06-02 18:12:41 +02:00
-remoteWrite.concurrency int
2022-08-08 13:02:03 +02:00
Defines number of writers for concurrent writing into remote querier (default 1)
2021-08-16 14:20:22 +02:00
-remoteWrite.disablePathAppend
2022-08-08 13:02:03 +02:00
Whether to disable automatic appending of '/api/v1/write' path to the configured -remoteWrite.url.
2020-06-29 21:09:03 +02:00
-remoteWrite.flushInterval duration
2022-08-08 13:02:03 +02:00
Defines interval of flushes to remote write endpoint (default 5s)
2022-07-21 13:57:53 +02:00
-remoteWrite.headers string
2022-08-08 13:02:03 +02:00
Optional HTTP headers to send with each request to the corresponding -remoteWrite.url. For example, -remoteWrite.headers='My-Auth:foobar' would send 'My-Auth: foobar' HTTP header with every request to the corresponding -remoteWrite.url. Multiple headers must be delimited by '^^': -remoteWrite.headers='header1:value1^^header2:value2'
2020-06-02 18:12:41 +02:00
-remoteWrite.maxBatchSize int
2022-08-08 13:02:03 +02:00
Defines defines max number of timeseries to be flushed at once (default 1000)
2020-06-02 18:12:41 +02:00
-remoteWrite.maxQueueSize int
2022-08-08 13:02:03 +02:00
Defines the max number of pending datapoints to remote write endpoint (default 100000)
2022-03-10 12:09:12 +01:00
-remoteWrite.oauth2.clientID string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientID to use for -remoteWrite.url.
2022-03-10 12:09:12 +01:00
-remoteWrite.oauth2.clientSecret string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecret to use for -remoteWrite.url.
2022-03-10 12:09:12 +01:00
-remoteWrite.oauth2.clientSecretFile string
2022-08-08 13:02:03 +02:00
Optional OAuth2 clientSecretFile to use for -remoteWrite.url.
2022-03-10 12:09:12 +01:00
-remoteWrite.oauth2.scopes string
2022-08-08 13:02:03 +02:00
Optional OAuth2 scopes to use for -notifier.url. Scopes must be delimited by ';'.
2022-03-10 12:09:12 +01:00
-remoteWrite.oauth2.tokenUrl string
2022-08-08 13:02:03 +02:00
Optional OAuth2 tokenURL to use for -notifier.url.
2022-08-11 13:30:32 +02:00
-remoteWrite.showURL
Whether to show -remoteWrite.url in the exported metrics. It is hidden by default, since it can contain sensitive info such as auth key
2020-08-14 18:13:24 +02:00
-remoteWrite.tlsCAFile string
2022-08-08 13:02:03 +02:00
Optional path to TLS CA file to use for verifying connections to -remoteWrite.url. By default system CA is used
2020-08-14 18:13:24 +02:00
-remoteWrite.tlsCertFile string
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate file to use when connecting to -remoteWrite.url
2020-06-23 21:48:25 +02:00
-remoteWrite.tlsInsecureSkipVerify
2022-08-08 13:02:03 +02:00
Whether to skip tls verification when connecting to -remoteWrite.url
2020-08-14 18:13:24 +02:00
-remoteWrite.tlsKeyFile string
2022-08-08 13:02:03 +02:00
Optional path to client-side TLS certificate key to use when connecting to -remoteWrite.url
2020-08-14 18:13:24 +02:00
-remoteWrite.tlsServerName string
2022-08-08 13:02:03 +02:00
Optional TLS server name to use for connections to -remoteWrite.url. By default the server name from -remoteWrite.url is used
2020-05-13 21:55:35 +02:00
-remoteWrite.url string
2022-08-11 13:30:32 +02:00
Optional URL to VictoriaMetrics or vminsert where to persist alerts state and recording rules results in form of timeseries. For example, if -remoteWrite.url=http://127.0.0.1:8428 is specified, then the alerts state will be written to http://127.0.0.1:8428/api/v1/write . See also -remoteWrite.disablePathAppend, '-remoteWrite.showURL'.
2022-05-20 14:07:16 +02:00
-replay.disableProgressBar
2022-08-08 13:02:03 +02:00
Whether to disable rendering progress bars during the replay. Progress bar rendering might be verbose or break the logs parsing, so it is recommended to be disabled when not used in interactive mode.
2021-06-09 11:27:31 +02:00
-replay.maxDatapointsPerQuery int
2022-08-08 13:02:03 +02:00
Max number of data points expected in one request. The higher the value, the less requests will be made during replay. (default 1000)
2021-06-09 11:27:31 +02:00
-replay.ruleRetryAttempts int
2022-08-08 13:02:03 +02:00
Defines how many retries to make before giving up on rule if request for it returns an error. (default 5)
2021-06-09 11:27:31 +02:00
-replay.rulesDelay duration
2022-08-08 13:02:03 +02:00
Delay between rules evaluation within the group. Could be important if there are chained rules inside of the groupand processing need to wait for previous rule results to be persisted by remote storage before evaluating the next rule.Keep it equal or bigger than -remoteWrite.flushInterval. (default 1s)
2021-06-09 11:27:31 +02:00
-replay.timeFrom string
2022-08-08 13:02:03 +02:00
The time filter in RFC3339 format to select time series with timestamp equal or higher than provided value. E.g. '2020-01-01T20:07:00Z'
2021-06-09 11:27:31 +02:00
-replay.timeTo string
2022-08-08 13:02:03 +02:00
The time filter in RFC3339 format to select timeseries with timestamp equal or lower than provided value. E.g. '2020-01-01T20:07:00Z'
2020-08-14 18:13:24 +02:00
-rule array
2022-08-08 13:02:03 +02:00
Path to the file with alert rules.
Supports patterns. Flag can be specified multiple times.
Examples:
-rule="/path/to/file". Path to a single file with alerting rules
-rule="dir/*.yaml" -rule="/*.yaml". Relative path to all .yaml files in "dir" folder,
absolute path to all .yaml files in root.
Rule files may contain %{ENV_VAR} placeholders, which are substituted by the corresponding env vars.
Supports an array of values separated by comma or specified via multiple flags.
2022-02-08 14:37:38 +01:00
-rule.configCheckInterval duration
2022-08-08 13:02:03 +02:00
Interval for checking for changes in '-rule' files. By default the checking is disabled. Send SIGHUP signal in order to force config check for changes. DEPRECATED - see '-configCheckInterval' instead
2021-09-13 16:11:23 +02:00
-rule.maxResolveDuration duration
2022-08-08 13:02:03 +02:00
Limits the maximum duration for automatic alert expiration, which is by default equal to 3 evaluation intervals of the parent group.
2022-03-17 19:17:15 +01:00
-rule.resendDelay duration
2022-08-08 13:02:03 +02:00
Minimum amount of time to wait before resending an alert to notifier
2022-05-20 14:07:16 +02:00
-rule.templates array
2022-08-08 13:02:03 +02:00
Path or glob pattern to location with go template definitions
for rules annotations templating. Flag can be specified multiple times.
Examples:
-rule.templates="/path/to/file". Path to a single file with go templates
-rule.templates="dir/*.tpl" -rule.templates="/*.tpl". Relative path to all .tpl files in "dir" folder,
absolute path to all .tpl files in root.
Supports an array of values separated by comma or specified via multiple flags.
2020-06-10 18:37:43 +02:00
-rule.validateExpressions
2022-08-08 13:02:03 +02:00
Whether to validate rules expressions via MetricsQL engine (default true)
2020-04-29 16:42:01 +02:00
-rule.validateTemplates
2022-08-08 13:02:03 +02:00
Whether to validate annotation and label templates (default true)
2020-08-14 18:13:24 +02:00
-tls
2022-08-08 13:02:03 +02:00
Whether to enable TLS for incoming HTTP requests at -httpListenAddr (aka https). -tlsCertFile and -tlsKeyFile must be set if -tls is set
2020-08-14 18:13:24 +02:00
-tlsCertFile string
2022-08-08 13:02:03 +02:00
Path to file with TLS certificate if -tls is set. Prefer ECDSA certs instead of RSA certs as RSA certs are slower. The provided certificate file is automatically re-read every second, so it can be dynamically updated
2022-04-16 14:59:45 +02:00
-tlsCipherSuites array
2022-08-08 13:02:03 +02:00
Optional list of TLS cipher suites for incoming requests over HTTPS if -tls is set. See the list of supported cipher suites at https://pkg.go.dev/crypto/tls#pkg-constants
Supports an array of values separated by comma or specified via multiple flags.
2020-08-14 18:13:24 +02:00
-tlsKeyFile string
2022-08-08 13:02:03 +02:00
Path to file with TLS key if -tls is set. The provided key file is automatically re-read every second, so it can be dynamically updated
2022-09-26 16:35:45 +02:00
-tlsMinVersion string
Optional minimum TLS version to use for incoming requests over HTTPS if -tls is set. Supported values: TLS10, TLS11, TLS12, TLS13
2020-08-14 18:13:24 +02:00
-version
2022-08-08 13:02:03 +02:00
Show VictoriaMetrics version
2020-04-29 16:42:01 +02:00
```
2022-08-16 10:44:08 +02:00
{% endraw %}
2020-04-29 16:42:01 +02:00
2021-12-02 23:08:42 +01:00
### Hot config reload
2022-03-22 12:40:55 +01:00
2021-05-26 11:32:16 +02:00
`vmalert` supports "hot" config reload via the following methods:
2022-03-22 12:40:55 +01:00
2021-05-26 11:32:16 +02:00
* send SIGHUP signal to `vmalert` process;
* send GET request to `/-/reload` endpoint;
2022-02-02 22:26:16 +01:00
* configure `-configCheckInterval` flag for periodic reload
2022-05-14 18:56:31 +02:00
on config change.
2020-05-13 21:55:35 +02:00
2021-12-02 23:08:42 +01:00
### URL params
To set additional URL params for `datasource.url` , `remoteWrite.url` or `remoteRead.url`
just add them in address: `-datasource.url=http://localhost:8428?nocache=1` .
To set additional URL params for specific [group of rules ](#Groups ) modify
the `params` group:
2022-03-22 12:40:55 +01:00
2021-12-02 23:08:42 +01:00
```yaml
groups:
- name: TestGroup
params:
denyPartialResponse: ["true"]
extra_label: ["env=dev"]
```
2022-03-22 12:40:55 +01:00
2021-12-02 23:08:42 +01:00
Please note, `params` are used only for executing rules expressions (requests to `datasource.url` ).
If there would be a conflict between URL params set in `datasource.url` flag and params in group definition
the latter will have higher priority.
2022-02-02 22:26:16 +01:00
### Notifier configuration file
Notifier also supports configuration via file specified with flag `notifier.config` :
2022-03-22 12:40:55 +01:00
2022-02-02 22:26:16 +01:00
```
./bin/vmalert -rule=app/vmalert/config/testdata/rules.good.rules \
2022-03-22 12:40:55 +01:00
-datasource.url=http://localhost:8428 \
-notifier.config=app/vmalert/notifier/testdata/consul.good.yaml
2022-02-02 22:26:16 +01:00
```
2022-04-13 10:50:26 +02:00
The configuration file allows to configure static notifiers, discover notifiers via
[Consul ](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config )
and [DNS ](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dns_sd_config ):
2022-02-02 22:26:16 +01:00
For example:
2022-03-22 12:40:55 +01:00
2022-02-02 22:26:16 +01:00
```
static_configs:
- targets:
- localhost:9093
- localhost:9095
consul_sd_configs:
- server: localhost:8500
services:
- alertmanager
2022-04-13 10:50:26 +02:00
dns_sd_configs:
- names:
- my.domain.com
type: 'A'
port: 9093
2022-02-02 22:26:16 +01:00
```
The list of configured or discovered Notifiers can be explored via [UI ](#Web ).
The configuration file [specification ](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmalert/notifier/config.go )
is the following:
2022-03-22 12:40:55 +01:00
2022-02-02 22:26:16 +01:00
```
# Per-target Notifier timeout when pushing alerts.
[ timeout: < duration > | default = 10s ]
# Prefix for the HTTP path alerts are pushed to.
[ path_prefix: < path > | default = / ]
# Configures the protocol scheme used for requests.
[ scheme: < scheme > | default = http ]
# Sets the `Authorization` header on every request with the
# configured username and password.
# password and password_file are mutually exclusive.
basic_auth:
[ username: < string > ]
[ password: < secret > ]
[ password_file: < string > ]
# Optional `Authorization` header configuration.
authorization:
# Sets the authentication type.
[ type: < string > | default: Bearer ]
# Sets the credentials. It is mutually exclusive with
# `credentials_file` .
[ credentials: < secret > ]
# Sets the credentials to the credentials read from the configured file.
# It is mutually exclusive with `credentials` .
[ credentials_file: < filename > ]
# Configures the scrape request's TLS settings.
# see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#tls_config
tls_config:
[ < tls_config > ]
# List of labeled statically configured Notifiers.
static_configs:
targets:
[ - '< host > ' ]
# List of Consul service discovery configurations.
# See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config
consul_sd_configs:
[ - < consul_sd_config > ... ]
2022-04-13 10:50:26 +02:00
# List of DNS service discovery configurations.
# See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dns_sd_config
dns_sd_configs:
[ - < dns_sd_config > ... ]
2022-04-11 11:11:32 +02:00
# List of relabel configurations for entities discovered via service discovery.
2022-02-02 22:26:16 +01:00
# Supports the same relabeling features as the rest of VictoriaMetrics components.
# See https://docs.victoriametrics.com/vmagent.html#relabeling
relabel_configs:
[ - < relabel_config > ... ]
2022-04-11 11:11:32 +02:00
# List of relabel configurations for alert labels sent via Notifier.
# Supports the same relabeling features as the rest of VictoriaMetrics components.
# See https://docs.victoriametrics.com/vmagent.html#relabeling
alert_relabel_configs:
[ - < relabel_config > ... ]
2022-02-02 22:26:16 +01:00
```
The configuration file can be [hot-reloaded ](#hot-config-reload ).
2021-04-07 12:39:16 +02:00
## Contributing
2020-04-29 16:42:01 +02:00
`vmalert` is mostly designed and built by VictoriaMetrics community.
2021-03-09 21:49:50 +01:00
Feel free to share your experience and ideas for improving this
2020-04-29 16:42:01 +02:00
software. Please keep simplicity as the main priority.
2020-05-15 12:26:51 +02:00
2021-04-07 12:39:16 +02:00
## How to build from sources
2020-05-15 12:26:51 +02:00
2021-03-09 21:49:50 +01:00
It is recommended using
[binary releases ](https://github.com/VictoriaMetrics/VictoriaMetrics/releases )
2020-05-15 12:26:51 +02:00
2022-03-22 12:40:55 +01:00
* `vmalert` is located in `vmutils-*` archives there.
2020-05-15 12:26:51 +02:00
2022-05-23 00:59:34 +02:00
### Docker image
You can build `vmalert` docker image from source and push it to your own docker repository.
Run the following commands from the root folder of [the repository ](https://github.com/VictoriaMetrics/VictoriaMetrics ):
2022-06-19 21:57:53 +02:00
```console
2022-05-23 00:59:34 +02:00
make package-vmalert
docker tag victoria-metrics/vmalert:version my-repo:my-version-name
docker push my-repo:my-version-name
```
To run the built image in `victoria-metrics-k8s-stack` or `VMAlert` CR object apply the following config change:
```yaml
kind: VMAlert
spec:
image:
repository: my-repo
tag: my-version-name
```
2021-04-07 12:39:16 +02:00
### Development build
2020-05-15 12:26:51 +02:00
2022-09-14 12:29:19 +02:00
1. [Install Go ](https://golang.org/doc/install ). The minimum supported version is Go 1.19.1.
2021-03-25 16:14:38 +01:00
2. Run `make vmalert` from the root folder of [the repository ](https://github.com/VictoriaMetrics/VictoriaMetrics ).
2020-05-15 12:26:51 +02:00
It builds `vmalert` binary and puts it into the `bin` folder.
2021-04-07 12:39:16 +02:00
### Production build
2020-05-15 12:26:51 +02:00
1. [Install docker ](https://docs.docker.com/install/ ).
2021-03-25 16:14:38 +01:00
2. Run `make vmalert-prod` from the root folder of [the repository ](https://github.com/VictoriaMetrics/VictoriaMetrics ).
2020-05-15 12:26:51 +02:00
It builds `vmalert-prod` binary and puts it into the `bin` folder.
2020-07-31 08:25:15 +02:00
2021-04-07 12:39:16 +02:00
### ARM build
2020-07-31 08:25:15 +02:00
ARM build may run on Raspberry Pi or on [energy-efficient ARM servers ](https://blog.cloudflare.com/arm-takes-wing/ ).
2021-04-07 12:39:16 +02:00
### Development ARM build
2020-07-31 08:25:15 +02:00
2022-09-14 12:29:19 +02:00
1. [Install Go ](https://golang.org/doc/install ). The minimum supported version is Go 1.19.1.
2022-07-13 15:44:39 +02:00
2. Run `make vmalert-linux-arm` or `make vmalert-linux-arm64` from the root folder of [the repository ](https://github.com/VictoriaMetrics/VictoriaMetrics ).
It builds `vmalert-linux-arm` or `vmalert-linux-arm64` binary respectively and puts it into the `bin` folder.
2020-07-31 08:25:15 +02:00
2021-04-07 12:39:16 +02:00
### Production ARM build
2020-07-31 08:25:15 +02:00
1. [Install docker ](https://docs.docker.com/install/ ).
2022-07-13 15:44:39 +02:00
2. Run `make vmalert-linux-arm-prod` or `make vmalert-linux-arm64-prod` from the root folder of [the repository ](https://github.com/VictoriaMetrics/VictoriaMetrics ).
It builds `vmalert-linux-arm-prod` or `vmalert-linux-arm64-prod` binary respectively and puts it into the `bin` folder.