AttributeError: 'Gauge' object has no attribute '_value'

336 views
Skip to first unread message

Sungmin Jeun

unread,
Apr 11, 2020, 1:31:24 AM4/11/20
to Prometheus Users
Hi, I just create a gauge and assigned value with set() method.
However error message says
AttributeError: 'Gauge' object has no attribute '_value'
 
code is below 
registry = CollectorRegistry()
g = Gauge('caliper_tps', "", {"client":"0","instance":"open1", "round":"0"}, registry=registry)
g.set(0)

How can i set value to guage metric?

Julius Volz

unread,
Apr 11, 2020, 1:39:06 AM4/11/20
to Sungmin Jeun, Prometheus Users
Hi,

In the creation of the gauge, you need to only pass the label names (not the values), and then pass the label values when you set the gauge:

g = Gauge('caliper_tps', "", ["client", "instance", "round"])
g.labels(client="0", instance="open1", round="0").set(0)

Cheers,
Julius

--
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 prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/80428846-4a9c-4899-9d95-8afb9d9683ac%40googlegroups.com.

Sungmin Jeun

unread,
Apr 11, 2020, 5:03:24 AM4/11/20
to Prometheus Users
Thank you so much!
Now I get it!

2020년 4월 11일 토요일 오후 2시 39분 6초 UTC+9, Julius Volz 님의 말:
Hi,

In the creation of the gauge, you need to only pass the label names (not the values), and then pass the label values when you set the gauge:

g = Gauge('caliper_tps', "", ["client", "instance", "round"])
g.labels(client="0", instance="open1", round="0").set(0)

Cheers,
Julius

On Sat, Apr 11, 2020 at 7:31 AM Sungmin Jeun <ckdr...@gmail.com> wrote:
Hi, I just create a gauge and assigned value with set() method.
However error message says
AttributeError: 'Gauge' object has no attribute '_value'
 
code is below 
registry = CollectorRegistry()
g = Gauge('caliper_tps', "", {"client":"0","instance":"open1", "round":"0"}, registry=registry)
g.set(0)

How can i set value to guage metric?

--
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 promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages