PushGateway produces "java.net.ConnectException: Connection refused: connect"

470 views
Skip to first unread message

benedi...@gmail.com

unread,
Aug 23, 2018, 7:54:55 AM8/23/18
to Prometheus Users
Hi List,

I have a Problem with the PushGateway.
I Installed and run a local Prometheus instance.

I have access to the application, I can see the metrics etc.
So everything works fine.

Now in integrated the exaple code of your site to my Java Application.

void executeBatchJob() throws Exception {
     
CollectorRegistry registry = new CollectorRegistry();
     
Gauge duration = Gauge.build()
         
.name("my_batch_job_duration_seconds").help("Duration of my batch job in seconds.").register(registry);
     
Gauge.Timer durationTimer = duration.startTimer();
     
try {
       
// Your code here.

       
// This is only added to the registry after success,
       
// so that a previous success in the Pushgateway isn't overwritten on failure.
       
Gauge lastSuccess = Gauge.build()
           
.name("my_batch_job_last_success").help("Last time my batch job succeeded, in unixtime.").register(registry);
       lastSuccess
.setToCurrentTime();
     
} finally {
       durationTimer
.setDuration();
       
PushGateway pg = new PushGateway("127.0.0.1:9091");
       pg
.pushAdd(registry, "my_batch_job");
     
}
   
}

This returns an java.net.ConnectException: Connection refused: connect exeception.

What am I doing wrong?
I was not able to find anything about this problem.

Thanks

Chris Marchbanks

unread,
Aug 23, 2018, 5:04:32 PM8/23/18
to benedi...@gmail.com, Prometheus Users
Hello,

From your description you have a running Prometheus instance, but did you also start a Pushgateway instance locally?

--
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/757fc6c9-c331-4249-b92b-07ac6fed813b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Chris Marchbanks | Engineer
FreshTracks.io - Intelligent Alerting for Kubernetes and Prometheus

benedi...@gmail.com

unread,
Aug 24, 2018, 5:27:27 AM8/24/18
to Prometheus Users
Hi Chris,

thanks for your answer.
I think its working now.

But I cannot find my custom metrics in prometheus.

I turned on the honor_labels flag but I cannot find anything.

I don't know whats going on.

Best regards

Chris Marchbanks

unread,
Aug 24, 2018, 10:44:50 AM8/24/18
to Benedikt Lind, Prometheus Users
Glad you made some progress!

What does your prometheus.yml file look like? Have you configured prometheus to scrape your pushgateway instance?
If you have configured prometheus to scrape pushgateway, do your see your custom metrics when you navigate to the pushgateway ui (http://localhost:9091)?


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages