---
title: PromQL Note for Adding JVM Version Information to Micrometer Metrics
tags: ["Spring Boot", "Micrometer", "Prometheus"]
categories: ["Observability", "Prometheus"]
date: 2024-07-11T07:47:09Z
updated: 2024-07-11T07:47:09Z
---

> ⚠️ This article was automatically translated by OpenAI (gpt-4o-mini).
> It may be edited eventually, but please be aware that it may contain incorrect information at this time.

This is a PromQL note for adding JVM version information to Micrometer's Prometheus metrics.

JVM information can be obtained from the following metric.

```
jvm_info{app="lognroll"}
```

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/de467cb9-3876-4a1c-a820-d08d3448eff5">


I want to add this information to the following metric.

```
jvm_memory_used_bytes{app="lognroll"}
```


<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/f84629b4-1369-4dc8-8187-97968c3dc6dd">


We will use the `*` operator for multiplication. Since the value of `jvm_info` is `1`, the result will ultimately return the value of `jvm_memory_used_bytes`. We specify the matching labels with `on (...)` and keep the left labels with `group_left`.

```
jvm_memory_used_bytes{app="lognroll"} * on (app, instance) group_left(version, runtime, vendor) jvm_info{app="lognroll"}
```

<img width="1024" alt="image" src="https://github.com/making/blog.ik.am/assets/106908/52fe1974-5d91-47e7-80a7-c4013cdf1a53">

> [!NOTE]
> Exposing the software version to Prometheus
> https://www.robustperception.io/exposing-the-software-version-to-prometheus/
