Skip to content

Duplicated timeseries in CollectorRegistry #921

@jednoprsak

Description

@jednoprsak

Hello,
I am trying to make my metrics and write it inside one file using textfile_collector, but the problem is, that it tells me ''Duplicated timeseries in CollectorRegistry: {'htcondor_jobstatus'}'.

Here is the function:

def make_job_metrics():
    # works with mandatory structures 
    # JobsAd_metrics, JobsAd_labels, jobs, metrics
    registry = CollectorRegistry()
    for jobid in jobs:
      # print(type(jobid))
      if not isinstance(jobid, str):
          continue
      for metric in JobsAd_metrics:
        args_dict = {}
        for parameter in JobsAd_labels:
            args_dict[parameter] = jobs[jobid][parameter]
        metric_name = 'htcondor' + '_' + metric.lower()
        # print(metric_name)
        # print(args_dict)
        print(metric_name)
        args_list=[]
        for v in args_dict.items():
            args_list.append(v[1])
        if jobs[jobid][metric] == None:
            continue
        **g = Gauge(metric_name, 'metric_label', JobsAd_labels, registry=registry).labels(*args_list).set(jobs[jobid][metric])**
    write_to_textfile('/usr/local/bin/prometheus_custom_plugins/test.prom', registry)

Here is the command line output:
Traceback (most recent call last):
File "./htcondor_exporter.py", line 308, in
make_job_metrics()
File "./htcondor_exporter.py", line 147, in make_job_metrics
g = Gauge(metric_name, 'metric_label', JobsAd_labels, registry=registry).labels(*args_list).set(jobs[jobid][metric])
File "/usr/local/bin/prometheus_custom_plugins/htcenv/lib/python3.6/site-packages/prometheus_client/metrics.py", line 373, in init
_labelvalues=_labelvalues,
File "/usr/local/bin/prometheus_custom_plugins/htcenv/lib/python3.6/site-packages/prometheus_client/metrics.py", line 143, in init
registry.register(self)
File "/usr/local/bin/prometheus_custom_plugins/htcenv/lib/python3.6/site-packages/prometheus_client/registry.py", line 45, in register
duplicates))
ValueError: Duplicated timeseries in CollectorRegistry: {'htcondor_jobstatus'}

My question is: How to write many metrics with same names, but different labels and values inside one file using textfile collector?

  • because it looks like, that in the case when I put inside registry next metric with the same name, it prints out this error.

Thank you for any responses
Lukáš Míča

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions