---
title: "JVM integration | Grafana Cloud documentation"
description: "Learn about JVM Grafana Cloud integration."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# JVM integration for Grafana Cloud

A Java Virtual Machine (JVM) provides a runtime environment that converts Java bytecode into machine language, allowing computers to run Java programs. This integration enables Grafana Alloy to send metrics to Grafana Cloud from JVM apps instrumented with Prometheus JVM client, Micrometer library (Springboot), or with OpenTelemetry.

This integration includes 2 useful alerts and 1 pre-built dashboard to help monitor and visualize JVM metrics.

## Before you begin

To instrument your JVM application with Prometheus client, please follow the official instrumentation guide [client\_java](https://github.com/prometheus/client_java#using).

## Install JVM integration for Grafana Cloud

1. In your Grafana Cloud stack, click **Connections** in the left-hand menu.
2. Find **JVM** and click its tile to open the integration.
3. Review the prerequisites in the **Configuration Details** tab and set up Grafana Alloy to send JVM metrics to your Grafana Cloud instance.
4. Click **Install** to add this integration’s pre-built dashboard and alerts to your Grafana Cloud instance, and you can start monitoring your JVM setup.

## Configuration snippets for Grafana Alloy

### Simple mode

These snippets are configured to scrape a single JVM instance running locally with default ports.

First, **manually** copy and append the following snippets into your alloy configuration file.

### Metrics snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
discovery.relabel "metrics_integrations_integrations_jvm" {
	targets = [{
		__address__ = "localhost:1234",
	}]

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}
}

prometheus.scrape "metrics_integrations_integrations_jvm" {
	targets    = discovery.relabel.metrics_integrations_integrations_jvm.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/jvm"
}
```

### Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your JVM instances, **manually** copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

### Advanced metrics snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
discovery.relabel "metrics_integrations_integrations_jvm" {
	targets = [{
		__address__ = "localhost:1234",
	}]

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}
}

prometheus.scrape "metrics_integrations_integrations_jvm" {
	targets    = discovery.relabel.metrics_integrations_integrations_jvm.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/jvm"
}
```

To monitor your JVM instance, you must use a [discovery.relabel](/docs/alloy/latest/reference/components/discovery.relabel/) component to discover your JVM Prometheus endpoint and apply appropriate labels, followed by a [prometheus.scrape](/docs/alloy/latest/reference/components/prometheus.scrape) component to scrape it.

Configure the following properties within each `discovery.relabel` component:

