---
myst:
html_meta:
description: |
VyOS exports metrics to external monitoring systems through the
Telegraf collector agent and through standalone Prometheus
exporters. Telegraf writes the collected data to Azure Data
Explorer, a Prometheus client endpoint, Splunk, or InfluxDB, and
forwards the VyOS system log to Loki.
keywords: monitoring, telegraf, prometheus, node exporter, frr exporter
---
(monitoring)=
# Monitoring
VyOS supports exporting metrics to external monitoring systems through
the [Telegraf][telegraf] collector agent and through standalone
Prometheus exporters. Telegraf can also forward system logs to Loki,
Grafana Labs' log aggregation system.
## Telegraf
Telegraf collects host and system metrics every 15 seconds through a
predefined set of input plugins, covering CPU, memory, disk and disk
I/O, network and network statistics, processes, kernel and interrupt
counters, systemd unit state, conntrack, per-interface link statistics,
and time synchronization. It also receives the VyOS system log through
its syslog input plugin.
The collected data is written to output plugins. Each plugin delivers it
to a different backend in that backend's format and protocol:
- [Azure Data Explorer][azure-data-explorer]: Writes metrics to an
Azure Data Explorer cluster.
- [Prometheus client][prometheus-client]: Exposes metrics on a
`/metrics` HTTP endpoint that a Prometheus server periodically
pulls.
- [Splunk][splunk]: Sends metrics to the Splunk HTTP Event Collector.
- [InfluxDB][influxdb]: Writes metrics to a bucket on an InfluxDB v2 server.
- [Loki][loki]: Sends the VyOS system log to a Grafana Loki server.
## Configuration
### General options
```{cfgcmd} set service monitoring telegraf vrf \
**Run the Telegraf service in the specified
{abbr}`VRF (Virtual Routing and Forwarding)` instance.**
The VRF must already be configured under `set vrf name `.
```
Example:
```none
set service monitoring telegraf vrf mgmt
```
### Agent Configuration
This section covers configuration commands which affect the overall agent behaviour.
```{cfgcmd} set service monitoring telegraf agent collection-jitter \
Set the collection jitter to jitter the collection by a random interval.
Each plugin will sleep for a random time within jitter before collecting.
This can be used to avoid many plugins querying things like sysfs at the same time,
which can have a measurable effect on the system.
By default vyos sets it to 5s.
```
```{cfgcmd} set service monitoring telegraf agent debug
Enable logging at debug level.
Delete this node to disable logging at debug level.
```
```{cfgcmd} set service monitoring telegraf agent flush-interval \
Set the default flushing interval for all outputs. Maximum flush-interval will
be flush-interval + flush-jitter.
By default vyos sets it to 15s.
```
```{cfgcmd} set service monitoring telegraf agent flush-jitter \
Set the default flush jitter for all outputs. This jitters the flush interval by
a random amount. This is primarily to avoid large write spikes for users running
a large number of telegraf instances. ie, a jitter of 5s and interval 10s means
flushes will happen every 10-15s.
By default vyos sets it to 0s.
```
```{cfgcmd} set service monitoring telegraf agent interval \
Set the default data collection interval for all inputs.
By default vyos sets it to 15s.
```
### Azure Data Explorer
A configuration for this plugin is committable only when
`authentication client-id`, `authentication client-secret`,
`authentication tenant-id`, `database`, and `url` are all configured.
`client-id`, `client-secret`, and `tenant-id` are credentials
associated with a single application registration in Microsoft Entra ID
(Azure AD), Microsoft's cloud identity service. Telegraf presents these
credentials to Entra ID to obtain an access token, then uses that token
to authorize its writes to the Azure Data Explorer cluster, Microsoft's
cloud analytics database. Create the application registration and
obtain these values from the Azure portal.
```{cfgcmd} set service monitoring telegraf azure-data-explorer authentication client-id \
**Configure the client ID of the Telegraf application registration.**
```
Example:
```none
set service monitoring telegraf azure-data-explorer authentication client-id a0b1c2d3-e4f5-0123-4567-89abcdef0123
```
```{cfgcmd} set service monitoring telegraf azure-data-explorer authentication client-secret \
**Configure the client secret of the Telegraf application
registration.**
```
Example:
```none
set service monitoring telegraf azure-data-explorer authentication client-secret MY-CLIENT-SECRET
```
```{cfgcmd} set service monitoring telegraf azure-data-explorer authentication tenant-id \
**Configure the tenant ID of the Telegraf application registration.**
```
Example:
```none
set service monitoring telegraf azure-data-explorer authentication tenant-id b1c2d3e4-f5a6-7890-1234-56789abcdef0
```
```{cfgcmd} set service monitoring telegraf azure-data-explorer database \
**Configure the cloud-hosted database into which Telegraf writes
metrics.**
The database must already exist. Telegraf does not create it.
```
Example:
```none
set service monitoring telegraf azure-data-explorer database vyos-metrics
```
```{cfgcmd} set service monitoring telegraf azure-data-explorer group-metrics \
**Configure how Telegraf groups metrics into tables in the configured
database:**
- `single-table`: All metrics are written to the single table
configured with `table`. If `single-table` is chosen, `table` becomes
required.
- `table-per-metric`: Metrics are grouped by metric name, and each
group is written to its own table.
The default is `table-per-metric`.
```
Example:
```none
set service monitoring telegraf azure-data-explorer group-metrics single-table
```
```{cfgcmd} set service monitoring telegraf azure-data-explorer table \
**Configure the destination table for Telegraf metrics when
`group-metrics` is set to `single-table`.**
When `group-metrics` is set to `table-per-metric`, this setting has no
effect.
```
Example:
```none
set service monitoring telegraf azure-data-explorer table vyos
```
```{cfgcmd} set service monitoring telegraf azure-data-explorer url \
**Configure the endpoint URL of the Azure Data Explorer cluster.**
```
Example:
```none
set service monitoring telegraf azure-data-explorer url https://vyos-cluster.westeurope.kusto.windows.net
```
### Prometheus client
The Prometheus client plugin is the Telegraf output plugin for exposing
metrics to Prometheus. For standalone Prometheus exporters, see the
{ref}`Prometheus ` section.
```{cfgcmd} set service monitoring telegraf prometheus-client
**Enable the Prometheus client output plugin.**
```
Example:
```none
set service monitoring telegraf prometheus-client
```
```{cfgcmd} set service monitoring telegraf prometheus-client allow-from \
**Restrict access to the metrics endpoint to clients whose source
address is within the specified IPv4 or IPv6 prefix.**
Repeat the command to allow multiple prefixes.
When unset, the endpoint accepts queries from any IP address.
```
Example:
```none
set service monitoring telegraf prometheus-client allow-from 192.0.2.0/24
set service monitoring telegraf prometheus-client allow-from 2001:db8::/32
```
```{cfgcmd} set service monitoring telegraf prometheus-client authentication username \
**Configure the username for HTTP Basic authentication on the metrics
endpoint.**
```
Example:
```none
set service monitoring telegraf prometheus-client authentication username prometheus
```
```{cfgcmd} set service monitoring telegraf prometheus-client authentication password \
**Configure the password for HTTP Basic authentication on the metrics
endpoint.**
HTTP Basic authentication is enabled only when both `username` and
`password` are configured.
```
Example:
```none
set service monitoring telegraf prometheus-client authentication password mysecurepassword
```
```{cfgcmd} set service monitoring telegraf prometheus-client listen-address \
**Configure a local IP address on which the Prometheus client plugin
accepts incoming connections.**
When unset, the plugin accepts incoming connections on all local IP
addresses.
```
Example:
```none
set service monitoring telegraf prometheus-client listen-address 192.0.2.1
```
```{cfgcmd} set service monitoring telegraf prometheus-client metric-version \<1-2\>
**Configure the metric mapping version used to translate Telegraf
metrics to the Prometheus format.**
The default is 2.
```
Example:
```none
set service monitoring telegraf prometheus-client metric-version 1
```
```{cfgcmd} set service monitoring telegraf prometheus-client port \<1-65535\>
**Configure the TCP port on which the Prometheus client plugin accepts
incoming connections.**
The default is 9273.
```
Example:
```none
set service monitoring telegraf prometheus-client port 9274
```
After enabling the plugin, the metrics endpoint can be queried with
`curl`:
```none
vyos@r14:~$ curl --silent localhost:9273/metrics | egrep -v "#" | grep cpu_usage_system
cpu_usage_system{cpu="cpu-total",host="r14"} 0.20040080160320556
cpu_usage_system{cpu="cpu0",host="r14"} 0.17182130584191915
cpu_usage_system{cpu="cpu1",host="r14"} 0.22896393817971655
```
### Splunk
A configuration for this plugin is committable only when
`authentication token` and `url` are configured.
```{cfgcmd} set service monitoring telegraf splunk authentication insecure
**Disable TLS certificate chain and host name verification for
connections to the Splunk HTTP Event Collector.**
```
Example:
```none
set service monitoring telegraf splunk authentication insecure
```
```{cfgcmd} set service monitoring telegraf splunk authentication token \
**Configure the token used to authorize requests to the Splunk HTTP
Event Collector.**
```
Example:
```none
set service monitoring telegraf splunk authentication token xxxxf5b8-xxxx-452a-xxxx-43828911xxxx
```
```{cfgcmd} set service monitoring telegraf splunk url \
**Configure the URL of the Splunk HTTP Event Collector endpoint.**
```
Example:
```none
set service monitoring telegraf splunk url 'https://192.0.2.10:8088/services/collector'
```
### InfluxDB
A configuration for this plugin is committable only when
`authentication organization`, `authentication token`, and `url` are
configured.
```{cfgcmd} set service monitoring telegraf influxdb authentication organization \
**Configure the name of the organization that owns the bucket on the
remote InfluxDB v2 server.**
```
Example:
```none
set service monitoring telegraf influxdb authentication organization vyos
```
```{cfgcmd} set service monitoring telegraf influxdb authentication token \
**Configure the API token used to authenticate to the remote InfluxDB
v2 server.**
The token must be in the standard InfluxDB v2 Base64-encoded format.
```
Example:
```none
set service monitoring telegraf influxdb authentication token 'ZAml9Uy5wrhA...=='
```
```{cfgcmd} set service monitoring telegraf influxdb bucket \
**Configure the name of the InfluxDB v2 bucket that receives metrics.**
The default is `main`.
```
Example:
```none
set service monitoring telegraf influxdb bucket bucket_vyos
```
```{cfgcmd} set service monitoring telegraf influxdb port \<1-65535\>
**Configure the TCP port of the remote InfluxDB v2 server.**
The default is 8086.
```
Example:
```none
set service monitoring telegraf influxdb port 8087
```
```{cfgcmd} set service monitoring telegraf influxdb url \
**Configure the URL of the remote InfluxDB v2 server.**
VyOS appends the configured port to this URL, so specify the URL
without a port number.
```
Example:
```none
set service monitoring telegraf influxdb url 'http://r1.influxdb2.local'
```
#### Example
The following example configures Telegraf to write metrics to an
InfluxDB v2 server at `r1.influxdb2.local` on port 8087, storing them
in the `bucket_vyos` bucket of the `vyos` organization, authenticating
to the InfluxDB v2 server with the configured API token.
```none
set service monitoring telegraf influxdb authentication organization 'vyos'
set service monitoring telegraf influxdb authentication token 'ZAml9Uy5wrhA...=='
set service monitoring telegraf influxdb bucket 'bucket_vyos'
set service monitoring telegraf influxdb port '8087'
set service monitoring telegraf influxdb url 'http://r1.influxdb2.local'
```
### Loki
A configuration for this plugin is committable only when `url` is
configured.
```{cfgcmd} set service monitoring telegraf loki port \<1-65535\>
**Configure the TCP port of the remote Loki server.**
The default is 3100.
```
Example:
```none
set service monitoring telegraf loki port 3101
```
```{cfgcmd} set service monitoring telegraf loki url \
**Configure the URL of the remote Loki server.**
VyOS appends the configured port to the host part of this URL. If the
URL contains a path, the path is used as the endpoint of the Loki write
API.
```
Example:
```none
set service monitoring telegraf loki url 'http://192.0.2.20'
```
```{cfgcmd} set service monitoring telegraf loki authentication username \
**Configure the username for HTTP Basic authentication to the Loki
server.**
```
Example:
```none
set service monitoring telegraf loki authentication username loki
```
```{cfgcmd} set service monitoring telegraf loki authentication password \
**Configure the password for HTTP Basic authentication to the Loki
server.**
If either `username` or `password` is configured, both are required.
Otherwise, the commit fails.
```
Example:
```none
set service monitoring telegraf loki authentication password mysecurepassword
```
```{cfgcmd} set service monitoring telegraf loki metric-name-label \