This project contains some sample code to expose internal data of a java application to prometheus.
Just type
./gradlew run
This starts SampleService.java which runs indefinitely. Every 3 secs it picks another random number from 0 to 100 and prints it. That value will also be exposed to prometheus via a http server on port 1234. In a real life scenario that port will be pulled from a prometheus server actively.
There’s also code for using Prometheus pushgateway.
Note
|
pushgatway code is commented out by default |