Hello everyone,

The following is an example of a pattern we use frequently:

import time

from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, REGISTRY

def costly_function():
    "E.g., queries someone else's API and uses up API credits, etc..."
    return ('dev', 'uat', 'prod')

class Collector:
    def collect(self):
        gauge = GaugeMetricFamily('example_gauge',
            'Example gauge', labels=["environment"])
        for environment in costly_function():
            print("adding sample for environment=%s" % environment)
            gauge.add_metric([environment], 1)
        yield gauge

REGISTRY.register(Collector())
start_http_server(8080)
print("server listening on port 8080")
while True:
    time.sleep(60)

When we hook these kinds of exporter up in Google's GKE, and expose them 
via ILB Services, the ILB health checks query them for health via a 
/healthz endpoint.

That triggers an unwanted call to the costly_function() which we'd like to 
avoid.

Is there a simple way to intercept the call to /healthz and return e.g., an 
"OK" response but without resorting to a framework like Flask or Twisted?

We're at pains to keep these exporters as simple as possible.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/8d21f1f6-1190-4fa1-ad40-b7e25c90130dn%40googlegroups.com.

Reply via email to