Skip to content

Questions about Gauge labels #890

@1138559250

Description

@1138559250

I'm a newbie with Prometheus_client.
I would like to ask if it is possible to customize the label.
The example is as follows
metrics_one = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label2", "label3", "label4", "label5", "label6"])
metrics_two = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label2", ])
metrics_three = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label3", ])
metrics_four = prometheus_client.Gauge("mysql_data", "mysql_data", ["label1", "label2", "label4" ])

But I have a lot of labels, I only need to use a few of them when I insert data,
Do I have to write all the metrics like this? Is there another way to do it?
And in the end, I finally hope to use flask to respond to the latest data of all labels of metrics.
@app.route('/metrics')
def metrics():
set_data_to_prometheus()
return Response(prometheus_client.generate_latest(metrics), mimetype="text/plain")

If so, I can only pass out the data of one metric.
Looking forward for your reply, thank you

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