For use from Go see the [Push](http://godoc.org/github.com/prometheus/client_golang/prometheus#Push) and [PushAdd](http://godoc.org/github.com/prometheus/client_golang/prometheus#PushAdd) functions.
For use from Go see the [Push](http://godoc.org/github.com/prometheus/client_golang/prometheus#Push) and [PushAdd](http://godoc.org/github.com/prometheus/client_golang/prometheus#PushAdd) functions.
## Java Batch Job Example
This example illustrates how to instrument a batch job and alert on it not having succeeded recently.
If using Maven, add the following to `pom.xml`:
```
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>0.0.6</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId>
<version>0.0.6</version>
</dependency>
```
Instrument your batch job's code:
```java
importio.prometheus.client.CollectorRegistry;
importio.prometheus.client.Gauge;
importio.prometheus.client.exporter.PushGateway;
voidexecuteBatchJob()throwsException{
CollectorRegistryregistry=newCollectorRegistry();
Gaugeduration=Gauge.build()
.name("my_batch_job_duration_seconds")
.help("Duration of my batch job in seconds.")
.register(registry);
Gauge.TimerdurationTimer=duration.startTimer();
try{
// Your code here.
// This is only added to the registry after success,
// so that a previous success in the Pushgateway is not overwritten on failure.
GaugelastSuccess=Gauge.build()
.name("my_batch_job_last_success_unixtime")
.help("Last time my batch job succeeded, in unixtime.")