Skip to main content
Collect JVM metrics with the OpenTelemetry Java agent and send them to ClickHouse Observability. Use the demo dataset to try the integration without instrumenting an application.

Prerequisites

  • A ClickHouse Observability service
  • For your own metrics, a Java 8+ application and access to its startup command or environment
  • For the demo, Docker and curl

Connection details

Open ClickHouse Observability and go to Team Settings → Data → Managed Telemetry. Copy your OTLP HTTP endpoint and API key. You can use Copy connection details to copy the configuration, or Reveal key to view the masked key.Set these variables in the terminal where you will start your application or demo collector:
Replace the placeholders with the exact endpoint, including its port, and API key from your service. Use the base HTTP endpoint without a /v1/metrics suffix; the exporter appends the signal path.
The endpoint must be reachable from your application. For the Docker demo, it must also be reachable from the collector container. For a destination collector running on this computer, use http://host.docker.internal:4318. The Docker commands below include the host mapping.

Integration with an existing JVM application

1

Download the Java agent

Download OpenTelemetry Java agent 2.22.0:
2

Configure and start your application

Set the connection variables, then configure the agent:
Replace my-application.jar with your application JAR and adjust the agent path if needed. Choose a service name that identifies your application. These settings collect metrics only. If your application already exports traces or logs, keep its existing exporter settings for those signals.For applications managed by a service or container, add the agent to the existing JVM startup arguments and supply the environment variables through your deployment configuration. See the Java agent configuration documentation.
3

Verify metrics

Allow at least two minutes for the agent to export metrics. Open Chart Explorer, select your Metrics source, and find jvm.memory.used or jvm.thread.count. Filter for ServiceName:jvm-service and select Last 15 minutes.

Demo dataset

The sample contains 6,048 gauge points sampled every five minutes and all 412 garbage-collection events from the original dataset. It covers roughly 24 hours of memory, thread, class, CPU, and GC activity. No Java application or direct database access is needed. Set the connection variables before starting.
1

Download the sample metrics

Download the demo bundle and extract it in your working directory. It contains jvm-metrics-demo.json and jvm-metrics-dashboard.json.
2

Configure the demo collector

Save this as jvm-metrics-demo.yaml:
The demo-only transform refreshes timestamps while preserving metric values and the interval between each point’s start and end timestamps. Omit it for live JVM metrics. The batch limit keeps uploads small enough for the destination collector.
3

Run the demo collector

From the directory containing the configuration, run the collector and leave this terminal open:
4

Send the sample

In another terminal, run this command from the download directory:
A response such as {} or {"partialSuccess":{}} indicates the local collector accepted the request. Check the collector terminal for export errors and allow a few seconds for forwarding. Stop it with Ctrl+C after verifying the data. Sending the sample again can produce duplicate points.
5

Verify the metrics

Import the dashboard in the next section, filter for ServiceName:jvm-demo, and select Last 2 days. The sample includes both gauge and sum metrics; no direct database access is needed.

Dashboards and visualization

1

2

Import the dashboard

  1. Open Dashboards and click Import in the upper-right corner.
  2. Upload jvm-metrics-dashboard.json.
  3. Map the charts to your Metrics source and click Finish Import.
3

View the dashboard

For the sample, filter for ServiceName:jvm-demo and select Last 2 days.The dashboard shows heap memory, GC pauses, threads, metaspace, CPU, and loaded classes from the sample.
The sample uses an older JVM metric schema. For Java agent 2.22.0, select the sum metric type for memory, thread, class, and CPU time metrics, and histogram for GC duration. Memory and count metrics are non-monotonic sums: use their current values rather than a rate. Update the chart filters and grouping to use jvm.memory.type, jvm.memory.pool.name, jvm.thread.state, and jvm.gc.name. See the JVM metric conventions for the current schema.

Troubleshooting

Agent does not start

Check that the agent JAR exists at the path passed to -javaagent, that the application can read it, and that Java is version 8 or later. Inspect the application startup output for agent errors.

No metrics appearing

  • Check application or demo collector output for authentication and export errors.
  • Confirm the endpoint is reachable from the application or container and that the protocol is http/protobuf.
  • Check the Metrics source, service-name filter, and time range. Use Last 2 days for the demo.
  • For an existing collector, confirm its metrics pipeline includes the OTLP receiver and a metrics exporter.
  • If the demo collector accepts the request but no data arrives, check its terminal for forwarding errors.

Next steps