The Nutanix Exporter is a Go application that fetches live data from any number of Prism Element servers and presents it in a format ingestable by Prometheus. It runs as a docker container, automatically fetching all PE clusters from a Prism Central instance and exporting metrics from multiple APIv2 endpoints (VMs, Hosts, Clusters, etc.).
- YAML config files define which metrics to collect
- Hashicorp Vault support for fetching cluster credentials
- Refreshes credentials from Vault on 4xx errors
- Parent Exporter class that can be extended for any APIv2 endpoint
- Per cluster metrics exposed at
/metrics/cluster-name
- Optional filtering by cluster name prefix
- Hashicorp Vault server with KVv2 Secrets Engine enabled
- Secrets Engine name: defined in
VAULT_ENGINE_NAME
environment variable - Secret name: defined in
PE_TASK_ACCOUNT
andPC_TASK_ACCOUNT
environment variables - Fields: username, secret
- Secrets Engine name: defined in
- Nutanix Prism Central 2023.4 or later
Metrics are collected from the Prism Element v2.0 APIs. Currently, the exporter supports the following endpoints:
- Clusters
- Hosts
- VMs
- Storage Containers
The response from the API contains a list of entities, each with a set of key-value pairs. The exporter will flatten these key-value pairs and expose them as Prometheus metrics.
/config
contains a YAML configuration file for each exporter. This is where the metrics to be collected are defined. Any value in the API response can be collected; however, the exporter will only collect metrics that are defined in the configuration file. It is important to note that nested fields in the API response are flattened and exposed like "parent_child", e.g. "stats_num_iops".
Each entry must have the following fields:
- name: The name of the metric key in the API response
- help: User defined description of the metric
- name: memory_mb
help: Memory in MB.
- name: power_state
help: Power state of the VM.
- name: vcpu_reservation_hz
help: vCPU reservation in Hz.
- name: stats_num_iops
help: Number of IOPS. (Example of a nested key where stats is the parent in the response)
Default configuration files are provided for each APIv2 endpoint. These can be overwritten when running the exporter by mounting a new configuration file into the container as seen in the deployment section.
While the exporter is designed to run in a containerized environment, it can also be run natively on a host. The following instructions will guide you through both methods. For production environments, the exporter should always be run in a container. However, for development and testing, running the Go binary natively is generally easier.
For both methods, start by cloning the repository and navigating to the repo root in your terminal.
To build and run the Go binary natively:
- Download and install Go from here
- Export all necessary environment variables
go run cmd/nutanix_exporter/main.go
- The exporter will now be running on
localhost:9408
To build and run in a container:
- Download and install Docker from here
docker build -t nutanix_exporter .
docker run -p 9408:9408 --env-file configs/exporter.env nutanix_exporter
- The exporter will now be running on
localhost:9408
Example exporter.env:
VAULT_ADDR=https://your-vault-server.yourdomain.com
VAULT_NAMESPACE=production
VAULT_ENGINE_NAME=NutanixKV2
VAULT_ROLE_ID=12345678-1234-5678-1234-567812345678
VAULT_SECRET_ID=12345678-1234-5678-1234-567812345678
PC_CLUSTER_NAME=your-pc-cluster-name
PC_CLUSTER_URL=https://your-pc-cluster.yourdomain.com:9440
PE_TASK_ACCOUNT=PETaskAccount
PC_TASK_ACCOUNT=PCTaskAccount
CLUSTER_PREFIX=optional-cluster-prefix to filter cluster names
PC_API_VERSION=v4 (Optional, defaults to v3)
Example docker-compose.yml:
services:
NutanixExporter:
image: "your_container_registry/nutanix_exporter:latest"
restart: unless-stopped
volumes:
- /path/to/your/configs/cluster.yaml:configs/cluster.yaml:z
- /path/to/your/configs/storagecontainer.yaml:configs/storagecontainer.yaml:z
- /path/to/your/configs/host.yaml:configs/host.yaml:z
- /path/to/your/configs/vm.yaml:configs/vm.yaml:z
env_file:
- /path/to/your/configs/exporter.env
ports:
- '9408:9408'
- Go - Programming language
- Go Prometheus Client - Prometheus client library for Go
- Go Hashicorp Vault Client - Hashicorp Vault client library for Go
- Docker - Containerization
- GitHub Actions - CI/CD pipeline
We do not have any dedicated Slack channel for this project, however the GitHub Discussions feature is enabled for this repository. Feel free to ask questions, share ideas, or discuss the project.
Please read CONTRIBUTING for more details about making a contribution to this open source project and ensure that you follow our CODE_OF_CONDUCT.
If you have any other issues or questions regarding this project, feel free to contact one of the CODEOWNERS for a more in-depth discussion.
This project is open source under the "GPLv2 License", read the LICENCE terms for more details.