how to push metrics continuously using pushgateway

2,479 views
Skip to first unread message

Srikanth Chandika

unread,
Jul 28, 2017, 10:20:39 AM7/28/17
to Prometheus Users
Hi,

I am very new to Prometheus Monitoring Tool.

I am using Prometheus for Collecting all System Metrics - soon I wanted to use in Kubernetes.

How to push metrics continuously using pushgateway.

I have setup with node_exporter on all my clients and I defined clients in prometheus server so now I can see all my metrics with very useful graphs from prometheus server.

Every time when a new node or client added, it is not possible for me to tell that node to prometheus server.

For that reason, I want to use push mechanism how do I achieve pushing metrics continuously and see graphs like node_exporter!!

from the help of documentation I used pusgateway, I ran below python script

===================================================

from prometheus_client import CollectorRegistry, Gauge, push_to_gateway

registry = CollectorRegistry()
g = Gauge('job_last_success_unixtime', 'Last time a batch job successfully finished', registry=registry)
g.set_to_current_time()
push_to_gateway('192.168.2.2:9091', job='batchA', registry=registry)

===================================================

But I did not understand what exactly happened with above script. I can only job="batchA" from prometheus server component 192.168.2.2:9091

How do I see graphs or create custom graphs using push mechanism.

I have attached screenshots.


pushgateway2.png
pushgateway1.png

Srikanth Chandika

unread,
Jul 28, 2017, 10:29:59 AM7/28/17
to Prometheus Users
Do I need to install pushgateway package on all clients!

If yes how do I tell pushgateway to send metrics to prometheus server!

Alexander Schwartz

unread,
Jul 29, 2017, 6:29:51 AM7/29/17
to promethe...@googlegroups.com

Hello Srikanth,

Prometheus is intended to pull metrics. The push gateway should only be used for short-running jobs that don't live long enough to be pulled.

To tell Prometheus about new nodes and clients, use the discovery mechanisms of Prometheus - this is also the way it will work on Kubernetes.

To give it a start without Kubernetes, have a look at "file_sd_config" discovery type: https://prometheus.io/docs/operating/configuration/#<file_sd_config>

Add a new node or client to the file and Prometheus will pick it up.

If you are already using Consul for nodes and services to register, you can use it to re-configure Prometheus on the fly as well (same link as above, different section).
 
Regards,
Alexander
--
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 post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/aa5979ee-b924-4394-b2ea-ea62b0bcf333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Alexander Schwartz (alexander...@gmx.net)
http://www.ahus1.de

Srikanth Chandika

unread,
Jul 30, 2017, 11:36:46 AM7/30/17
to Prometheus Users
Hi Alexander,

Thanks for reply.
Its a Valuable information - I will work on it.

Actually we have a setup that needs short-running jobs so for that reason also I am trying to setup push mechanism.

So can you also please share me inputs for pusgateway. How to get all system metrics for short period lets say 5mins.


---
Srikanth

Srikanth Chandika

unread,
Aug 1, 2017, 8:58:33 AM8/1/17
to Prometheus Users
Hi Alex,

Discovery mechanisms of Prometheus solved our problem.
I will have to check with K8s

Thanks

On Saturday, July 29, 2017 at 3:59:51 PM UTC+5:30, Alexander Schwartz wrote:
Reply all
Reply to author
Forward
0 new messages