SR Linux has first-class streaming telemetry support thanks to 100% YANG coverage of state and config data. You can stream any data off the switch with on-change, sample or target-defined subscriptions, and every API sees the same data: what the CLI shows can also be streamed over gNMI.
This lab is a small Clos fabric of Nokia SR Linux switches running as containers, with a telemetry stack of gnmic, Prometheus and Grafana, and a logging stack of Grafana Alloy and Loki.
Open st.clab.yml in the containerlab app to see the lab like this. The buttons start traffic and run the scenarios described below.
Goals of this lab:
- Show how a telemetry and logging stack becomes part of the containerlab topology file.
- Explain the SR Linux telemetry support, with sample and on-change gNMI subscriptions.
- Give practical gnmic configuration examples: subscriptions, processors and the export to Prometheus.
- Build advanced Grafana dashboards: a live topology map and faceplates with the flow panel plugin, the EVPN overlay, alerts and logs.
- Collect the SR Linux syslog with Grafana Alloy and Loki, and tell events from debug traces.
- Break the fabric on purpose and watch it in the telemetry.
The lab is deployed with containerlab; st.clab.yml describes its topology. In the cloned directory:
containerlab deployTo remove the lab:
containerlab destroy --cleanupThe SR Linux switches are reachable over SSH by their name, the Linux clients with docker exec:
ssh admin@leaf1
ssh admin@spine1
docker exec -it client1 bashThe telemetry and logging services are exposed on the host:
| Service | Address | Notes |
|---|---|---|
| Grafana | http://localhost:3000 | Anonymous access, no login needed; admin/admin to sign in |
| Prometheus | http://localhost:9090 | Queries, rules and alerts |
| Loki | http://localhost:3100 | API only, query the logs in Grafana |
| Alloy | http://localhost:12345 | State of the log pipeline |
The fabric has two spines and three leaves, with a client behind each leaf. The diagram shows the subnet of each link, the AS number and system address of each switch and the address of each client.
Leaves and spines are 7220 IXR-D2L and IXR-D3L switches. Each switch gets its startup configuration at boot.
Once booted, the switches come up with their interfaces, underlay protocols and overlay service configured. The fabric runs a Layer 2 EVPN service between the leaves.
The underlay runs eBGP, the overlay iBGP with EVPN. The Layer 2 EVPN service is configured as explained in the L2 EVPN tutorial.
On a leaf, show network-instance default protocols bgp neighbor lists the BGP sessions:
BGP neighbor summary for network-instance "default"
Peer flags: see legend after the summary when applicable.
+----------------------+--------------------------------+----------------------+--------+------------+------------------+------------------+----------------------------------------------+
| Net-Inst | Peer | Group | Flags | Peer-AS | State | Uptime | AFI/SAFI [Rx/Active/Tx] |
+======================+================================+======================+========+============+==================+==================+==============================================+
| default | 10.0.2.1 | iBGP-overlay | S | 100 | established | 0d:1h:32m:24s | evpn [4/4/2] |
| default | 10.0.2.2 | iBGP-overlay | S | 100 | established | 0d:1h:32m:27s | evpn [4/0/2] |
| default | 192.168.11.1 | eBGP | S | 201 | established | 0d:1h:32m:29s | ipv4-unicast [3/3/2] |
| default | 192.168.12.1 | eBGP | S | 202 | established | 0d:1h:32m:32s | ipv4-unicast [3/3/4] |
+----------------------+--------------------------------+----------------------+--------+------------+------------------+------------------+----------------------------------------------+
Summary:
4 configured neighbors, 4 configured sessions are established, 0 disabled peers
0 dynamic peers
Telemetry is at the core of the lab:
| Role | Software |
|---|---|
| Telemetry collector | gnmic |
| Time-series DB | Prometheus |
| Visualization | Grafana |
gnmic is an OpenConfig project that subscribes to streaming telemetry of network devices and exports it to a variety of destinations. Here it subscribes to the five switches and exposes the data to Prometheus. Its configuration, configs/gnmic/gnmic-config.yml, shows a few practices worth copying:
- Sample and on-change subscriptions. Counters and rates are sampled every 5 seconds. States (port oper-state, BGP session state, network instance state, software version) are streamed on-change, with a 10 second heartbeat that keeps the metric alive in Prometheus. Together with Prometheus scraping gnmic every second and the dashboard refreshing every second, a port or BGP session going down shows in Grafana about two seconds after it happened.
- Verified TLS. gnmic checks the certificates of the switches against the CA that containerlab creates for the lab, instead of skipping the verification.
- Processors. Prometheus only stores numbers, so a Starlark processor turns timestamps into epoch seconds,
true/falseinto 1/0, the BGP session state into a number (6 is established) and text such as the software version and the port descriptions into labels. - EVPN overlay. Besides interface, BGP, routing, bridge table and platform statistics, gnmic collects the MAC table of the MAC-VRFs (whether a MAC was learnt on a local port or received over EVPN, and where it points to), the traffic per remote VTEP and the EVPN routes of type 2 and 3.
Prometheus stores the telemetry exported by gnmic. configs/prometheus/prometheus.yml makes it scrape gnmic and evaluate the rules every second.
configs/prometheus/rules.yml holds the rules:
- Recording rules for what the dashboard and the alerts share:
srl:interface:in_usemarks the cabled ports and carries their description,srl:switch:problemscounts the BGP sessions and cabled ports that are down per switch. - Alert rules:
BGPSessionDown,PortDown,PortErrorsandHighCPU. They show in the Prometheus UI under Alerts, in Grafana under Alerting > Alert rules and on the dashboard. There is no Alertmanager, so nobody is notified.
Grafana visualizes the telemetry and the logs. The topology file provisions its datasources, the dashboard and the plugins it needs.
The dashboard provided by this repository is organized in tabs:
| Tab | Shows |
|---|---|
| Fabric | Key figures of the fabric (BGP sessions, ports, client traffic, EVPN MAC addresses, warnings, alerts), a live topology map, the switch faceplates, fabric throughput and every BGP session |
| Switches | One row per selected switch with throughput, BGP, routes and MACs, network instances, ports, release, uptime, last commit, CPU and memory |
| Ports | Traffic, packet, error and discard rates of the selected ports and a table of all cabled ports with what they connect to |
| EVPN | The MAC table of the leaves, the EVPN routes per switch and the VXLAN traffic per remote VTEP |
| Logs | Log volume per severity and the syslog messages of the selected switches and applications |
Switches, ports and applications are picked with the Business Variable panel. A red mark next to a switch tells that one of its BGP sessions or cabled ports is down, an orange or red mark next to an application that it logged warnings or errors. The time series show markers where something happened in the fabric, taken from the logs: orange for a port going up or down, red for a BGP session changing state, blue for a configuration commit.
The topology map and the front panel view are powered by the flow plugin, which overlays telemetry data over SVG graphics. Each half of a link is colored by the traffic rate leaving that end and labelled with it, and the port bubbles and faceplate ports are colored by their oper-state. The topology panel is generated from the topology file with the Grafana bundle export of the containerlab app. The SVG graphics and panel configurations of both views are in configs/grafana/flow_panels.
The dashboard is generated by tools/dashboard; see its README to change and rebuild it.
The switches send their syslog to Alloy, which labels the messages and ships them to Loki. They send every message above informational level. SR Linux writes two kinds of messages, and Alloy tells them apart:
- Events report what happened: a port went down, a BGP session changed state, a commit succeeded. They get the labels
kind="event"andeventwith the name of the event, such asportDownorbgpNeighborEstablished. - Traces are the debug output of the SR Linux applications and get
kind="trace". At boot they come in bursts of thousands, many of them at warning level.
The message prefix (subsystem, module, source location) moves to structured metadata, so the log line is the message itself. The Logs tab shows events by default and can include the traces; the warning figure and the markers on the graphs count events only.
A freshly deployed lab carries no traffic. traffic.sh starts and stops iperf3 traffic from the clients to client1:
| Command | What it does |
|---|---|
bash traffic.sh start all |
client2 and client3 send 1.6 Mbit/s each to client1 |
bash traffic.sh start 1-2 |
only client2 sends |
bash traffic.sh start 1-3 |
only client3 sends |
bash traffic.sh start 1-2 1M |
8 streams of 1 Mbit/s instead of the default 200 Kbit/s |
bash traffic.sh stop all |
stops all traffic |
bash traffic.sh status |
shows which clients send traffic |
The rates show on the topology map and the throughput panels of the dashboard.
scenario.sh breaks and repairs the fabric, so you can see it in the telemetry. Start the traffic first, open the dashboard, then try:
| Command | What happens | Where to look |
|---|---|---|
bash scenario.sh port-down leaf3 e1-49 |
The uplink from leaf3 to spine1 goes down | The port turns red on the topology and the faceplate, the PortDown and BGPSessionDown alerts fire, the traffic moves to spine2 |
bash scenario.sh bgp-down leaf1 10.0.2.1 |
The EVPN session from leaf1 to spine1 is disabled | The BGP sessions table, a red marker on the graphs; the EVPN tab shows that the MAC addresses stay, learnt over spine2 |
bash scenario.sh congest |
client2 sends 8 Mbit/s to client1 | The access links of leaf1 and leaf2 turn red on the topology |
bash scenario.sh commit leaf1 |
Changes the configuration of leaf1 and commits it; the change is harmless, it sets the system location | Last commit on the Switches tab, a blue marker on the graphs |
bash scenario.sh status |
Lists ports and BGP sessions that are not up | |
bash scenario.sh reset |
Undoes all of the above | Everything turns green again |
tools/smoke-test.mjs checks a deployed lab: BGP, telemetry, EVPN data, logs, alerts and every tab of the dashboard. The smoke test workflow runs it on GitHub for every pull request.
npm ci --prefix tools
npx --prefix tools playwright install chromium
START_TRAFFIC=1 node tools/smoke-test.mjs