pushgateway cannot get data from pusher

19 views
Skip to first unread message

张鹏

unread,
May 29, 2020, 10:14:25 AM5/29/20
to Prometheus Users
The process is as follows: 

I push the data generated by  two servers to two pushgateway instances in turn (the IP of the server is used as the grouping key), 
and then use Prometheus to pull the gateway.


The problem  is that the data on the server is always lost intermittently. 
The return value of the push method is checked, and there is no error.

And I see the  data on the pushgateway page. 
Sometimes the last pushed time is the time when the data drops to 0, sometimes it's the normal current time


The screenshots of the next two pushgateway pages are only seconds apart
1.png

2.png





Part of push codes as follows:


mymetrics := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "req_monitor",
Help: "req monitor ",
},
[]string{"code", "method"},
)
reg := prometheus.NewRegistry()
reg.MustRegister(mymetrics)
pusher := push.New(url, "my_job").Gatherer(reg)

pusher.Grouping("instance", gLocalIP)

err := pusher.Add()
if err != nil{
fmt.println("push error:%s",err)
}

Bjoern Rabenstein

unread,
Jun 2, 2020, 12:41:03 PM6/2/20
to 张鹏, Prometheus Users
On 29.05.20 07:14, 张鹏 wrote:
>
> I push the data generated by  two servers to two pushgateway instances in turn
> (the IP of the server is used as the grouping key), 
> and then use Prometheus to pull the gateway.

What do you mean by "data generated by two servers"?

The PGW is mostly for batch jobs to push out their result before they
terminate.

> The problem  is that the data on the server is always lost intermittently. 
> The return value of the push method is checked, and there is no error.
>
> And I see the  data on the pushgateway page. 

What do you mean by "lost"? Does it make it to the PGW, but you cannot
see it on your Prometheus server?

Or does it sometimes make it to the PGW but then disappears?

> Sometimes the last pushed time is the time when the data drops to 0, sometimes
> it's the normal current time

The "last pushed time" is what it says. It should never be the current
time.

> The screenshots of the next two pushgateway pages are only seconds apart
> 1.png
>
> 2.png

Yes, that's fine. You pushed something at 21:23:54. Just after the 1st
screenshot, you pushed something again, and then you see the updated
time on the 2nd screenshot.

> Part of push codes as follows:
>
>
> mymetrics := prometheus.NewCounterVec(prometheus.CounterOpts{
> Name: "req_monitor",
> Help: "req monitor ",
> },
> []string{"code", "method"},
> )
> reg := prometheus.NewRegistry()
> reg.MustRegister(mymetrics)
> pusher := push.New(url, "my_job").Gatherer(reg)
>
> pusher.Grouping("instance", gLocalIP)
>
> err := pusher.Add()
> if err != nil{
> fmt.println("push error:%s",err)
> }

This code never really sets anything, you push would be empty.

--
Björn Rabenstein
[PGP-ID] 0x851C3DA17D748D03
[email] bjo...@rabenste.in
Reply all
Reply to author
Forward
0 new messages