I'm just starting with prometheus. I've setup a python collector that I'm
successfully scraping. The collector is doing a few api queries with one of
our products. This can take 5-10 seconds. Even if I set the scrape duration
to greater than the maximum query time, I'm finding the collector is
returning zero as a value regularly.
In the collector logs I'm getting the following error :
```
BrokenPipeError: [Errno 32] Broken pipe
```
The main collector method is :
def collect(self):
logging.info("collect : {}".format(self))
g = GaugeMetricFamily("sg_one_time_query", 'Help text', labels=['site',
'field'])
data = self.get_shotgun_API_response()
logging.info("data : {}".format(data))
if data:
g.add_metric([_SG_SCRIPT_SITE, 'sg_one_time_query'],
data['sg_one_time_query'])
g.add_metric([_SG_SCRIPT_SITE, 'sg_one_time_update'],
data['sg_one_time_update'])
g.add_metric([_SG_SCRIPT_SITE, 'sg_open_ended_query'],
data['sg_open_ended_query'])
yield g
So what I think is happening is that Prometheus is scraping this collector
before the get_shogun_API_response method has returned a value.
Does anyone know how I can fix the collect() method so it gracefully
handles situations when the next scrape happens before the
get_shotgun_API_response method has returned a value to yield?
Thanks in advance for your help!
Cheers
Patrick
--
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/f0381231-ef8a-4b23-979d-49ee62e2b177n%40googlegroups.com.