F5 Distributed Cloud Telemetry (Metrics) - Prometheus
Scope
This article walks through the process of collecting metrics from F5 Distributed Cloud’s (XC) Service Graph API and exposing them in a format that Prometheus can scrape. Prometheus then scrapes these metrics, which can be visualized in Grafana.
Introduction
Metrics are essential for gaining real-time insight into service performance and behaviour. F5 Distributed Cloud (XC) provides a Service Graph API that captures service-to-service communication data across your infrastructure.
Prometheus, a leading open-source monitoring system, can scrape and store time-series metrics — and when paired with Grafana, offers powerful visualization capabilities.
This article shows how to integrate a custom Python-based exporter that transforms Service Graph API data into Prometheus-compatible metrics. These metrics are then scraped by Prometheus and visualized in Grafana, all running in Docker for easy deployment.
Prerequisites
- Access to F5 Distributed Cloud (XC) SaaS tenant
- VM with Python3 installed
- Running Prometheus instance (If not check "Configuring Prometheus" section below)
- Running Grafana instance (If not check "Configuring Grafana" section below)
Note – In this demo, an AWS VM is used with Python installed and running exporter (port - 8888), Prometheus (host port - 9090) and Grafana (port - 3000) running as docker instance, all in same VM.
Fig 1 : Docker instancesArchitecture Overview
- F5 XC API → Python Exporter → Prometheus → Grafana
Building the Python Exporter
To collect metrics from the F5 Distributed Cloud (XC) Service Graph API and expose them in a format Prometheus understands, we created a lightweight Python exporter using Flask. This exporter acts as a transformation layer — it fetches service graph data, parses it, and exposes it through a /metrics endpoint that Prometheus can scrape.
Code Link -> exporter.py
Key Functions of the Exporter
- Uses XC-Provided .p12 File for Authentication: To authenticate API requests to F5 Distributed Cloud (XC), the exporter uses a client certificate packaged in a .p12 file. This file must be manually downloaded from the F5 XC console (steps) and stored on the VM where the Python script runs. The script expects the full path to the .p12 file and its associated password to be specified in the configuration section.
- Fetches Service Graph Metrics: The script pulls service-level metrics such as request rates, error rates, throughput, and latency from the XC API. It supports both aggregated and individual load balancer views.
- Processes and Structures the Data: The exporter parses the raw API response to extract the latest metric values and converts them into Prometheus exposition format. Each metric is labelled (e.g., by vhost and direction) for flexibility in Grafana queries.
- Exposes a /metrics Endpoint: A Flask web server runs on port 8888, serving the /metrics endpoint. Prometheus periodically scrapes this endpoint to ingest the latest metrics.
- Handles Multiple Metric Types: Traffic metrics and health scores are handled and formatted individually. Each metric includes a descriptive name, type declaration, and optional labels for fine-grained monitoring and visualization.
Running the Exporter
- python3 exporter.py > python.log 2>&1 &
This command runs exporter.py using Python3 in background and redirects all standard output and error messages to python.log for easier debugging.
Configuring Prometheus
- docker run -d --name=prometheus --network=host -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest
Prometheus is running as docker instance in host network (port 9090) mode with below configuration (prometheus.yml), scrapping /metrics endpoint exposed from python flask exporter on port 8888 every 60 seconds.
Fig 3 : Prometheus configurationConfiguring Grafana
- docker run -d --name=grafana -p 3000:3000 grafana/grafana:latest
Private IP of the Prometheus docker instance along with port (9090) is used as data source in Grafana configuration.
Fig 4 : Configuring Prometheus data source in GrafanaOnce Prometheus is configured under Grafana Data sources, follow below steps:
- Navigate to Explore menu
- Select “Prometheus” in data source picker
- Choose appropriate metric, in this case “f5xc_downstream_http_request_rate”
- Select desired time range and click “Run query”
- Observe metrics graph will be displayed
Note : Some requests need to be generated for metrics to be visible in Grafana.
A broader, high-level view of all metrics can be accessed by navigating to “Drilldown” and selecting “Metrics”, providing a comprehensive snapshot across services.
Fig 6 : Verifying all metrics exposed from F5 XCConclusion
F5 Distributed Cloud’s (F5 XC) Service Graph API provides deep visibility into service-to-service communication, and when paired with Prometheus and Grafana, it enables powerful, real-time monitoring without vendor lock-in. This integration highlights F5 XC’s alignment with open-source ecosystems, allowing users to build flexible and scalable observability pipelines. The custom Python exporter bridges the gap between the XC API and Prometheus, offering a lightweight and adaptable solution for transforming and exposing metrics. With Grafana dashboards on top, teams can gain instant insight into service health and performance. This open approach empowers operations teams to respond faster, optimize more effectively, and evolve their observability practices with confidence and control.