I met with following issue in during writing custom exporter:
example:
from prometheus_client import Gauge
g = Gauge('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])
g.labels('get', '/').set(100) - that works
but if i have big amount of labels and i am trying to pass as list(or tuple):
labels_names = ['customerid', 'tenantname', 'operation', 'product', 'feature', 'context', 'hostname', 'message', 'region', 'podname']
labels_values = [u'Admin Tenant', u'RE-P01-IN01-C', u'us-west-1', u'Web Services', u'Admin Tenant', u'SXPServerHealthCheck', u'SO Server', u'mon...@cscloud.com', u'PR01', u'SXPServerHealthCheck']
if len(labels_names) == len(labels_values):
g = Gauge('my_requests_total', 'HTTP Failures', labels_names)
g.labels(labels_values).set(100)
i got:
File "/Library/Python/2.7/site-packages/prometheus_client/core.py", line 516, in labels
raise ValueError('Incorrect label count')
ValueError: Incorrect label count
In debug i see that method is getting following tuple:
<type 'tuple'>: ([u'Admin Tenant', u'RE-P01-IN01-C', u'us-west-1', u'Web Services', u'Admin Tenant', u'SXPServerHealthCheck', u'SO Server', u'mon...@cscloud.com', u'PR01', u'SXPServerHealthCheck'],)
instead what i am expecting:
(u'Admin Tenant', u'RE-P01-IN01-C', u'us-west-1', u'Web Services', u'Admin Tenant', u'SXPServerHealthCheck', u'SO Server', u'mon...@cscloud.com', u'PR01', u'SXPServerHealthCheck')
Any way to set values by passing list or tuple or i need to pass only strings separated by comma?
Thank you for answer that wasn't obvious from python client sdk.