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