Prometheus via micrometer from spring

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

The response is following:

# 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:

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?

Are you sure about the configuration?

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

Did you try something like this:

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

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