- `__address__`: The address to your JVM Prometheus metrics endpoint.
- `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this JVM instance.

If you have multiple JVM servers to scrape, configure one `discovery.relabel` for each and scrape them by including each under `targets` within the `prometheus.scrape` component.

## Dashboards

The JVM integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

- JVM overview

**JVM overview**

## Alerts

The JVM integration includes the following useful alerts:

Expand table

| Alert                | Description                          |
|----------------------|--------------------------------------|
| JvmMemoryFillingUp   | Warning: JVM heap memory filling up. |
| JvmThreadsDeadlocked | Critical: JVM deadlock detected.     |

## Metrics

The most important metrics provided by the JVM integration, which are used on the pre-built dashboard and Prometheus alerts, are as follows:

- java\_lang\_classloading\_loadedclasscount
- java\_lang\_memory\_heapmemoryusage\_committed
- java\_lang\_memory\_heapmemoryusage\_max
- java\_lang\_memory\_heapmemoryusage\_used
- java\_lang\_memory\_nonheapmemoryusage\_committed
- java\_lang\_memory\_nonheapmemoryusage\_max
- java\_lang\_memory\_nonheapmemoryusage\_used
- java\_lang\_operatingsystem\_cpuload
- java\_lang\_operatingsystem\_processcputime
- java\_lang\_operatingsystem\_systemloadaverage
- java\_lang\_runtime\_starttime
- java\_lang\_runtime\_uptime
- java\_lang\_threading\_daemonthreadcount
- java\_lang\_threading\_peakthreadcount
- java\_lang\_threading\_threadcount
- jvm\_buffer\_memory\_used\_bytes
- jvm\_buffer\_pool\_capacity\_bytes
- jvm\_buffer\_pool\_used\_bytes
- jvm\_buffer\_total\_capacity\_bytes
- jvm\_classes\_loaded
- jvm\_classes\_loaded\_classes
- jvm\_gc\_collection\_seconds\_count
- jvm\_gc\_collection\_seconds\_sum
- jvm\_gc\_memory\_allocated\_bytes\_total
- jvm\_gc\_memory\_promoted\_bytes\_total
- jvm\_gc\_pause\_seconds\_count
- jvm\_gc\_pause\_seconds\_max
- jvm\_gc\_pause\_seconds\_sum
- jvm\_memory\_bytes\_committed
- jvm\_memory\_bytes\_max
- jvm\_memory\_bytes\_used
- jvm\_memory\_committed\_bytes
- jvm\_memory\_max\_bytes
- jvm\_memory\_pool\_allocated\_bytes\_total
- jvm\_memory\_pool\_bytes\_committed
- jvm\_memory\_pool\_bytes\_max
- jvm\_memory\_pool\_bytes\_used
- jvm\_memory\_pool\_committed\_bytes
- jvm\_memory\_pool\_max\_bytes
- jvm\_memory\_pool\_used\_bytes
- jvm\_memory\_used\_bytes
- jvm\_threads\_current
- jvm\_threads\_daemon
- jvm\_threads\_daemon\_threads
- jvm\_threads\_deadlocked
- jvm\_threads\_live\_threads
- jvm\_threads\_peak
- jvm\_threads\_peak\_threads
- jvm\_threads\_state
- jvm\_threads\_states\_threads
- process\_cpu\_seconds\_total
- process\_cpu\_usage
- process\_files\_max
- process\_files\_max\_files
- process\_files\_open
- process\_files\_open\_files
- process\_max\_fds
- process\_open\_fds
- process\_resident\_memory\_bytes
- process\_runtime\_jvm\_buffer\_limit
- process\_runtime\_jvm\_buffer\_limit\_bytes
- process\_runtime\_jvm\_buffer\_usage
- process\_runtime\_jvm\_buffer\_usage\_bytes
- process\_runtime\_jvm\_classes\_loaded
- process\_runtime\_jvm\_classes\_loaded\_total
- process\_runtime\_jvm\_cpu\_utilization
- process\_runtime\_jvm\_cpu\_utilization\_ratio
- process\_runtime\_jvm\_gc\_duration\_bucket
- process\_runtime\_jvm\_gc\_duration\_count
- process\_runtime\_jvm\_gc\_duration\_seconds\_bucket
- process\_runtime\_jvm\_gc\_duration\_seconds\_count
- process\_runtime\_jvm\_memory\_allocation\_count
- process\_runtime\_jvm\_memory\_committed
- process\_runtime\_jvm\_memory\_committed\_bytes
- process\_runtime\_jvm\_memory\_limit
- process\_runtime\_jvm\_memory\_limit\_bytes
- process\_runtime\_jvm\_memory\_usage
- process\_runtime\_jvm\_memory\_usage\_bytes
- process\_runtime\_jvm\_system\_cpu\_load\_1m
- process\_runtime\_jvm\_system\_cpu\_utilization
- process\_runtime\_jvm\_system\_cpu\_utilization\_ratio
- process\_runtime\_jvm\_threads\_count
- process\_start\_time
- process\_start\_time\_seconds
- process\_uptime
- process\_uptime\_seconds
- runtime\_uptime\_milliseconds\_total
- system\_cpu\_count
- system\_cpu\_usage
- system\_load\_average\_1m
- up

## Changelog

md ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```md
# 2.1.0 - September 2024

* Add new additional source:
    - OpenTelemetry JVM process metrics (with suffixes (add_metric_suffixes=true))

# 2.0.0 - August 2024

* New mixin based on JVM observability lib:
  - Add support for universal dashboard and alerts supporting metrics from different sources at the same time:
    - Prometheus library (compatible with older naming schema)
    - JMX exporter (both http and agent modes)
    - JVM metrics from Spring boot (micrometer)
    - OpenTelemetry JVM process metrics
  - Add JvmThreadsDeadlocked alert

# 1.0.0 - May 2024

* Update mixin to accommodate exporter metric name changes

# 0.0.5 - September 2023

* Update Grafana Agent configuration snippets to include filtered metrics used in gauge panels

# 0.0.4 - September 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.3 - September 2022

* Update dashboard panels descriptions.

# 0.0.2 - October 2021

* Update mixin to latest version:
  - Update the datasource template variable label to 'Data Source'
  - Update all rate queries to use `$__rate_interval` so they respect the default resolution

# 0.0.1 - October 2020

* Initial release
```

## Cost

By connecting your JVM instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see [Active series and dpm usage](/docs/grafana-cloud/fundamentals/active-series-and-dpm/) and [Cloud tier pricing](/products/cloud/pricing/).
