48. Appendix 6 – Monitoring with Prometheus and Grafana
Wanguard can be watched from the monitoring stack you already run, in two complementary ways. The REST API exports the operational state of the whole deployment, from Sensors and servers to BGP peers and the license, as Prometheus metrics that Prometheus, Zabbix and compatible collectors scrape and alert on. Grafana shows the traffic graphs, flows and anomalies by reading the stores the Console already keeps, with ready-made dashboards and an installer. The first part of this appendix covers the metrics endpoint, the second part Grafana.
48.1. Prometheus
The metrics endpoint is GET /wanguard-api/v1/metrics, in the Prometheus text format. Prometheus, Grafana Agent / Grafana Alloy, Grafana Cloud, VictoriaMetrics and Zabbix (through its Prometheus items) can scrape it directly. No extra daemon, port or agent is needed: the endpoint is served by the Console’s web server and reads the Console database on every request, the same way the Console’s own widgets do.
Use it to alert on what the NOC must react to before customers notice: a Sensor that stopped, an interface that drops packets or runs full, a server that stopped reporting, a BGP peer down, a Flowspec table near its limit, a stuck command queue, a full disk or an expiring license. Several Consoles can be scraped by one Prometheus, which gives MSSPs a fleet view the Console cannot give on its own.
48.1.1. What is exposed
● Components – For every active Sensor, Sensor Cluster and Filter: whether it runs (WANsupervisor watchdog state and age), CPU, RAM and start time, and a health value computed exactly like the Sensor Health dashboard widget (0 OK, 1 warning, 2 critical). Filters that are started per anomaly have no watchdog; they are covered by the Filter metrics below● Interfaces – Per monitored interface: traffic and packets/s in each direction, usage of the configured link speed, the drop ratio, IP validation failures, the number of internal and external IP addresses, and the age of the live statistics. Packet Sensors add captured and dropped packets/s, Flow Sensors flows/s and export sequence failures, SNMP Sensors interface errors, discards and the operational status. DPDK engines add their port counters (RX/TX packets, bits, errors, RX missed and RX no-buffer)● Servers and Console – Per server: time since the last report, uptime, load, CPU, RAM, interrupts, clock offset to the Console, components and free space on the packet dump and flow storage paths. For the Console: free space on the database and graph paths, database size and connections, logged-in users● Anomalies – Active anomalies in total, per decoder and class, and per Sensor; how many are mitigated by a Filter, a BGP traffic diversion or a BGP blackhole; their aggregate traffic; the highest link severity; anomalies detected in the last 5 minutes● Filters – Per Filter: running instances, their traffic, firewall pass/drop and Flowspec traffic, capture drops, and the time since an instance last reported● BGP Connectors – Active announcements per kind (unicast, Flowspec, SRTBH), the configured Flowspec rule limit, the age of the oldest announcement and, for connectors with health checks enabled, the number of BGP peers and of peers down● Operations – Commands waiting in the WANsupervisor queue per module, events of the last 5 minutes per level, and the license: validity, expiry, licensed and used items● Meta – The Wanguard version, how long the response took to build and which sections failed
Traffic and link speeds are exported in bytes per second (metric names ending in _bytes_per_second), the base unit Prometheus uses, so they combine with node_exporter and SNMP exporter data. Multiply by 8 for bits per second, as the included dashboard does.
What is not exposed: traffic analytics per IP address, AS number, country or IP group. They stay in the Console’s graph storage (InfluxDB or ClickHouse), which Grafana reads with its own datasources, as described in the Grafana section. No series is labelled with an IP address or an AS number, so the number of series follows the number of components, not the traffic.
48.1.2. Creating the user
The endpoint answers to users with the Administrator or Operator role; Guest users get HTTP 403. In General Settings » User Management, create a dedicated user, for example prometheus, with an Operator role and set REST API Access to Exclusive (API access only, no Console login). Either keep its password for HTTP Basic authentication, or click the Options button and set an API Key, which is sent in the X-API-Key HTTP header.
Test the endpoint from the Prometheus server (-k accepts the Console’s self-signed TLS certificate):
curl -s -k -u prometheus:PASSWORD https://wanguard_console/wanguard-api/v1/metrics | head
curl -s -k -H 'X-API-Key: API_KEY' https://wanguard_console/wanguard-api/v1/metrics | head
48.1.3. Scrape configuration
Add a job to prometheus.yml. With a password (works with every Prometheus version):
scrape_configs:
- job_name: wanguard
scheme: https
metrics_path: /wanguard-api/v1/metrics
scrape_interval: 30s
scrape_timeout: 20s
basic_auth:
username: prometheus
password_file: /etc/prometheus/wanguard.pass
# tls_config:
# ca_file: /etc/prometheus/console-ca.pem # or insecure_skip_verify: true for a self-signed certificate
static_configs:
- targets: ['wanguard_console']
labels:
site: main
With an API key instead of a password, which needs Prometheus 2.55 or later (custom request headers are not supported by older versions, including the 2.53 LTS series):
scrape_configs:
- job_name: wanguard
scheme: https
metrics_path: /wanguard-api/v1/metrics
scrape_interval: 30s
http_headers:
X-API-Key:
files: [/etc/prometheus/wanguard.key]
static_configs:
- targets: ['wanguard_console']
To scrape several Consoles, list them all under targets; every series carries the instance label of its Console. A scrape interval of 30 seconds matches how often the components and WANsupervisor update the database; scraping more often adds load without adding information.
- job_name: wanguard-fast
metrics_path: /wanguard-api/v1/metrics
params:
sections: ['components,queue,bgp']
scrape_interval: 15s
# ... authentication and targets as above
48.1.4. Alert rules
Ready-made Prometheus alerting rules are provided in /opt/andrisoft/api/contrib/prometheus/wanguard-alerts.yml on the Console: components down or without live statistics, interface drops and saturation, DPDK RX misses, silent servers, clock skew, low disk space, stale Filter instances and Filter capture drops, BGP peers down, Flowspec tables near their limit, announcements older than a day, a stuck WANsupervisor queue, bursts of error events, failing metric sections, and license expiry, exhaustion and invalid keys. Component thresholds match the Sensor Health widget. The same directory holds wanguard-health.json, a Grafana dashboard for these metrics, which is covered together with the other dashboards in the Grafana section.
Copy wanguard-alerts.yml to the Prometheus server, reference it from prometheus.yml and check it:
rule_files:
- /etc/prometheus/rules/wanguard-alerts.yml
promtool check rules /etc/prometheus/rules/wanguard-alerts.yml
Every alert has a severity label (critical, warning or info) for routing in Alertmanager. Adjust thresholds and for durations to your network; for example, a permanent blackhole makes WanguardAnnouncementTooOld fire by design.
48.1.5. Zabbix
Zabbix 4.2 and later read the same endpoint. Create an HTTP agent item with the URL https://wanguard_console/wanguard-api/v1/metrics, HTTP authentication Basic (or the header X-API-Key), and use it as the master item for dependent items with the Prometheus pattern preprocessing step, for example wanguard_component_up{component=”Border Sensor”}. Low-level discovery with the Prometheus to JSON preprocessing step creates one item per component automatically.
48.1.6. Number of series
The response grows with the configuration, not with the traffic. Roughly, it holds 10 to 12 series per component (about 20 for a component running a DPDK engine), 15 to 18 per monitored interface, 30 per server, 6 per BGP Connector and one per decoder with active anomalies, plus a few dozen for the Console, the queue, the events and the license. For example, a Console with 50 Sensors monitoring 200 interfaces on 10 servers exports about 4,000 series. The response is built in a few tens of milliseconds with about 20 small queries, all of them on indexed columns or small tables, and it never writes to the database.
48.2. Grafana
Grafana can show Wanguard’s traffic graphs, anomalies and health next to the rest of your monitoring. Nothing has to be exported: Grafana reads, with its standard datasources, the data the Console already keeps in three places:
● Graph storage engine – When Configuration » General Settings » Graphs & Storage uses ClickHouse or InfluxDB, every Sensor, application, IP/subnet, AS, country and anomaly graph of the Console is a table or measurement Grafana can query directly with the ClickHouse datasource plugin or the built-in InfluxDB datasource. Flow records stored in ClickHouse by Flow Sensors are available as well. RRDtool files cannot be read by Grafana● Console database – A read-only MySQL/MariaDB account gives Grafana the names of Sensors and decoders, the anomaly list and anomaly annotations● Prometheus – The operational state from the metrics endpoint described above: components up or down, capture drops, link usage, servers, BGP Connectors, the WANsupervisor queue and the license
Wanguard ships ready-made dashboards for all three, an installer that sets up Grafana on the Console server in one step, and provisioning files for a Grafana running elsewhere. They are in /opt/andrisoft/api/contrib/grafana/ (the README file there has the GRANT statements and a data model reference) and /opt/andrisoft/api/contrib/prometheus/.
48.2.1. Installing Grafana on the Console server
Run as root:
/opt/andrisoft/bin/install_grafana
The installer adds the official Grafana package repository and installs Grafana OSS (unless it is already installed), installs the ClickHouse datasource plugin when a ClickHouse graph storage engine is enabled, creates the read-only Console database user grafana, generates the datasources from the engines enabled in Graphs & Storage, copies the matching dashboards into a Wanguard folder, and starts the grafana-server service. Grafana then answers on port 3000; the first login is admin / admin.
Useful options (see install_grafana –help for all of them):
● –prometheus-url URL – Also provisions the Prometheus datasource and the Wanguard Health dashboard, for the Prometheus that scrapes the metrics endpoint● –bind ADDRESS and –port PORT – The address and port Grafana listens on● –mysql-user USER –mysql-password PASSWORD – Use an existing database account instead of creating grafana; required when the Console database runs on another server (the installer prints the GRANT statements to run there)● –dashboards-only – Refresh the dashboards after a Wanguard upgrade; datasources and packages are left alone
The dashboards are provisioned from files, so Grafana shows them as read-only. To customize one, open it and use Save as to create an editable copy; re-running the installer updates only the provisioned originals.
48.2.2. Connecting a Grafana running elsewhere
Grafana on another server or Grafana Cloud needs network access to the stores and three datasources (four with Prometheus). Examples of the provisioning files are in /opt/andrisoft/api/contrib/grafana/provisioning/; the same settings can be entered in the Grafana UI.
● ClickHouse – Install the grafana-clickhouse-datasource plugin (version 4; 4.15 and later need Grafana 11.6 or later). Use the HTTP interface of the ClickHouse server from Graphs & Storage (port 8123 by default) and the database configured there (andrisoft by default). Create a read-only user instead of using the Console’s account:CREATE USER grafana IDENTIFIED BY '...'; GRANT SELECT ON andrisoft.* TO grafana;● InfluxDB – The InfluxDB server and database from Graphs & Storage, query language InfluxQL. With authentication enabled create a read-only user:CREATE USER grafana WITH PASSWORD '...'; GRANT READ ON andrisoft TO grafana● Console database – MySQL/MariaDB on the Console server, database andrisoft. Create a user with SELECT on the tables attacks, wansensor, wansniff, wanflow, wanflow_interfaces, wansnmp, wansnmp_interfaces, wansensor_virtual, wanserver, protocols, ipaddr and as_numbers, allowed to connect from the Grafana server, and open port 3306 for it as for Sensors on other servers● Prometheus – The Prometheus that scrapes the metrics endpoint, configured as described above
Import the dashboards from /opt/andrisoft/api/contrib/grafana/dashboards/ through Dashboards » New » Import (Dashboards » Import in older versions); every file declares the datasources it needs and the import dialog asks which of yours to use. Use the clickhouse set when the Console stores graphs in ClickHouse and the influxdb set for InfluxDB. Grafana 10.4 or later is required, 11 or later is recommended. The Wanguard Health dashboard is /opt/andrisoft/api/contrib/prometheus/wanguard-health.json instead; import it the same way, select the Prometheus datasource that scrapes the Consoles, and note that it works with Grafana 8.4 or later.
48.2.3. The dashboards
● Wanguard Sensors – Current inbound and outbound bits/s and packets/s, dropped packets and internal IP addresses of the selected Sensors; per-Sensor traffic and packets in each direction, stacked; the applications graph; drops, IP address counts, invalid packets, CPU, memory and load of each Sensor● Wanguard IP Traffic – The IP graph of one IP address or subnet: inbound and outbound bits/s and packets/s per decoder, summed over the selected Sensors, with a per-decoder summary of the time range. The prefix is chosen from the subnets with IP graph data or typed as address/mask● Wanguard Top Talkers (ClickHouse) – Hosts or subnets ranked by average or peak bits/s or packets/s over the time range for one decoder and direction, their traffic over time, and a ranking table that opens the IP Traffic dashboard for a prefix● Wanguard AS & Country – The top autonomous systems of the upstream, transit, peering or downstream AS graph and the top countries, over time and as rankings, with a country share chart and a world map● Wanguard Anomalies – Active and mitigated anomalies, anomalies started per interval by decoder, the number of active anomalies over time, the list of anomalies active during the time range (prefix, decoder, direction, class, values, severity, mitigation, Sensor) and the traffic, rule value against threshold and mitigation graphs of a selected anomaly● Wanguard Flows (ClickHouse) – Flow records stored by Flow Sensors: total traffic and the top values of any dimension (addresses, AS numbers, countries, ports, IP protocol, application, interfaces, IP zone names, flow class) over time, with share and ranking● Wanguard Health (Prometheus) – Components, interfaces, servers, mitigation and operations from the metrics endpoint, with an overview row and a component health table; the Console, Server and Component type selectors at the top filter all panels
Anomalies are drawn as red regions on every traffic dashboard, from the Console database, for the selected Sensors. Each dashboard has a Wanguard dashboards drop-down to switch between them.
48.2.4. How the data is read
● Sensors and decoders – The graph storage engines identify Sensors by the Console’s internal id (type-id-interface) and decoders by their key. The Sensor and Decoder variables take the names from the Console database, so the ClickHouse dashboards show Console names everywhere; the InfluxDB dashboards show the ids in graph legends● Resolution and retention with ClickHouse – Each graph table has raw rows, 15-minute averages and 2-hour averages, kept for the periods set in Graphs & Storage. The queries read the raw table for the most recent raw_hours hours, the 15-minute averages up to mid_hours hours and the 2-hour averages beyond, so any time range works without changing anything. The two hidden dashboard constants default to the Console’s defaults (192 and 840 hours); the installer sets them from the Console’s configuration, and they must be adjusted in the dashboard settings after the retention is changed● Resolution and retention with InfluxDB – InfluxQL cannot combine retention policies, so the InfluxDB dashboards have a Data tier selector: raw data, medium rollups or long-term rollups. Select a rollup tier for time ranges older than the raw retention● Units – All rates are per second, bits/s or packets/s. Values inside a Grafana interval are averaged; peak values are the highest interval average, so short bursts need a short interval● Load – The Top Talkers and AS rankings scan the IP, AS or country data of the whole time range on every refresh. On large installations keep the time range and refresh interval reasonable, as for the Console’s own reports
48.2.5. Security
Grafana needs read access only. Use dedicated read-only accounts for the Console database, ClickHouse and InfluxDB as described above, keep the provisioning file with the passwords readable by the grafana user only (the installer sets mode 640), and protect Grafana itself with its own authentication (LDAP, OAuth or local users) and TLS in front of it. Grafana users see all Sensors and prefixes of the Console; the Console’s per-user restrictions do not apply to Grafana.
48.2.6. Troubleshooting
✔ Datasource not found on a dashboard: the datasource placeholders of an imported dashboard were not assigned, or the provisioned datasource UIDs differ from wanguard-clickhouse, wanguard-influxdb, wanguard-mysql and wanguard-prometheus✔ The Sensor drop-down is empty: the Console database datasource cannot connect, or its user lacks SELECT on wansensor and the component tables✔ Panels are empty for a Sensor: the graph storage engine may exclude that graph class in Graphs & Storage » Storage Restrictions, or the time range is outside the retention; with InfluxDB select the right Data tier✔ The Flows dashboard reports an unknown column: the chosen dimension is not kept in the selected rollup table; select Raw flows✔ Grafana’s log shows database is locked (SQLITE_BUSY), datasource health checks fail with sqlstore.max-retries-reached, or a built-in datasource is reported as not registered: Grafana’s own SQLite database is contended on a busy Console server. Set wal = true under [database] in /etc/grafana/grafana.ini and restart grafana-server. The first start after an installation or upgrade runs its schema migrations, which can take several minutes on a loaded server✔ The queries behind every panel are plain SQL or InfluxQL and can be inspected in the panel editor; they document the data model for your own panels