A Prometheus exporter written in Python3 to retrieve custom metrics from Cisco APICs.
There are two ways to add further metrics. One is extending the BaseCollector and the other is extending the Collector.
When extending from the BaseCollector
the client has to take care of the communication with the different APIC hosts, checking for valid response data etc. The Collector
takes care of these things and only requires to implement the abstract methods get_query
(defines the query to be executed against the APIC host) and get_metrics
(creates the Prometheus metrics from the fetched data).
For most metrics it is sufficient to extend from the Collector. See ApicCoopDbCollector as an example.
The exporter is configured by passing a yaml
of the following structure:
exporter:
log_level: INFO
prometheus_port: 9102
aci:
apic_hosts:
apic_user:
apic_tenant_name:
collectors:
- "ApicHealthCollector"
- "ApicIPsCollector"
- ...
The list of collectors can be used to select the list of collectors to be run. If no collectors are specified, all are run.
Additionally an environment variable APIC_PASSWORD
is required.
Build the Docker image locally with make build
.
And test with docker run -p 9102:9102 -v ~/Developer/git/apic-exporter/apic-config-sample.yaml:/config.yaml apic-exporter:latest -c /config.yaml
- Ensure that your system meets the requirement mentioned in the Getting Started section of the Dev Containers documentation.
- Clone this repository to your local filesystem
- Open the repository in VS Code
- Press
F1
,CMD+Shift+P
and select Dev Containers: Reopen in Container - Now you have a running Python Dev Environment.
- You will need to fill the
apic-config-sample.yaml
andlaunch.json
with actual values to be able to debug.