Add Prometheus metric exporter

Adds a "fake" Prometheus metrics endpoint which returns cluster status
information in Prometheus format.
This commit is contained in:
2023-12-08 11:45:52 -05:00
parent d0e7c19602
commit 7373bfed3f
2 changed files with 114 additions and 0 deletions

View File

@ -622,6 +622,30 @@ class API_Status(Resource):
api.add_resource(API_Status, "/status")
# /metrics
class API_Metrics(Resource):
def get(self):
"""
Return the current PVC cluster status in Prometheus-compatible metrics format
Endpoint is unauthenticated to allow metrics exfiltration without having to deal
with the Prometheus compatibility later.
---
tags:
- root
responses:
200:
description: OK
400:
description: Bad request
"""
status_data, status_retcode = api_helper.cluster_status()
return api_helper.cluster_format_metrics(status_data, status_retcode)
api.add_resource(API_Metrics, "/metrics")
# /faults
class API_Faults(Resource):
@RequestParser(