While the Java client library uses pom.xml and Maven, there's nothing stopping you from using other tools such as Gradle

The example dependencies for the Java client are for Maven, if you have an existing Gradle project​ the equivalents will look something like:

dependencies {
 compile group: 'io.prometheus', name: 'simpleclient', version: '0.5.0'
 compile group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.5.0'
 compile group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.5.0'
}

 

If you're starting from scratch, I've created a sample project to get you going. After ensuring Gradle is installed:

git clone https://github.com/RobustPerception/prometheus_examples
cd prometheus_examples/java_examples/java_gradle/
gradle jar
java -jar ./build/libs/java_gradle.jar

If you now visit :8000/metrics you'll see your metrics!

 

Want to learn more about instrumenting Java? Contact us.