vmalert executes a list of the given alerting
or recording
rules against configured -datasource.url. For sending alerting notifications
vmalert relies on Alertmanager configured via -notifier.url flag.
Recording rules results are persisted via remote write
protocol and require -remoteWrite.url to be configured.
vmalert is heavily inspired by Prometheus
implementation and aims to be compatible with its syntax.
A single-node
or cluster version
of VictoriaMetrics are capable of proxying requests to vmalert via -vmalert.proxyURL command-line flag.
Use this feature for the following cases:
for accessing vmalert’s UI through VictoriaMetrics Web interface.
VictoriaMetrics Cloud
provides out-of-the-box alerting functionality based on vmalert. This service simplifies the setup
and management of alerting and recording rules as well as the integration with Alertmanager. For more details,
please refer to the VictoriaMetrics Cloud documentation.
vmalert execute queries against remote datasource which has reliability risks because of the network.
It is recommended to configure alerts thresholds and rules expressions with the understanding that network
requests may fail;
vmalert executes rules within a group sequentially, but persistence of execution results to remote
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. See how to chain groups here.
git clone https://github.com/VictoriaMetrics/VictoriaMetrics
cd VictoriaMetrics
make vmalert
The build binary will be placed in VictoriaMetrics/bin folder.
To start using vmalert you will need the following things:
list of rules - PromQL/MetricsQL expressions to execute;
datasource address - reachable endpoint with Prometheus HTTP API support for running queries against;
notifier address [optional] - reachable Alert Manager instance for processing,
aggregating alerts, and sending notifications. Please note, notifier address also supports Consul and DNS Service Discovery via
config file.
remote write address [optional] - remote write
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;
remote read address [optional] - MetricsQL compatible datasource to restore alerts state from.
Then configure vmalert accordingly:
1
2
3
4
5
6
7
8
./bin/vmalert -rule=alert.rules \ # Path to the file with rules configuration. Supports wildcard -datasource.url=http://localhost:8428 \ # Prometheus HTTP API compatible datasource -notifier.url=http://localhost:9093 \ # AlertManager URL (required if alerting rules are used) -notifier.url=http://127.0.0.1:9093 \ # AlertManager replica URL -remoteWrite.url=http://localhost:8428 \ # Remote write compatible storage to persist rules and alerts state info (required if recording rules are used) -remoteRead.url=http://localhost:8428 \ # MetricsQL compatible datasource to restore alerts state from -external.label=cluster=east-1 \ # External label to be applied for each rule -external.label=replica=a # Multiple external labels may be set
Note
To validate the syntax of configured rules simply run vmalert with -rule and -dryRun cmd-line flags.
Note there’s a separate -remoteWrite.url command-line flag to allow writing results of
alerting/recording rules into a different storage than the initial data that’s
queried. This allows using vmalert to aggregate data from a short-term,
high-frequency, high-cardinality storage into a long-term storage with
decreased cardinality and a bigger interval between samples.
See also stream aggregation.
See the full list of configuration flags in configuration section.
If you run multiple vmalert services for the same datastore or AlertManager - do not forget
to specify different -external.label command-line flags in order to define which vmalert generated rules or alerts.
If rule result metrics have label that conflict with -external.label, vmalert will automatically rename
it with prefix exported_.
Configuration for recording
and alerting rules is very
similar to Prometheus rules and configured using YAML. Configuration examples may be found
in testdata folder.
Every rule belongs to a group and every configuration file may contain arbitrary number of groups:
For users of VictoriaMetrics Cloud,
many of the configuration steps (including highly available setup of vmalert for cluster deployments) are handled automatically.
Please, refer to the VictoriaMetrics Cloud documentation for more details.
# The name of the group. Must be unique within a file.name:<string># How often rules in the group are evaluated.[ interval:<duration> | default = -evaluationInterval flag ]# Optional# Group will be evaluated at the exact offset in the range of [0...interval].# E.g. for Group with `interval: 1h` and `eval_offset: 5m` the evaluation will# start at 5th minute of the hour. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3409# `interval` must be specified if `eval_offset` is used, and `eval_offset` cannot exceed `interval`.# `eval_offset` cannot be used with `eval_delay`, as group will be executed at the exact offset and `eval_delay` is ignored.[ eval_offset:<duration> ]# Optional# Adjust the `time` parameter of group evaluation requests to compensate intentional query delay from the datasource.# By default, the value is inherited from the `-rule.evalDelay` cmd-line flag - see its description for details.# If group has `latency_offset` set in `params`, then it is recommended to set `eval_delay` equal to `latency_offset`.# See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5155 and https://docs.victoriametrics.com/keyconcepts/#query-latency.[ eval_delay:<duration> ]# Limit limits the number of alerts or recording results the rule within this group can produce.# On exceeding the limit, rule will be marked with an error and all its results will be discarded.# 0 is no limit.[ limit:<integer> | default 0]# How many rules execute at once within a group. Increasing concurrency may speed# up group's evaluation duration (exposed via `vmalert_iteration_duration_seconds` metric).[ concurrency:<integer> | default = 1 ]# Optional type for expressions inside rules to override the `-rule.defaultRuleType(default is "prometheus")` cmd-line flag.# Supported values: "graphite", "prometheus" and "vlogs"(check https://docs.victoriametrics.com/victorialogs/vmalert/ for details).[ type:<string> ]# Optional# The evaluation timestamp will be aligned with group's interval, # instead of using the actual timestamp that evaluation happens at.## It is enabled by default to get more predictable results # and to visually align with graphs plotted via Grafana or vmui.# When comparing with raw queries, remember to use `step` equal to evaluation interval.## See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5049 # Available starting from v1.95[ eval_alignment:<bool> | default true]# 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-enhancementsparams:[ <string>:[<string>, ...]]# 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>, ...]# Optional list of HTTP headers in form `header-name: value`# applied for all alert notifications sent to notifiers # generated by rules of this group.# It has higher priority over headers defined in notifier config.# For example:# notifier_headers:# - "TenantID: foo"notifier_headers:[<string>, ...]# 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> ... ]rules:[- <rule> ... ]
Every rule contains expr field for PromQL
or MetricsQL expression. vmalert will execute the configured
expression and then act according to the Rule type.
There are two types of Rules:
alerting -
Alerting rules allow defining alert conditions via expr field and to send notifications to
Alertmanager if execution result is not empty.
recording -
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.
vmalert forbids defining duplicates - rules with the same combination of name, expression, and labels
within one group.
# The name of the alert. Must be a valid metric name.alert:<string># The expression to evaluate. The expression language depends on the type value.# By default, PromQL/MetricsQL expression is used. If group.type="graphite", then the expression# must contain valid Graphite expression.expr:<string># Alerts are considered firing once they have been returned for this long.# Alerts which have not yet been fired for long enough are considered pending.# If param is omitted or set to 0 then alerts will be immediately considered# as firing once they return.[ for:<duration> | default = 0s ]# Alert will continue firing for this long even when the alerting expression no longer has results.# This allows you to delay alert resolution.[ keep_firing_for:<duration> | default = 0s ]# 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.# Logs are printed with INFO level, so make sure that -loggerLevel=INFO to see the output.[ debug:<bool> | default = false ]# Defines the number of rule's updates entries stored in memory# and available for view on rule's Details page.# Overrides `rule.updateEntriesLimit` value for this specific rule.# Available starting from https://docs.victoriametrics.com/changelog/#v1860[ update_entries_limit:<integer> | default 0 ]# Labels to add or overwrite for each alert.# In case of conflicts, original labels are kept with prefix `exported_`.labels:[ <labelname>:<tmpl_string> ]# Annotations to add to each alert.annotations:[ <labelname>:<tmpl_string> ]
It is allowed to use Go templating in annotations to format data, iterate over
or execute expressions.
The following variables are available in templating:
Variable
Description
Example
$value or .Value
The current alert’s value. Avoid using value in labels, it may cause unexpected issues.
Number of connections is {{ $value }}
$activeAt or .ActiveAt
The moment of time when alert became active (pending or firing).
vmalert provides the following template functions, which can be used during templating:
args arg0 ... argN - converts the input args into a map with arg0, …, argN keys.
externalURL - returns the value of -external.url command-line flag.
first - returns the first result from the input query results returned by query function.
htmlEscape - escapes special chars in input string, so it can be safely embedded as a plaintext into HTML.
humanize - converts the input number into human-readable format by adding metric prefixes.
For example, 100000 is converted into 100K.
humanize1024 - converts the input number into human-readable format with 1024 base.
For example, 1024 is converted into 1ki`.
humanizeDuration - converts the input number in seconds into human-readable duration.
humanizePercentage - converts the input number to percentage. For example, 0.123 is converted into 12.3%.
humanizeTimestamp - converts the input unix timestamp into human-readable time.
jsonEscape - JSON-encodes the input string.
label name - returns the value of the label with the given name from the input query result.
match regex - matches the input string against the provided regex.
parseDuration - parses the input string into duration in seconds. For example, 1h is parsed into 3600.
parseDurationTime - parses the input string into time.Duration.
pathEscape - escapes the input string, so it can be safely put inside path part of URL.
pathPrefix - returns the path part of the -external.url command-line flag.
query - executes the MetricsQL query against -datasource.url and returns the query result.
For example, {{ query "sort_desc(process_resident_memory_bytes)" | first | value }} executes the sort_desc(process_resident_memory_bytes)
query at -datasource.url and returns the first result.
queryEscape - escapes the input string, so it can be safely put inside query arg part of URL.
quotesEscape - escapes the input string, so it can be safely embedded into JSON string.
reReplaceAll regex repl - replaces all the occurrences of the regex in input string with the repl.
safeHtml - marks the input string as safe to use in HTML context without the need to html-escape it.
sortByLabel name - sorts the input query results by the label with the given name.
stripDomain - leaves the first part of the domain. For example, foo.bar.baz is converted to foo.
The port part is left in the output string. E.g. foo.bar:1234 is converted into foo:1234.
stripPort - strips port part from host:port input string.
strvalue - returns the metric name from the input query result.
title - converts the first letters of every input word to uppercase.
toLower - converts all the chars in the input string to lowercase.
toTime - converts the input unix timestamp to time.Time.
toUpper - converts all the chars in the input string to uppercase.
value - returns the numeric value from the input query result.
Like in Alertmanager you can define reusable templates
to share same templates across annotations. Just define the templates in a file and
set the path via -rule.templates flag.
For example, template grafana.filter can be defined as following:
# The name of the time series to output to. Must be a valid metric name.record:<string># The expression to evaluate. The expression language depends on the type value.# By default, MetricsQL expression is used. If group.type="graphite", then the expression# must contain valid Graphite expression.expr:<string># Labels to add or overwrite before storing the result.# In case of conflicts, original labels are kept with prefix `exported_`.labels:[ <labelname>:<labelvalue> ]# Whether to print debug information into logs.# Information includes requests sent to the datasource.# information - it will be printed to logs.# Logs are printed with INFO level, so make sure that -loggerLevel=INFO to see the output.[ debug:<bool> | default = false ]# Defines the number of rule's updates entries stored in memory# and available for view on rule's Details page.# Overrides `rule.updateEntriesLimit` value for this specific rule.[ update_entries_limit:<integer> | default 0 ]
For recording rules to work -remoteWrite.url must be specified.
vmalert holds alerts state in the memory. Restart of the vmalert process will reset the state of all active alerts
in the memory. To prevent vmalert from losing the state on restarts configure it to persist the state
to the remote database via the following flags:
-remoteWrite.url - URL to VictoriaMetrics (Single) or vminsert (Cluster). vmalert will persist alerts state
to the configured address in the form of time seriesALERTS and ALERTS_FOR_STATE via remote-write protocol.
These time series can be queried from VictoriaMetrics just as any other time series.
The state will be persisted to the configured address on each evaluation.
-remoteRead.url - URL to VictoriaMetrics (Single) or vmselect (Cluster). vmalert will try to restore alerts state
from the configured address by querying time series with name ALERTS_FOR_STATE. The restore happens only once when
vmalert process starts, and only for the configured rules. Config hot reload doesn’t trigger
state restore.
Both flags are required for proper state restoration. Restore process may fail if time series are missing
in configured -remoteRead.url, weren’t updated in the last 1h (controlled by -remoteRead.lookback)
or received state doesn’t match current vmalert rules configuration. vmalert marks successfully restored rules
with restored label in web UI.
Alerting notifications sent by vmalert always contain a source link. By default, the link format
is the following http://<vmalert-addr>/vmalert/alert?group_id=<group_id>&alert_id=<alert_id>. On click, it opens
vmalert web UI to show the alert status and its fields.
It is possible to override the link format. For example, to make the link to vmui
specify the following cmd-line flags:
1
2
3
./bin/vmalert \
-external.url=http://<vmui-addr> \ # the hostname and port for datasource vmui
-external.alert.source='vmui/#/?g0.expr={{.Expr|queryEscape}}' # the path built using alert expr
Now, all source links will lead to http://<vmui-addr>/vmui/#/?g0.expr=$expr, where $expr is an alerting rule
expression.
The -external.alert.source cmd-line flag supports templating
and allows using labels and extra data related to the alert. For example, see the following link to Grafana:
1
2
3
./bin/vmalert \
-external.url=http://<grafana-addr> \ # the hostname and port for Grafana
-external.alert.source='explore?left={"datasource":"VictoriaMetrics","queries":[{"expr":{{ .Expr|jsonEscape|queryEscape }},"refId":"A"}],"range":{"from":"{{ .ActiveAt.UnixMilli }}","to":"now"}}'
In this example, -external.alert.source will lead to Grafana’s Explore page with expr field equal to alert expression,
and time range will be selected starting from "from":"{{ .ActiveAt.UnixMilli }}" when alert became active.
In addition to source link, some extra links could be added to alert’s annotations
field. See how we use them
to link alerting rule and the corresponding panel on Grafana dashboard.
There are the following approaches exist for alerting and recording rules across
multiple tenants:
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.
For example, /path/to/vmalert -datasource.url=http://vmselect:8481/select/123/prometheus
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
rules to AccountID=123.
To use the multitenant endpointAvailable from v1.104.0of vminsert as
the -remoteWrite.url and vmselect as the -datasource.url, add extra_label with tenant ID as an HTTP URL parameter for each group.
For example, run vmalert using -datasource.url=http://vmselect:8481/select/multitenant/prometheus -remoteWrite.url=http://vminsert:8480/insert/multitenant/prometheus,
along with the rule group:
1
2
3
4
5
6
groups:- name:rules_for_tenant_456:789params:extra_label:[vm_account_id=456,vm_project_id=789]rules:# Rules for accountID=456, projectID=789
For security considerations, it is recommended restricting access to multitenant endpoints only to trusted sources, since untrusted source may break per-tenant data by writing unwanted samples or get access to data of arbitrary tenants.
To specify tenant parameter per each alerting and recording group if
enterprise version of vmalert is used
with -clusterMode command-line flag. For example:
1
2
3
4
5
6
7
8
9
10
groups:- name:rules_for_tenant_123tenant:"123"rules:# Rules for accountID=123- name:rules_for_tenant_456:789tenant:"456:789"rules:# Rules for accountID=456, projectID=789
The results of alerting and recording rules contain vm_account_id and vm_project_id labels
if -clusterMode is enabled. These labels can be used during templating,
and help to identify to which account or project the triggered alert or produced recording belongs.
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.
vmalert automatically adds the specified tenant to urls per each recording rule in this case.
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.
The enterprise version of vmalert is available in vmutils-*-enterprise.tar.gz files
at release page and in *-enterprise
tags at Docker Hub and Quay.
The simplest configuration where one single-node VM server is used for
rules execution, storing recording rules results and alerts state.
vmalert configuration flags:
1
2
3
4
5
./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
In cluster mode
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.
Cluster mode could have multiple vminsert and vmselect components.
vmalert configuration flags:
1
2
3
4
5
./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
-remoteWrite.url=http://vminsert:8480/insert/0/prometheus # vminsert addr to persist alerts state and recording rules results
-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
In case when you want to spread the load on these components - add balancers before them and configure
vmalert with balancer addresses. Please, see more about VM’s cluster architecture
here.
For High Availability(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.
vmalert configuration flags:
1
2
3
4
5
6
./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
To avoid recording rules results and alerts state duplication in VictoriaMetrics server
don’t forget to configure deduplication.
Multiple equally configured vmalerts should evaluate rules at the same timestamps, so it is recommended
to set -dedup.minScrapeInterval as equal to vmalert’s -evaluationInterval.
If you have multiple different interval params for distinct rule groups, then set -dedup.minScrapeInterval to
the biggest interval value, or value which will be a multiple for all interval values. For example, if you have
two groups with interval: 10s and interval: 15s, then set -dedup.minScrapeInterval=30s. This would consistently
keep only a single data point on 30s time interval for all rules. However, try to avoid having inconsistent interval
values.
It is not recommended having -dedup.minScrapeInterval smaller than -evaluationInterval, as it may produce
results with inconsistent intervals between data points.
Alertmanager will automatically deduplicate alerts with identical labels, so ensure that
all vmalerts are having identical config.
Don’t forget to configure cluster mode
for Alertmanagers for better reliability. List all Alertmanager URLs in vmalert -notifier.url
to ensure high availability.
This example uses single-node VM server for the sake of simplicity.
Check how to replace it with cluster VictoriaMetrics if needed.
Please note, stream aggregation might be more efficient
for cases when downsampling or aggregation need to be applied before data gets into the TSDB.
vmalert can’t modify existing data. But it can run arbitrary PromQL/MetricsQL queries
via 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:
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’sinterval 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:
Ability of vmalert to be configured with different -datasource.url and -remoteWrite.url command-line flags
allows reading data from one data source and backfilling results to another. This helps to build a system
for aggregating and downsampling the data.
The following example shows how to build a topology where vmalert will process data from one cluster
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.
vmalert configuration flags:
1
2
3
./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 recording rules expressions
-remoteWrite.url=http://aggregated-cluster-vminsert:8480/insert/0/prometheus # vminsert addr to persist recording rules results
Please note, replay feature may be used for transforming historical data.
Flags -remoteRead.url and -notifier.url are omitted since we assume only recording rules are used.
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 as fan-out proxy:
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,
or time series modification via relabeling.
vmalert runs a web-server (-httpListenAddr) for serving metrics and alerts endpoints:
http://<vmalert-addr> - UI;
http://<vmalert-addr>/api/v1/rules - list of all loaded groups and rules. Supports additional filtering;
http://<vmalert-addr>/api/v1/alerts - list of all active alerts;
http://<vmalert-addr>/vmalert/api/v1/alert?group_id=<group_id>&alert_id=<alert_id> - get alert status in JSON format.
Used as alert source in AlertManager.
http://<vmalert-addr>/vmalert/alert?group_id=<group_id>&alert_id=<alert_id> - get alert status in web UI.
http://<vmalert-addr>/vmalert/rule?group_id=<group_id>&rule_id=<rule_id> - get rule status in web UI.
http://<vmalert-addr>/vmalert/api/v1/rule?group_id=<group_id>&alert_id=<alert_id> - get rule status in JSON format.
vmalert sends requests to <-datasource.url>/render?format=json during evaluation of alerting and recording rules
if the corresponding group or rule contains type: "graphite" config option. It is expected that the <-datasource.url>/render
implements Graphite Render API for format=json.
When using vmalert with both graphite and prometheus rules configured against cluster version of VM do not forget
to set -datasource.appendTypePrefix flag to true, so vmalert can adjust URL prefix automatically based on the query type.
vmalert supports alerting and recording rules backfilling (aka replay). In replay mode vmalert
can read the same rules configuration as normal, evaluate them on the given time range and backfill
results via remote write to the configured storage. vmalert supports any PromQL/MetricsQL compatible
data source for backfilling.
Please note, that response caching may lead to unexpected results during and after backfilling process.
In order to avoid this you need to reset cache contents or disable caching when using backfilling
as described in backfilling docs.
In replay mode vmalert works as a cli-tool and exits immediately after work is done.
To run vmalert in replay mode:
1
2
3
4
5
./bin/vmalert -rule=path/to/your.rules \ # path to files with rules you usually use with vmalert
-datasource.url=http://localhost:8428 \ # Prometheus HTTP API compatible datasource
-remoteWrite.url=http://localhost:8428 \ # remote write compatible storage to persist results
-replay.timeFrom=2021-05-11T07:21:43Z \ # to start replay from
-replay.timeTo=2021-05-29T18:40:43Z # to finish replay by, is optional
The output of the command will look like the following:
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
to /query_range endpoint
of the configured -datasource.url. Returned data is then processed according to the rule type and
backfilled to -remoteWrite.url via remote Write protocol.
vmalert respects evaluationInterval value set by flag or per-group during the replay.
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.
The result of alerting rules replay is time series reflecting alert’s state.
To see if replayed alert has fired in the past use the following PromQL/MetricsQL expression:
-replay.maxDatapointsPerQuery - the max number of data points expected to receive in one request.
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.
-replay.ruleRetryAttempts - when datasource fails to respond vmalert will make this number of retries
per rule before giving up.
-replay.rulesDelay - delay between sequential rules execution. Important in cases if there are chaining
(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.
-replay.disableProgressBar - whether to disable progress bar which shows progress work.
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.
See full description for these flags in ./vmalert -help.
vmalert exports various metrics in Prometheus exposition format at http://vmalert-host:8880/metrics page.
The default list of alerting rules for these metric can be found here.
We recommend setting up regular scraping of this page either through vmagent or by Prometheus-compatible scraper,
so that the exported metrics may be analyzed later.
If you use Google Cloud Managed Prometheus for scraping metrics from VictoriaMetrics components, then pass -metrics.exposeMetadata
command-line to them, so they add TYPE and HELP comments per each exposed metric at /metrics page.
See these docs for details.
Use the official Grafana dashboard for vmalert overview.
Graphs on this dashboard contain useful hints - hover the i icon in the top left corner of each graph in order to read it.
If you have suggestions for improvements or have found a bug - please open an issue on github or add
a review to the dashboard.
Data delay is one of the most common issues with rules execution.
vmalert executes configured rules within certain intervals at specifics timestamps.
It expects that the data is already present in configured -datasource.url at the moment of time when rule is executed:
Usually, troubles start to appear when data in -datasource.url is delayed or absent. In such cases, evaluations
may get empty response from the datasource and produce empty recording rules or reset alerts state:
Try the following recommendations to reduce the chance of hitting the data delay issue:
Always configure group’s -evaluationInterval to be bigger or at least equal to
time series resolution;
Ensure that [duration] value is at least twice bigger than
time series resolution. For example,
if expression is rate(my_metric[2m]) > 0 then ensure that my_metric resolution is at least 1m or better 30s.
Extend [duration] in expr to help tolerate the delay. For example, max_over_time(errors_total[10m]) > 0 will be active even if there is no data in datasource for last 9m.
If time series resolution
in datasource is inconsistent or >=5min - try changing vmalerts -datasource.queryStep command-line flag to specify
how far search query can look back for the recent datapoint. The recommendation is to have the step
at least two times bigger than the resolution.
Note
Please note, data delay is inevitable in distributed systems. And it is better to account for it instead of ignoring.
By default, recently written samples to VictoriaMetrics aren’t visible for queries
for up to 30s (see -search.latencyOffset command-line flag at vmselect or VictoriaMetrics single-node). Such delay is needed to eliminate risk of
incomplete data on the moment of querying, due to chance that metrics collectors won’t be able to deliver that data in time.
To compensate the latency in timestamps for produced evaluation results, -rule.evalDelay is also set to 30s by default.
If you expect data to be delayed for longer intervals (it gets buffered, queued, or just network is slow sometimes),
or you changed default value of -search.latencyOffset - consider increasing the -rule.evalDelay value accordingly.
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 or Grafana to track how alerts state
changed in time.
vmalert stores last -rule.updateEntriesLimit (or update_entries_limitper-rule config)
state updates for each rule starting from v1.86.
To check updates, click on Details link next to rule’s name on /vmalert/groups page
and check the Last updates section:
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. Sensitive info is stripped from the curl examples - see security section
for more details.
vmalert allows configuring more detailed logging for specific alerting or recording rule starting from Available from v1.115.0.
Just set debug: true in rule’s configuration and vmalert will start printing additional log messages:
1
2
3
4
5
6
7
8
2022-09-15T13:35:41.155Z DEBUG alerting rule "TestGroup":"Conns" (2601299393013563564) at 2022-09-15T15:35:41+02:00: query returned 0 samples (elapsed: 5.896041ms, isPartial: false)
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 alerting rule "TestGroup":"Conns" (2601299393013563564) at 2022-09-15T15:35:56+02:00: query returned 1 samples (elapsed: 28.368208ms, isPartial: false)
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 alerting 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 alerting 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
Sensitive info is stripped from the curl examples - see security section for more details.
vmalert can detectAvailable from v1.91.0if alert’s expression doesn’t match any time series in runtime
starting from v1.91. This problem usually happens
when alerting expression selects time series which aren’t present in the datasource (i.e. wrong job label)
or there is a typo in the series selector (i.e. env=prod). Such alerting rules will be marked with special icon in
vmalerts UI and exposed via vmalert_alerting_rules_last_evaluation_series_fetched metric. The metric value will
show how many time series were matched before the filtering by rule’s expression. If metric value is -1, then
this feature is not supported by the datasource (old versions of VictoriaMetrics). The following expression can be
used to detect rules matching no series:
As label __name__ will be dropped during evaluation, leads to duplicated time series.
To fix this, one could use function like label_replace to preserve the distinct labelset.
By default vmalert accepts http requests at 8880 port (this port can be changed via -httpListenAddr command-line flags),
since it is expected it runs in an isolated trusted network.
Enterprise version of vmagent supports the ability to accept mTLS
requests at this port, by specifying -tls and -mtls command-line flags. For example, the following command runs vmalert, which accepts only mTLS requests at port 8880:
1
./vmalert -tls -mtls -remoteWrite.url=...
By default system-wide TLS Root CA is used for verifying client certificates if -mtls command-line flag is specified.
It is possible to specify custom TLS Root CA via -mtlsCAFile command-line flag.
See general recommendations regarding security here.
vmalert web UI exposes configuration details such as list of Groups, active alerts,
alerts state, notifiers. Notifier addresses (sanitized) are attached
as labels to metrics vmalert_alerts_sent_.* on http://<vmalert>/metrics page. Consider limiting user’s access
to the web UI or /metrics page if this information is sensitive.
Alerts state page or debug mode could emit additional information about configured
datasource URL, GET params and headers. Sensitive information such as passwords or auth tokens is stripped by default.
To disable stripping of such info pass -datasource.showURL cmd-line flag to vmalert.
The command for collecting CPU profile waits for 30 seconds before returning.
The collected profiles may be analyzed with go tool pprof.
It is safe sharing the collected profiles from security point of view, since they do not contain sensitive information.
-clusterModeIfclusterModeisenabled,thenvmalertautomaticallyaddsthetenantspecifiedinconfiggroupsto-datasource.url,-remoteWrite.urland-remoteRead.url.Seehttps://docs.victoriametrics.com/vmalert/#multitenancy . This flag is available only in Enterprise binaries. See https://docs.victoriametrics.com/enterprise/-configCheckIntervaldurationIntervalforcheckingforchangesin'-rule'or'-notifier.config'files.Bydefault,thecheckingisdisabled.SendSIGHUPsignalinordertoforceconfigcheckforchanges.-datasource.appendTypePrefixWhethertoaddtypeprefixto-datasource.urlbasedonthequerytype.SettotrueifsendingdifferentquerytypestothevmselectURL.-datasource.basicAuth.passwordstringOptionalbasicauthpasswordfor-datasource.url-datasource.basicAuth.passwordFilestringOptionalpathtobasicauthpasswordtousefor-datasource.url-datasource.basicAuth.usernamestringOptionalbasicauthusernamefor-datasource.url-datasource.bearerTokenstringOptionalbearerauthtokentousefor-datasource.url.-datasource.bearerTokenFilestringOptionalpathtobearertokenfiletousefor-datasource.url.-datasource.disableKeepAliveWhethertodisablelong-livedconnectionstothedatasource.Iftrue,disablesHTTPkeep-aliveandwillonlyusetheconnectiontotheserverforasingleHTTPrequest.-datasource.disableStepParamWhethertodisableadding'step'paramininstantqueriestotheconfigured-datasource.urland-remoteRead.url.Onlyvalidforprometheusdatasource.Thismightbeusefulwhenusingvmalertwithdatasourcesthatdonotsupport'step'paramforinstantqueries,likeGoogleManagedPrometheus.ItisnotrecommendedtoenablethisflagifyouusevmalertwithVictoriaMetrics.-datasource.headersstringOptionalHTTPextraHeaderstosendwitheachrequesttothecorresponding-datasource.url.Forexample,-datasource.headers='My-Auth:foobar'wouldsend'My-Auth: foobar'HTTPheaderwitheveryrequesttothecorresponding-datasource.url.Multipleheadersmustbedelimitedby'^^':-datasource.headers='header1:value1^^header2:value2'-datasource.idleConnTimeoutdurationDefinesadurationforidle(keep-aliveconnections)toexist.Considersettingsthisvaluelesstothevalueof"-http.idleConnTimeout".Itmustpreventpossible"write: broken pipe"and"read: connection reset by peer"errors.(default50s)-datasource.maxIdleConnectionsintDefinesthenumberofidle(keep-aliveconnections)toeachconfigureddatasource.Considersettingthisvalueequaltothevalue:groups_total*group.concurrency.ToolowavaluemayresultinahighnumberofsocketsinTIME_WAITstate.(default100)-datasource.oauth2.clientIDstringOptionalOAuth2clientIDtousefor-datasource.url-datasource.oauth2.clientSecretstringOptionalOAuth2clientSecrettousefor-datasource.url-datasource.oauth2.clientSecretFilestringOptionalOAuth2clientSecretFiletousefor-datasource.url-datasource.oauth2.endpointParamsstringOptionalOAuth2endpointparameterstousefor-datasource.url.TheendpointparametersmustbesetinJSONformat:{"param1":"value1",...,"paramN":"valueN"}-datasource.oauth2.scopesstringOptionalOAuth2scopestousefor-datasource.url.Scopesmustbedelimitedby';'-datasource.oauth2.tokenUrlstringOptionalOAuth2tokenURLtousefor-datasource.url-datasource.queryStepdurationHowfaravaluecanfallbacktowhenevaluatingqueriestotheconfigured-datasource.urland-remoteRead.url.Onlyvalidforprometheusdatasource.Forexample,if-datasource.queryStep=15sthenparam"step"withvalue"15s"willbeaddedtoeveryquery.Ifsetto0,rule's evaluation interval will be used instead. (default 5m0s)-datasource.roundDigitsintAdds"round_digits"GETparamtodatasourcerequestswhichlimitsthenumberofdigitsafterthedecimalpointinresponsevalues.OnlyvalidforVictoriaMetricsasthedatasource.-datasource.showURLWhethertoavoidstrippingsensitiveinformationsuchasauthheadersorpasswordsfromURLsinlogmessagesorUIandexportedmetrics.Itishiddenbydefault,sinceitcancontainsensitiveinfosuchasauthkey-datasource.tlsCAFilestringOptionalpathtoTLSCAfiletouseforverifyingconnectionsto-datasource.url.Bydefault,systemCAisused-datasource.tlsCertFilestringOptionalpathtoclient-sideTLScertificatefiletousewhenconnectingto-datasource.url-datasource.tlsInsecureSkipVerifyWhethertoskiptlsverificationwhenconnectingto-datasource.url-datasource.tlsKeyFilestringOptionalpathtoclient-sideTLScertificatekeytousewhenconnectingto-datasource.url-datasource.tlsServerNamestringOptionalTLSservernametouseforconnectionsto-datasource.url.Bydefault,theservernamefrom-datasource.urlisused-datasource.urlstringDatasourcecompatiblewithPrometheusHTTPAPI.ItcanbesinglenodeVictoriaMetricsorvmselectURL.Requiredparameter.SupportsaddressintheformofIPaddresswithaport(e.g.,http://127.0.0.1:8428)orDNSSRVrecord.Seealso-remoteRead.disablePathAppendand-datasource.showURL-defaultTenant.graphitestringDefaulttenantforGraphitealertinggroups.Seehttps://docs.victoriametrics.com/vmalert/#multitenancy .This flag is available only in Enterprise binaries. See https://docs.victoriametrics.com/enterprise/-defaultTenant.prometheusstringDefaulttenantforPrometheusalertinggroups.Seehttps://docs.victoriametrics.com/vmalert/#multitenancy . This flag is available only in Enterprise binaries. See https://docs.victoriametrics.com/enterprise/-disableAlertgroupLabelWhethertodisableaddinggroup's Name as label to generated alerts and time series.-dryRunWhethertocheckonlyconfigfileswithoutrunningvmalert.Therulesfilearevalidated.The-ruleflagmustbespecified.-enableTCP6WhethertoenableIPv6forlisteninganddialing.Bydefault,onlyIPv4TCPandUDPareused-envflag.enableWhethertoenablereadingflagsfromenvironmentvariablesinadditiontothecommandline.Commandlineflagvalueshavepriorityovervaluesfromenvironmentvars.Flagsarereadonlyfromthecommandlineifthisflagisn't set. See https://docs.victoriametrics.com/#environment-variables for more details-envflag.prefixstringPrefixforenvironmentvariablesif-envflag.enableisset-eulaDeprecated,pleaseuse-licenseor-licenseFileflagsinstead.Byspecifyingthisflag,youconfirmthatyouhaveanenterpriselicenseandaccepttheESAhttps://victoriametrics.com/legal/esa/.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-evaluationIntervaldurationHowoftentoevaluatetherules(default1m0s)-external.alert.sourcestringExternalAlertSourceallowstooverridetheSourcelinkforalertssenttoAlertManagerforcaseswhereyouwanttobuildacustomlinktoGrafana,Prometheusoranyotherservice.Supportstemplating-seehttps://docs.victoriametrics.com/vmalert/#templating . For example, link to Grafana: -external.alert.source='explore?orgId=1&left={"datasource":"VictoriaMetrics","queries":[{"expr":{{.Expr|jsonEscape|queryEscape}},"refId":"A"}],"range":{"from":"now-1h","to":"now"}}'. Link to VMUI: -external.alert.source='vmui/#/?g0.expr={{.Expr|queryEscape}}'. If empty 'vmalert/alert?group_id={{.GroupID}}&alert_id={{.AlertID}}' is used.-external.labelarrayOptionallabelintheform'Name=value'toaddtoallgeneratedrecordingrulesandalerts.Incaseofconflicts,originallabelsarekeptwithprefix`exported_`.Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-external.urlstringExternalURLisusedasalert's source for sent alerts to the notifier. By default, hostname is used as address.-filestream.disableFadviseWhethertodisablefadvise()syscallwhenreadinglargedatafiles.Thefadvise()syscallpreventsfromevictionofrecentlyaccesseddatafromOSpagecacheduringbackgroundmergesandbackups.InsomerarecasesitisbettertodisablethesyscallifitusestoomuchCPU-flagsAuthKeyvalueAuthkeyfor/flagsendpoint.ItmustbepassedviaauthKeyqueryarg.Itoverrides-httpAuth.*Flagvaluecanbereadfromthegivenfilewhenusing-flagsAuthKey=file:///abs/path/to/fileor-flagsAuthKey=file://./relative/path/to/file.Flagvaluecanbereadfromthegivenhttp/httpsurlwhenusing-flagsAuthKey=http://host/pathor-flagsAuthKey=https://host/path-fs.disableMmapWhethertousepread()insteadofmmap()forreadingdatafiles.Bydefault,mmap()isusedfor64-bitarchesandpread()isusedfor32-bitarches,sincetheycannotreaddatafilesbiggerthan2^32bytesinmemory.mmap()isusuallyfasterforreadingsmalldatachunksthanpread()-http.connTimeoutdurationIncomingconnectionsto-httpListenAddrareclosedaftertheconfiguredtimeout.ThismayhelpevenlyspreadingloadamongaclusterofservicesbehindTCP-levelloadbalancer.Zerovaluedisablesclosingofincomingconnections(default2m0s)-http.disableResponseCompressionDisablecompressionofHTTPresponsestosaveCPUresources.Bydefault,compressionisenabledtosavenetworkbandwidth-http.header.cspstringValuefor'Content-Security-Policy'header,recommended:"default-src 'self'"-http.header.frameOptionsstringValuefor'X-Frame-Options'header-http.header.hstsstringValuefor'Strict-Transport-Security'header,recommended:'max-age=31536000; includeSubDomains'-http.idleConnTimeoutdurationTimeoutforincomingidlehttpconnections(default1m0s)-http.maxGracefulShutdownDurationdurationThemaximumdurationforagracefulshutdownoftheHTTPserver.Ahighlyloadedservermayrequireincreasedvalueforagracefulshutdown(default7s)-http.pathPrefixstringAnoptionalprefixtoaddtoallthepathshandledbyhttpserver.Forexample,if'-http.pathPrefix=/foo/bar'isset,thenallthehttprequestswillbehandledon'/foo/bar/*'paths.Thismaybeusefulforproxiedrequests.Seehttps://www.robustperception.io/using-external-urls-and-proxies-with-prometheus-http.shutdownDelaydurationOptionaldelaybeforehttpservershutdown.Duringthisdelay,theserverreturnsnon-OKresponsesfrom/healthpage,soloadbalancerscanroutenewrequeststootherservers-httpAuth.passwordvaluePasswordforHTTPserver's Basic Auth. The authentication is disabled if -httpAuth.username is emptyFlagvaluecanbereadfromthegivenfilewhenusing-httpAuth.password=file:///abs/path/to/fileor-httpAuth.password=file://./relative/path/to/file.Flagvaluecanbereadfromthegivenhttp/httpsurlwhenusing-httpAuth.password=http://host/pathor-httpAuth.password=https://host/path-httpAuth.usernamestringUsernameforHTTPserver's Basic Auth. The authentication is disabled if empty. See also -httpAuth.password-httpListenAddrarrayAddresstolistenforincominghttprequests.Seealso-tlsand-httpListenAddr.useProxyProtocolSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-httpListenAddr.useProxyProtocolarrayWhethertouseproxyprotocolforconnectionsacceptedatthecorresponding-httpListenAddr.Seehttps://www.haproxy.org/download/1.8/doc/proxy-protocol.txt.Withenabledproxyprotocolhttpservercannotserveregular/metricsendpoint.Use-pushmetrics.urlformetricspushingSupportsarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Emptyvaluesaresettofalse.-internStringCacheExpireDurationdurationTheexpirydurationforcachesforinternedstrings.Seehttps://en.wikipedia.org/wiki/String_interning.Seealso-internStringMaxLenand-internStringDisableCache(default6m0s)-internStringDisableCacheWhethertodisablecachesforinternedstrings.ThismayreducememoryusageatthecostofhigherCPUusage.Seehttps://en.wikipedia.org/wiki/String_interning.Seealso-internStringCacheExpireDurationand-internStringMaxLen-internStringMaxLenintThemaximumlengthforstringstointern.AlowerlimitmaysavememoryatthecostofhigherCPUusage.Seehttps://en.wikipedia.org/wiki/String_interning.Seealso-internStringDisableCacheand-internStringCacheExpireDuration(default500)-licensestringLicensekeyforVictoriaMetricsEnterprise.Seehttps://victoriametrics.com/products/enterprise/.TrialEnterpriselicensecanbeobtainedfromhttps://victoriametrics.com/products/enterprise/trial/.ThisflagisavailableonlyinEnterprisebinaries.Thelicensekeycanbealsopassedviafilespecifiedby-licenseFilecommand-lineflag-license.forceOfflineWhethertoenableofflineverificationforVictoriaMetricsEnterpriselicensekey,whichhasbeenpassedeithervia-licenseorvia-licenseFilecommand-lineflag.Theissuedlicensekeymustsupportofflineverificationfeature.Contactinfo@victoriametrics.comifyouneedofflinelicenseverification.ThisflagisavailableonlyinEnterprisebinaries-licenseFilestringPathtofilewithlicensekeyforVictoriaMetricsEnterprise.Seehttps://victoriametrics.com/products/enterprise/.TrialEnterpriselicensecanbeobtainedfromhttps://victoriametrics.com/products/enterprise/trial/.ThisflagisavailableonlyinEnterprisebinaries.Thelicensekeycanbealsopassedinlinevia-licensecommand-lineflag-loggerDisableTimestampsWhethertodisablewritingtimestampsinlogs-loggerErrorsPerSecondLimitintPer-secondlimitonthenumberofERRORmessages.Ifmorethanthegivennumberoferrorsareemittedpersecond,theremainingerrorsaresuppressed.Zerovaluesdisabletheratelimit-loggerFormatstringFormatforlogs.Possiblevalues:default,json(default"default")-loggerJSONFieldsstringAllowsrenamingfieldsinJSONformattedlogs.Example:"ts:timestamp,msg:message"renames"ts"to"timestamp"and"msg"to"message".Supportedfields:ts,level,caller,msg-loggerLevelstringMinimumleveloferrorstolog.Possiblevalues:INFO,WARN,ERROR,FATAL,PANIC(default"INFO")-loggerMaxArgLenintThemaximumlengthofasingleloggedargument.Longerargumentsarereplacedwith'arg_start..arg_end',where'arg_start'and'arg_end'isprefixandsuffixoftheargwiththelengthnotexceeding-loggerMaxArgLen/2(default1000)-loggerOutputstringOutputforthelogs.Supportedvalues:stderr,stdout(default"stderr")-loggerTimezonestringTimezonetousefortimestampsinlogs.TimezonemustbeavalidIANATimeZone.Forexample:America/New_York,Europe/Berlin,Etc/GMT+3orLocal(default"UTC")-loggerWarnsPerSecondLimitintPer-secondlimitonthenumberofWARNmessages.Ifmorethanthegivennumberofwarnsareemittedpersecond,thentheremainingwarnsaresuppressed.Zerovaluesdisabletheratelimit-memory.allowedBytessizeAllowedsizeofsystemmemoryVictoriaMetricscachesmayoccupy.Thisoptionoverrides-memory.allowedPercentifsettoanon-zerovalue.ToolowavaluemayincreasethecachemissrateusuallyresultinginhigherCPUanddiskIOusage.ToohighavaluemayevicttoomuchdatafromtheOSpagecacheresultinginhigherdiskIOusageSupportsthefollowingoptionalsuffixesforsizevalues:KB,MB,GB,TB,KiB,MiB,GiB,TiB(default0)-memory.allowedPercentfloatAllowedpercentofsystemmemoryVictoriaMetricscachesmayoccupy.Seealso-memory.allowedBytes.ToolowavaluemayincreasecachemissrateusuallyresultinginhigherCPUanddiskIOusage.ToohighavaluemayevicttoomuchdatafromtheOSpagecachewhichwillresultinhigherdiskIOusage(default60)-metrics.exposeMetadataWhethertoexposeTYPEandHELPmetadataatthe/metricspage,whichisexposedat-httpListenAddr.Themetadatamaybeneededwhenthe/metricspageisconsumedbysystems,whichrequirethisinformation.Forexample,ManagedPrometheusinGoogleCloud-https://cloud.google.com/stackdriver/docs/managed-prometheus/troubleshooting#missing-metric-type-metricsAuthKeyvalueAuthkeyfor/metricsendpoint.ItmustbepassedviaauthKeyqueryarg.Itoverrides-httpAuth.*Flagvaluecanbereadfromthegivenfilewhenusing-metricsAuthKey=file:///abs/path/to/fileor-metricsAuthKey=file://./relative/path/to/file.Flagvaluecanbereadfromthegivenhttp/httpsurlwhenusing-metricsAuthKey=http://host/pathor-metricsAuthKey=https://host/path-mtlsarrayWhethertorequirevalidclientcertificateforhttpsrequeststothecorresponding-httpListenAddr.Thisflagworksonlyif-tlsflagisset.Seealso-mtlsCAFile.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/Supportsarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Emptyvaluesaresettofalse.-mtlsCAFilearrayOptionalpathtoTLSRootCAforverifyingclientcertificatesatthecorresponding-httpListenAddrwhen-mtlsisenabled.BydefaultthehostsystemTLSRootCAisusedforclientcertificateverification.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.basicAuth.passwordarrayOptionalbasicauthpasswordfor-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.basicAuth.passwordFilearrayOptionalpathtobasicauthpasswordfilefor-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.basicAuth.usernamearrayOptionalbasicauthusernamefor-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.bearerTokenarrayOptionalbearertokenfor-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.bearerTokenFilearrayOptionalpathtobearertokenfilefor-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.blackholeWhethertoblackholealertingnotifications.Enablethisflagifyouwantvmalerttoevaluatealertingruleswithoutsendinganynotificationstoexternalreceivers(eg.alertmanager).-notifier.url,-notifier.configand-notifier.blackholearemutuallyexclusive.-notifier.configstringPathtoconfigurationfilefornotifiers-notifier.headersarrayOptionalHTTPheaderstosendwitheachrequesttothecorresponding-notifier.url.Forexample,-notifier.headers='My-Auth:foobar'wouldsend'My-Auth: foobar'HTTPheaderwitheveryrequesttothecorresponding-notifier.url.Multipleheadersmustbedelimitedby'^^':-notifier.headers='header1:value1^^header2:value2,header3:value3'.-notifier.oauth2.clientIDarrayOptionalOAuth2clientIDtousefor-notifier.url.Ifmultipleargsareset,thentheyareappliedindependentlyforthecorresponding-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.oauth2.clientSecretarrayOptionalOAuth2clientSecrettousefor-notifier.url.Ifmultipleargsareset,thentheyareappliedindependentlyforthecorresponding-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.oauth2.clientSecretFilearrayOptionalOAuth2clientSecretFiletousefor-notifier.url.Ifmultipleargsareset,thentheyareappliedindependentlyforthecorresponding-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.oauth2.endpointParamsarrayOptionalOAuth2endpointparameterstouseforthecorresponding-notifier.url.TheendpointparametersmustbesetinJSONformat:{"param1":"value1",...,"paramN":"valueN"}Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.oauth2.scopesarrayOptionalOAuth2scopestousefor-notifier.url.Scopesmustbedelimitedby';'.Ifmultipleargsareset,thentheyareappliedindependentlyforthecorresponding-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.oauth2.tokenUrlarrayOptionalOAuth2tokenURLtousefor-notifier.url.Ifmultipleargsareset,thentheyareappliedindependentlyforthecorresponding-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.sendTimeoutTimeoutwhensendingalertstothecorresponding-notifier.url.(default10s)-notifier.showURLWhethertoavoidstrippingsensitiveinformationsuchaspasswordsfromURLinlogmessagesorUIfor-notifier.url.Itishiddenbydefault,sinceitcancontainsensitiveinfosuchasauthkey-notifier.suppressDuplicateTargetErrorsWhethertosuppress'duplicate target'errorsduringdiscovery-notifier.tlsCAFilearrayOptionalpathtoTLSCAfiletouseforverifyingconnectionsto-notifier.url.Bydefault,systemCAisusedSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.tlsCertFilearrayOptionalpathtoclient-sideTLScertificatefiletousewhenconnectingto-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.tlsInsecureSkipVerifyarrayWhethertoskiptlsverificationwhenconnectingto-notifier.urlSupportsarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Emptyvaluesaresettofalse.-notifier.tlsKeyFilearrayOptionalpathtoclient-sideTLScertificatekeytousewhenconnectingto-notifier.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.tlsServerNamearrayOptionalTLSservernametouseforconnectionsto-notifier.url.Bydefault,theservernamefrom-notifier.urlisusedSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-notifier.urlarrayPrometheusAlertmanagerURL,e.g.http://127.0.0.1:9093.ListallAlertmanagerURLsifitrunsintheclustermodetoensurehighavailability.Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-pprofAuthKeyvalueAuthkeyfor/debug/pprof/*endpoints.ItmustbepassedviaauthKeyqueryarg.Itoverrides-httpAuth.*Flagvaluecanbereadfromthegivenfilewhenusing-pprofAuthKey=file:///abs/path/to/fileor-pprofAuthKey=file://./relative/path/to/file.Flagvaluecanbereadfromthegivenhttp/httpsurlwhenusing-pprofAuthKey=http://host/pathor-pprofAuthKey=https://host/path-promscrape.consul.waitTimedurationWaittimeusedbyConsulservicediscovery.Defaultvalueisusedifnotset-promscrape.consulSDCheckIntervaldurationIntervalforcheckingforchangesinConsul.Thisworksonlyifconsul_sd_configsisconfiguredin'-promscrape.config'file.Seehttps://docs.victoriametrics.com/sd_configs/#consul_sd_configs for details (default 30s)-promscrape.discovery.concurrencyintThemaximumnumberofconcurrentrequeststoPrometheusautodiscoveryAPI(Consul,Kubernetes,etc.)(default100)-promscrape.discovery.concurrentWaitTimedurationThemaximumdurationforwaitingtoperformAPIrequestsifmorethan-promscrape.discovery.concurrencyrequestsaresimultaneouslyperformed(default1m0s)-promscrape.dnsSDCheckIntervaldurationIntervalforcheckingforchangesindns.Thisworksonlyifdns_sd_configsisconfiguredin'-promscrape.config'file.Seehttps://docs.victoriametrics.com/sd_configs/#dns_sd_configs for details (default 30s)-pushmetrics.disableCompressionWhethertodisablerequestbodycompressionwhenpushingmetricstoevery-pushmetrics.url-pushmetrics.extraLabelarrayOptionallabelstoaddtometricspushedtoevery-pushmetrics.url.Forexample,-pushmetrics.extraLabel='instance="foo"'addsinstance="foo"labeltoallthemetricspushedtoevery-pushmetrics.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-pushmetrics.headerarrayOptionalHTTPrequestheadertosendtoevery-pushmetrics.url.Forexample,-pushmetrics.header='Authorization: Basic foobar'adds'Authorization: Basic foobar'headertoeveryrequesttoevery-pushmetrics.urlSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-pushmetrics.intervaldurationIntervalforpushingmetricstoevery-pushmetrics.url(default10s)-pushmetrics.urlarrayOptionalURLtopushmetricsexposedat/metricspage.Seehttps://docs.victoriametrics.com/#push-metrics . By default, metrics exposed at /metrics page aren't pushed to any remote storageSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-reloadAuthKeyvalueAuthkeyfor/-/reloadhttpendpoint.ItmustbepassedviaauthKeyqueryarg.Itoverrides-httpAuth.*Flagvaluecanbereadfromthegivenfilewhenusing-reloadAuthKey=file:///abs/path/to/fileor-reloadAuthKey=file://./relative/path/to/file.Flagvaluecanbereadfromthegivenhttp/httpsurlwhenusing-reloadAuthKey=http://host/pathor-reloadAuthKey=https://host/path-remoteRead.basicAuth.passwordstringOptionalbasicauthpasswordfor-remoteRead.url-remoteRead.basicAuth.passwordFilestringOptionalpathtobasicauthpasswordtousefor-remoteRead.url-remoteRead.basicAuth.usernamestringOptionalbasicauthusernamefor-remoteRead.url-remoteRead.bearerTokenstringOptionalbearerauthtokentousefor-remoteRead.url.-remoteRead.bearerTokenFilestringOptionalpathtobearertokenfiletousefor-remoteRead.url.-remoteRead.disablePathAppendWhethertodisableautomaticappendingof'/api/v1/query'or'/select/logsql/stats_query'pathtotheconfigured-datasource.urland-remoteRead.url-remoteRead.headersstringOptionalHTTPheaderstosendwitheachrequesttothecorresponding-remoteRead.url.Forexample,-remoteRead.headers='My-Auth:foobar'wouldsend'My-Auth: foobar'HTTPheaderwitheveryrequesttothecorresponding-remoteRead.url.Multipleheadersmustbedelimitedby'^^':-remoteRead.headers='header1:value1^^header2:value2'-remoteRead.idleConnTimeoutdurationDefinesadurationforidle(keep-aliveconnections)toexist.Considersettingsthisvaluelesstothevalueof"-http.idleConnTimeout".Itmustpreventpossible"write: broken pipe"and"read: connection reset by peer"errors.(default50s)-remoteRead.lookbackdurationLookbackdefineshowfartolookintopastforalertstimeseries.Forexample,iflookback=1hthenrangefromnow()tonow()-1hwillbescanned.(default1h0m0s)-remoteRead.oauth2.clientIDstringOptionalOAuth2clientIDtousefor-remoteRead.url.-remoteRead.oauth2.clientSecretstringOptionalOAuth2clientSecrettousefor-remoteRead.url.-remoteRead.oauth2.clientSecretFilestringOptionalOAuth2clientSecretFiletousefor-remoteRead.url.-remoteRead.oauth2.endpointParamsstringOptionalOAuth2endpointparameterstousefor-remoteRead.url.TheendpointparametersmustbesetinJSONformat:{"param1":"value1",...,"paramN":"valueN"}-remoteRead.oauth2.scopesstringOptionalOAuth2scopestousefor-remoteRead.url.Scopesmustbedelimitedby';'.-remoteRead.oauth2.tokenUrlstringOptionalOAuth2tokenURLtousefor-remoteRead.url.-remoteRead.showURLWhethertoshow-remoteRead.urlintheexportedmetrics.Itishiddenbydefault,sinceitcancontainsensitiveinfosuchasauthkey-remoteRead.tlsCAFilestringOptionalpathtoTLSCAfiletouseforverifyingconnectionsto-remoteRead.url.Bydefault,systemCAisused-remoteRead.tlsCertFilestringOptionalpathtoclient-sideTLScertificatefiletousewhenconnectingto-remoteRead.url-remoteRead.tlsInsecureSkipVerifyWhethertoskiptlsverificationwhenconnectingto-remoteRead.url-remoteRead.tlsKeyFilestringOptionalpathtoclient-sideTLScertificatekeytousewhenconnectingto-remoteRead.url-remoteRead.tlsServerNamestringOptionalTLSservernametouseforconnectionsto-remoteRead.url.Bydefault,theservernamefrom-remoteRead.urlisused-remoteRead.urlstringOptionalURLtodatasourcecompatiblewithMetricsQL.ItcanbesinglenodeVictoriaMetricsorvmselect.Remotereadisusedtorestorealertsstate.Thisconfigurationmakessenseonlyifvmalertwasconfiguredwith`remoteWrite.url`beforeandhasbeensuccessfullypersisteditsstate.SupportsaddressintheformofIPaddresswithaport(e.g.,http://127.0.0.1:8428)orDNSSRVrecord.Seealso'-remoteRead.disablePathAppend','-remoteRead.showURL'.-remoteWrite.basicAuth.passwordstringOptionalbasicauthpasswordfor-remoteWrite.url-remoteWrite.basicAuth.passwordFilestringOptionalpathtobasicauthpasswordtousefor-remoteWrite.url-remoteWrite.basicAuth.usernamestringOptionalbasicauthusernamefor-remoteWrite.url-remoteWrite.bearerTokenstringOptionalbearerauthtokentousefor-remoteWrite.url.-remoteWrite.bearerTokenFilestringOptionalpathtobearertokenfiletousefor-remoteWrite.url.-remoteWrite.concurrencyintDefinesnumberofwritersforconcurrentwritingintoremotewriteendpoint.DefaultvaluedependsonthenumberofavailableCPUcores.-remoteWrite.disablePathAppendWhethertodisableautomaticappendingof'/api/v1/write'pathtotheconfigured-remoteWrite.url.-remoteWrite.flushIntervaldurationDefinesintervalofflushestoremotewriteendpoint(default2s)-remoteWrite.headersstringOptionalHTTPheaderstosendwitheachrequesttothecorresponding-remoteWrite.url.Forexample,-remoteWrite.headers='My-Auth:foobar'wouldsend'My-Auth: foobar'HTTPheaderwitheveryrequesttothecorresponding-remoteWrite.url.Multipleheadersmustbedelimitedby'^^':-remoteWrite.headers='header1:value1^^header2:value2'-remoteWrite.idleConnTimeoutdurationDefinesadurationforidle(keep-aliveconnections)toexist.Considersettingsthisvaluelesstothevalueof"-http.idleConnTimeout".Itmustpreventpossible"write: broken pipe"and"read: connection reset by peer"errors.(default50s)-remoteWrite.maxBatchSizeintDefinesmaxnumberoftimeseriestobeflushedatonce(default10000)-remoteWrite.maxQueueSizeintDefinesthemaxnumberofpendingdatapointstoremotewriteendpoint(default100000)-remoteWrite.oauth2.clientIDstringOptionalOAuth2clientIDtousefor-remoteWrite.url-remoteWrite.oauth2.clientSecretstringOptionalOAuth2clientSecrettousefor-remoteWrite.url-remoteWrite.oauth2.clientSecretFilestringOptionalOAuth2clientSecretFiletousefor-remoteWrite.url-remoteWrite.oauth2.endpointParamsstringOptionalOAuth2endpointparameterstousefor-remoteWrite.url.TheendpointparametersmustbesetinJSONformat:{"param1":"value1",...,"paramN":"valueN"}-remoteWrite.oauth2.scopesstringOptionalOAuth2scopestousefor-notifier.url.Scopesmustbedelimitedby';'.-remoteWrite.oauth2.tokenUrlstringOptionalOAuth2tokenURLtousefor-notifier.url.-remoteWrite.retryMaxTimedurationThemaxtimespentonretryattemptsforthefailedremote-writerequest.ChangethisvalueifitisexpectedforremoteWrite.urltobeunreachableformorethan-remoteWrite.retryMaxTime.Seealso-remoteWrite.retryMinInterval(default30s)-remoteWrite.retryMinIntervaldurationTheminimumdelaybetweenretryattempts.Everynextretryattemptwilldoublethedelaytopreventhammeringofremotedatabase.Seealso-remoteWrite.retryMaxTime(default1s)-remoteWrite.sendTimeoutdurationTimeoutforsendingdatatotheconfigured-remoteWrite.url.(default30s)-remoteWrite.showURLWhethertoshow-remoteWrite.urlintheexportedmetrics.Itishiddenbydefault,sinceitcancontainsensitiveinfosuchasauthkey-remoteWrite.tlsCAFilestringOptionalpathtoTLSCAfiletouseforverifyingconnectionsto-remoteWrite.url.Bydefault,systemCAisused-remoteWrite.tlsCertFilestringOptionalpathtoclient-sideTLScertificatefiletousewhenconnectingto-remoteWrite.url-remoteWrite.tlsInsecureSkipVerifyWhethertoskiptlsverificationwhenconnectingto-remoteWrite.url-remoteWrite.tlsKeyFilestringOptionalpathtoclient-sideTLScertificatekeytousewhenconnectingto-remoteWrite.url-remoteWrite.tlsServerNamestringOptionalTLSservernametouseforconnectionsto-remoteWrite.url.Bydefault,theservernamefrom-remoteWrite.urlisused-remoteWrite.urlstringOptionalURLtoVictoriaMetricsorvminsertwheretopersistalertsstateandrecordingrulesresultsinformoftimeseries.SupportsaddressintheformofIPaddresswithaport(e.g.,http://127.0.0.1:8428)orDNSSRVrecord.Forexample,if-remoteWrite.url=http://127.0.0.1:8428isspecified,thenthealertsstatewillbewrittentohttp://127.0.0.1:8428/api/v1/write.Seealso-remoteWrite.disablePathAppend,'-remoteWrite.showURL'.-replay.disableProgressBarWhethertodisablerenderingprogressbarsduringthereplay.Progressbarrenderingmightbeverboseorbreakthelogsparsing,soitisrecommendedtobedisabledwhennotusedininteractivemode.-replay.maxDatapointsPerQuery/query_rangeMaxnumberofdatapointsexpectedinonerequest.Itaffectsthemaxtimerangeforevery/query_rangerequestduringthereplay.Thehigherthevalue,thelessrequestswillbemadeduringreplay.(default1000)-replay.ruleRetryAttemptsintDefineshowmanyretriestomakebeforegivinguponruleifrequestforitreturnsanerror.(default5)-replay.rulesDelaydurationDelaybetweenrulesevaluationwithinthegroup.Couldbeimportantiftherearechainedrulesinsidethegroupandprocessingneedtowaitforpreviousruleresultstobepersistedbyremotestoragebeforeevaluatingthenextrule.Keepitequalorbiggerthan-remoteWrite.flushInterval.(default1s)-replay.timeFromstringThetimefilterinRFC3339formattostartthereplayfrom.E.g.'2020-01-01T20:07:00Z'-replay.timeTostringThetimefilterinRFC3339formattofinishthereplayby.E.g.'2020-01-01T20:07:00Z'.Bydefault,issettothecurrenttime.-rulearrayPathtothefilesorhttpurlwithalertingand/orrecordingrulesinYAMLformat.Supportshierarchicalpatternsandregexpes.Examples:-rule="/path/to/file".Pathtoasinglefilewithalertingrules.-rule="http://<some-server-addr>/path/to/rules".HTTPURLtoapagewithalertingrules.-rule="dir/*.yaml"-rule="/*.yaml"-rule="gcs://vmalert-rules/tenant_%{TENANT_ID}/prod".-rule="dir/**/*.yaml".Includesallthe.yamlfilesin"dir"subfoldersrecursively.RulefilessupportYAMLmulti-document.Filesmaycontain%{ENV_VAR}placeholders,whicharesubstitutedbythecorrespondingenvvars.EnterpriseversionofvmalertsupportsS3andGCSpathstorules.Forexample:gs://bucket/path/to/rules,s3://bucket/path/to/rulesS3andGCSpathssupportonlymatchingbyprefix,e.g.s3://bucket/dir/rule_matchesallfileswithprefixrule_infolderdir.Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-rule.defaultRuleTypestringDefaulttypeforruleexpressions,canbeoverriddenbytypeparameterinsidetherulegroup.Supportedvalues:"graphite","prometheus"and"vlogs".(default:"prometheus")-rule.evalDelaytimeAdjustmentofthetimeparameterforruleevaluationrequeststocompensateintentionaldatadelayfromthedatasource.Normally,shouldbeequalto`-search.latencyOffset`(cmd-lineflagconfiguredforVictoriaMetricssingle-nodeorvmselect).Thisdoesn't apply to groups with eval_offset specified. (default 30s)-rule.maxResolveDurationdurationLimitsthemaxiMumdurationforautomaticalertexpiration,whichbydefaultis4timesevaluationIntervaloftheparentgroup-rule.resendDelaydurationMiniMumamountoftimetowaitbeforeresendinganalerttonotifier-rule.stripFilePathWhethertostripfilepathinresponsesfromtheapi/v1/rulesAPIforfilesconfiguredvia-rulecmd-lineflag.Forexample,thefilepath'/path/to/tenant_id/rules.yml'willbestrippedtojust'rules.yml'.ThisflagmightbeusefultohidesensitiveinformationinfilepathsuchastenantID.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-rule.templatesarrayPathorglobpatterntolocationwithgotemplatedefinitionsforrulesannotationstemplating.Flagcanbespecifiedmultipletimes.Examples:-rule.templates="/path/to/file".Pathtoasinglefilewithgotemplates-rule.templates="dir/*.tpl"-rule.templates="/*.tpl".Relativepathtoall.tplfilesin"dir"folder,absolutepathtoall.tplfilesinroot.-rule.templates="dir/**/*.tpl".Includesallthe.tplfilesin"dir"subfoldersrecursively.Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-rule.updateEntriesLimitintDefinesthemaxnumberofrule's state updates stored in-memory. Rule'supdatesareavailableonrule's Details page and are used for debugging purposes. The number of stored updates can be overridden per rule via update_entries_limit param. (default 20)-rule.validateExpressionsWhethertovalidaterulesexpressionsviaMetricsQLengine(defaulttrue)-rule.validateTemplatesWhethertovalidateannotationandlabeltemplates(defaulttrue)-s3.configFilePathstringPathtofilewithS3configs.Configsareloadedfromdefaultlocationifnotset.Seehttps://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-s3.configProfilestringProfilenameforS3configs.Ifnoset,thevalueoftheenvironmentvariablewillbeloaded(AWS_PROFILEorAWS_DEFAULT_PROFILE),orifbothnotset,DefaultSharedConfigProfileisused.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-s3.credsFilePathstringPathtofilewithGCSorS3credentials.Credentialsareloadedfromdefaultlocationsifnotset.Seehttps://cloud.google.com/iam/docs/creating-managing-service-account-keysandhttps://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-s3.customEndpointstringCustomS3endpointforusewithS3-compatiblestorages(e.g.MinIO).S3isusedifnotset.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-s3.forcePathStylePrefixingendpointwithbucketnamewhensetfalse,truebydefault.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/(defaulttrue)-tlsarrayWhethertoenableTLSforincomingHTTPrequestsatthegiven-httpListenAddr(akahttps).-tlsCertFileand-tlsKeyFilemustbesetif-tlsisset.Seealso-mtlsSupportsarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Emptyvaluesaresettofalse.-tlsAutocertCacheDirstringDirectorytostoreTLScertificatesissuedviaLet's Encrypt. Certificates are lost on restarts if this flag isn'tset.ThisflagisavailableonlyinEnterprisebinaries.Seehttps://docs.victoriametrics.com/enterprise/-tlsAutocertEmailstringContactemailfortheissuedLet's Encrypt TLS certificates. See also -tlsAutocertHosts and -tlsAutocertCacheDir .This flag is available only in Enterprise binaries. See https://docs.victoriametrics.com/enterprise/-tlsAutocertHostsarrayOptionalhostnamesforautomaticissuingofLet's Encrypt TLS certificates. These hostnames must be reachable at -httpListenAddr . The -httpListenAddr must listen tcp port 443 . The -tlsAutocertHosts overrides -tlsCertFile and -tlsKeyFile . See also -tlsAutocertEmail and -tlsAutocertCacheDir . This flag is available only in Enterprise binaries. See https://docs.victoriametrics.com/enterprise/Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-tlsCertFilearrayPathtofilewithTLScertificateforthecorresponding-httpListenAddrif-tlsisset.PreferECDSAcertsinsteadofRSAcertsasRSAcertsareslower.Theprovidedcertificatefileisautomaticallyre-readeverysecond,soitcanbedynamicallyupdated.Seealso-tlsAutocertHostsSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-tlsCipherSuitesarrayOptionallistofTLSciphersuitesforincomingrequestsoverHTTPSif-tlsisset.Seethelistofsupportedciphersuitesathttps://pkg.go.dev/crypto/tls#pkg-constantsSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-tlsKeyFilearrayPathtofilewithTLSkeyforthecorresponding-httpListenAddrif-tlsisset.Theprovidedkeyfileisautomaticallyre-readeverysecond,soitcanbedynamicallyupdated.Seealso-tlsAutocertHostsSupportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-tlsMinVersionarrayOptionalminimumTLSversiontouseforthecorresponding-httpListenAddrif-tlsisset.Supportedvalues:TLS10,TLS11,TLS12,TLS13Supportsanarrayofvaluesseparatedbycommaorspecifiedviamultipleflags.Valuecancontaincommainsidesingle-quotedordouble-quotedstring,{},[]and()braces.-versionShowVictoriaMetricsversion
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 modify
the params group:
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.
For chaining groups, they must be executed in a specific order, and the next group should be executed after
the results from previous group are available in the datasource.
In vmalert, user can specify eval_offset to achieve thatAvailable from v1.113.0.
groups:- name:BaseGroupinterval:1meval_offset:10srules:- record:http_server_request_duration_seconds:sum_rate:5m:http_getexpr:| sum without(instance, pod) (
rate(
http_server_request_duration_seconds{
http_request_method="GET"
}[5m]
)
)- record:http_server_request_duration_seconds:sum_rate:5m:http_postexpr:| sum without(instance, pod) (
rate(
http_server_request_duration_seconds{
http_request_method="POST"
}[5m]
)
)- name:TopGroupinterval:1meval_offset:40srules:- record:http_server_request_duration_seconds:sum_rate:5m:mergedexpr:| http_server_request_duration_seconds:sum_rate:5m:http_get
or
http_server_request_duration_seconds:sum_rate:5m:http_post
This configuration ensures that rules in BaseGroup are executed at(assuming vmalert starts at 12:00:00):
1
[12:00:10, 12:01:10, 12:02:10, 12:03:10...]
while rules in group TopGroup are executed at:
1
[12:00:40, 12:01:40, 12:02:40, 12:03:40...]
As a result, TopGroup always gets the latest results of BaseGroup.
By default, the eval_offset values should be at least 30 seconds apart to accommodate the
-search.latencyOffset(default 30s) command-line flag at vmselect or VictoriaMetrics single-node.
The minimum eval_offset gap can be adjusted accordingly with -search.latencyOffset.
The configuration file allows to configure static notifiers, discover notifiers via
Consul
and DNS:
For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
static_configs:- targets:# support using full url- 'http://alertmanager:9093/test/api/v2/alerts'- 'https://alertmanager:9093/api/v2/alerts'# the following target with only host:port will be used as <scheme>://localhost:9093/<path_prefix>/api/v2/alerts- localhost:9093consul_sd_configs:- server:localhost:8500services:- alertmanagerdns_sd_configs:- names:- my.domain.comtype:'A'port:9093
The list of configured or discovered Notifiers can be explored via UI.
If Alertmanager runs in cluster mode then all its URLs needs to be available during discovery
to ensure high availability.
The configuration file specification
is the following:
# 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:<string> ][ 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_configtls_config:[<tls_config> ]# Configures Bearer authentication token via stringbearer_token:<string># or by passing path to the file with token.bearer_token_file:<string># Configures OAuth 2.0 authentication# see https://prometheus.io/docs/prometheus/latest/configuration/configuration/#oauth2oauth2:[<oauth2_config> ]# Optional list of HTTP headers in form `header-name: value`# applied for all requests to notifiers# For example:# headers:# - "CustomHeader: foo"# - "CustomHeader2: bar"headers:[<string>, ...]# List of labeled statically configured Notifiers.## Each list of targets may be additionally instructed with# authorization params. Target's authorization params will# inherit params from global authorization params if there# are no conflicts.static_configs:[ - targets:][- '<host>'][oauth2 ][basic_auth ][authorization ][tls_config ][bearer_token ][bearer_token_file ][headers ]# List of Consul service discovery configurations.# See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_configconsul_sd_configs:[- <consul_sd_config> ... ]# List of DNS service discovery configurations.# See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dns_sd_configdns_sd_configs:[- <dns_sd_config> ... ]# List of relabel configurations for entities discovered via service discovery.# Supports the same relabeling features as the rest of VictoriaMetrics components.# See https://docs.victoriametrics.com/vmagent/#relabelingrelabel_configs:[- <relabel_config> ... ]# 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/#relabelingalert_relabel_configs:[- <relabel_config> ... ]
vmalert is mostly designed and built by VictoriaMetrics community.
Feel free to share your experience and ideas for improving this
software. Please keep simplicity as the main priority.
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:
1
2
3
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:
Install Go. The minimum supported version is Go 1.22.
Run make vmalert-linux-arm or make vmalert-linux-arm64 from the root folder of the repository.
It builds vmalert-linux-arm or vmalert-linux-arm64 binary respectively and puts it into the bin folder.
Run make vmalert-linux-arm-prod or make vmalert-linux-arm64-prod from the root folder of the repository.
It builds vmalert-linux-arm-prod or vmalert-linux-arm64-prod binary respectively and puts it into the bin folder.