I am trying to visualise my Spring application (still on localhost until now) metrics with grafana. To do that, first I configured a connection pool with HikariCP and I added monituring features with Jmx (MBean). Until this step every things works fine.
Then I started Grafana, a Prometheus and a jmx-prometheus-exporter docker containers.
Here is my docker compose file
version: '3'
services:
grafana:
image: grafana/grafana:latest
ports:
- 3000:3000
prometheus:
image: prom/prometheus:latest
ports:
- 9090:9090
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
jmx-exporter:
image: sscaling/jmx-prometheus-exporter
ports:
- 5556:5556
And here is prometheus configuration file
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
labels:
group: 'prometheus'
- job_name: 'app-server'
static_configs:
- targets: ['localhost:8080']
- job_name: 'jmx-exporter'
static_configs:
- targets: ['jmx-exporter:5556']
in the prometheus: "http://localhost:9090/targets"
I could see the jmx-prometheus-exporter and prometheus itself as healthy services.
When visiting http://localhost:5556/
I see some values, but there is nothing that shows that they are specific to my application ( I don't see the pool name I have set ...) and it seems logic because I don't see where how the jmx container is configured to read metrics from my application (local jmx)
# TYPE java_lang_MemoryPool_UsageThresholdSupported untyped
java_lang_MemoryPool_UsageThresholdSupported{name="Metaspace",} 1.0
java_lang_MemoryPool_UsageThresholdSupported{name="PS Old Gen",} 1.0
java_lang_MemoryPool_UsageThresholdSupported{name="PS Eden Space",} 0.0
java_lang_MemoryPool_UsageThresholdSupported{name="Code Cache",} 1.0
java_lang_MemoryPool_UsageThresholdSupported{name="Compressed Class Space",} 1.0
java_lang_MemoryPool_UsageThresholdSupported{name="PS Survivor Space",} 0.0
# HELP java_lang_Threading_ThreadContentionMonitoringEnabled ThreadContentionMonitoringEnabled (java.lang<type=Threading><>ThreadContentionMonitoringEnabled)
# TYPE java_lang_Threading_ThreadContentionMonitoringEnabled untyped
java_lang_Threading_ThreadContentionMonitoringEnabled 0.0
# HELP java_lang_OperatingSystem_CommittedVirtualMemorySize CommittedVirtualMemorySize (java.lang<type=OperatingSystem><>CommittedVirtualMemorySize)
My question is, I want to expose my application metrics in order to be read in the jmx-prometheus-exporter container ( https://github.com/sscaling/docker-jmx-prometheus-exporter), and I don't see how to configure that, ( the exporter java agent solution may work but I want something dockerized)