# Prometheus via micrometer from spring

**URL:** <https://discuss.elastic.co/t/prometheus-via-micrometer-from-spring/288636>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [November 8, 2021, 2:23pm UTC](https://discuss.elastic.co/t/prometheus-via-micrometer-from-spring/288636 "2021-11-08T14:23:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ziemowit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ziemowit/32/96546_2.png) [@Ziemowit](https://discuss.elastic.co/u/Ziemowit)\
**Post date:** [November 8, 2021, 2:23pm UTC](https://discuss.elastic.co/t/prometheus-via-micrometer-from-spring/288636/1 "2021-11-08T14:23:00Z")

</div>

I am exposing the memory metrics in Prometheus format from my spring application via micrometer.

The response is following:

```auto
# HELP jvm_buffer_count_buffers An estimate of the number of buffers in the pool
# TYPE jvm_buffer_count_buffers gauge
jvm_buffer_count_buffers{id="mapped - 'non-volatile memory'",} 0.0
jvm_buffer_count_buffers{id="mapped",} 0.0
jvm_buffer_count_buffers{id="direct",} 22.0
# HELP jvm_memory_used_bytes The amount of used memory
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",id="G1 Survivor Space",} 6914696.0
jvm_memory_used_bytes{area="heap",id="G1 Old Gen",} 8.6028288E7
jvm_memory_used_bytes{area="nonheap",id="Metaspace",} 8.037428E7
jvm_memory_used_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 1382528.0
jvm_memory_used_bytes{area="heap",id="G1 Eden Space",} 6.0817408E7
jvm_memory_used_bytes{area="nonheap",id="Compressed Class Space",} 1.06606E7
jvm_memory_used_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 1.6343936E7
# HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management
# TYPE jvm_memory_max_bytes gauge
jvm_memory_max_bytes{area="heap",id="G1 Survivor Space",} -1.0
jvm_memory_max_bytes{area="heap",id="G1 Old Gen",} 4.171235328E9
jvm_memory_max_bytes{area="nonheap",id="Metaspace",} -1.0
jvm_memory_max_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 7553024.0
jvm_memory_max_bytes{area="heap",id="G1 Eden Space",} -1.0
jvm_memory_max_bytes{area="nonheap",id="Compressed Class Space",} 1.073741824E9
jvm_memory_max_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 2.44105216E8
# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use
# TYPE jvm_memory_committed_bytes gauge
jvm_memory_committed_bytes{area="heap",id="G1 Survivor Space",} 8388608.0
jvm_memory_committed_bytes{area="heap",id="G1 Old Gen",} 1.3631488E8
jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 8.1752064E7
jvm_memory_committed_bytes{area="nonheap",id="CodeHeap 'non-nmethods'",} 2555904.0
jvm_memory_committed_bytes{area="heap",id="G1 Eden Space",} 1.572864E8
jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 1.112064E7
jvm_memory_committed_bytes{area="nonheap",id="CodeHeap 'non-profiled nmethods'",} 1.6384E7
# HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool
# TYPE jvm_buffer_memory_used_bytes gauge
jvm_buffer_memory_used_bytes{id="mapped - 'non-volatile memory'",} 0.0
jvm_buffer_memory_used_bytes{id="mapped",} 0.0
jvm_buffer_memory_used_bytes{id="direct",} 426845.0
# HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers in this pool
# TYPE jvm_buffer_total_capacity_bytes gauge
jvm_buffer_total_capacity_bytes{id="mapped - 'non-volatile memory'",} 0.0
jvm_buffer_total_capacity_bytes{id="mapped",} 0.0
jvm_buffer_total_capacity_bytes{id="direct",} 426844.0

```

But the Metricbeat fails on:

> Error fetching data for metricset prometheus.collector: unable to decode response from prometheus endpoint: decoding of metric family failed: text format parsing error in line 12: invalid escape sequence '"'

My configuration is:

```auto
metricbeat.autodiscover:
  providers:
    - type: docker
      labels.dedot: true
      templates:
        - condition:
            contains:
              docker.container.image: foo
          config:
            - module: prometheus
              period: 10s
              metricsets: ["collector"]
              hosts: ["http://${data.host}:${data.port}/actuator/prometheus"]
              metrics_path: /metrics

```

Is it some bug? Or should I make some extra configurations?

---

<div class="post-metadata">

**Author:** ![mtojek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtojek/32/63863_2.png) [@mtojek](https://discuss.elastic.co/u/mtojek)\
**Post date:** [November 10, 2021, 1:23pm UTC](https://discuss.elastic.co/t/prometheus-via-micrometer-from-spring/288636/2 "2021-11-10T13:23:51Z")

</div>

Are you sure about the configuration?

```auto
              hosts: ["http://${data.host}:${data.port}/actuator/prometheus"]
              metrics_path: /metrics

```

Did you try something like this:

```auto
hosts: ["http://${data.host}:${data.port}]
metrics_path: "/actuator/prometheus/metrics"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 8, 2021, 1:24pm UTC](https://discuss.elastic.co/t/prometheus-via-micrometer-from-spring/288636/3 "2021-12-08T13:24:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
