This repository provides a centralized documentation source for OpenShift and its operators Prometheus metrics. It includes metadata for metrics such as descriptions, labels, and types.
The repository also provides a script to automatically fetch and update the list of Prometheus metrics and their associated labels from OpenShift clusters.
- Centralized Documentation: Stores Prometheus metrics and their metadata (descriptions, labels, types) in organized YAML files.
- Automated Updates: A Python script that can be run against OpenShift clusters to fetch new metrics and update existing ones.
- Custom Label Descriptions: Allows updating label descriptions using an input YAML file for improved clarity and consistency.
- Python 3.7 or later.
- Access to an OpenShift cluster with Prometheus monitoring enabled.
- A valid token for accessing the Prometheus endpoint.
git clone https://github.com/your-username/openshift-metrics.git
cd openshift-metrics
pip install requests>=2.25.0 pyyaml>=5.4 urllib3>=1.26
Place the label_descriptions.yaml file in the data/ directory. It should follow this format:
- label_name: endpoint
label_description: The specific endpoint of the service or application being monitored.
- label_name: namespace
label_description: The Kubernetes namespace in which the pod or service resides.
Execute the Python script to fetch and update metrics documentation:
python src/fetch_metrics.py --token YOUR_PROMETHEUS_TOKEN
The updated metrics documentation will be saved in the docs/prometheus_metrics/ directory. Each YAML file corresponds to a group of metrics organized by their prefix, such as:
docs/prometheus_metrics/
├── controller_metrics.yaml
├── kube_metrics.yaml
└── network_metrics.yaml
Note: It is possible to manually update the metrics and labels descriptions directly in the file under docs/prometheus_metrics
.
The script provides debug messages for:
- Labels that are newly added.
- Labels whose descriptions are updated based on the label_descriptions.yaml input file.
We welcome contributions to improve the documentation or the script. Follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Commit your changes and push the branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the Apache License.
For issues or questions, feel free to open an issue.