Metric for version number

8/8/2018

Is it possible to add some metrics to a Java system that will return the version number as a string for the application that is monitored?

I am aiming for a dashboard where each pod, running a Java application inside a Docker container, in a Kubernetes cluster is monitored and the current version of each Java application is viewed.

If it isn't possible, do you have an idea on how to get that information from the Java application and make it available in a Grafana dashboard?

-- Thomas Sundberg
grafana
java
kubernetes
prometheus

1 Answer

8/8/2018

In your application, you can make available a Gauge metric that uses labels to export e.g. a version number or commit/build hash and then set the value of the gauge to 1.

For example, this is how the redis_exporter exports information about a redis instance:

# HELP redis_instance_info Information about the Redis instance
# TYPE redis_instance_info gauge
redis_instance_info{addr="redis://localhost:6379",os="Linux 4.4.0-62-generic x86_64",redis_build_id="687a2a319020fa42",redis_mode="standalone",redis_version="3.0.6",role="master"} 1

You can see the version and a couple of other attributes exported as labels of the metric redis_instance_info.

-- Oliver
Source: StackOverflow