blue-yonder/azure-cost-mon

Switch to official Prometheus python client

StephanErb opened this issue · 0 comments

To foster re-use and make the code easier to approach for the Prometheus community, we should switch to the official Prometheus client (https://github.com/prometheus/client_python)

Example how the integration could look like:

from prometheus_client.core import CounterMetricFamily, REGISTRY

class AzureCollector(object):
    def collect(self):
        c = CounterMetricFamily('my_counter_total', 'Help text', labels=['foo'])
        c.add_metric(['bar'], 1.7)
        c.add_metric(['baz'], 3.8)
        yield c

REGISTRY.register(AzureCollector())

We could either use the built-in HTTP server (via start_http_server), built-in WSGI app (via make_wsgi_app) or continue to use Flask by returning output of generate_latest() with content type CONTENT_TYPE_LATEST from a custom /metrics function.