1

I have a Spring Boot Java app and am sending metrics to a hierarchical Graphite metrics system. I'm using the management.metrics.export.graphite.tags-as-prefix and mapping host and app to prefix my metrics. I then have a metric with namespace jvm.memory.committed, but the metric namespace is coming over the wire as host.app.jvmMemoryCommitted.*. So it's replacing dots (".") in the metric namespace and camelCasing the following piece of the namespace.

application.properties management.metrics.export.graphite.tags-as-prefix=[host, app]

Customizer for tags as prefix.

    @Bean
    public MeterRegistryCustomizer<MeterRegistry> commonTags() {
        return r -> r.config().commonTags("host", "localhost", "app", "app");
    }

When I look at the .../actuator/metrics/jvm.memory.committed endpoint I see the following:

  "name": "jvm.memory.committed",
  "description": "The amount of memory in bytes that is committed for the Java virtual machine to use",
  "baseUnit": "bytes",
  "measurements": [
    {
      "statistic": "VALUE",
      "value": 759701504
    }
  ],
  "availableTags": [
    {
      "tag": "area",
      "values": [
        "heap",
        "nonheap"
      ]
    },
    {
      "tag": "app",
      "values": [
        "app"
      ]
    },
    {
      "tag": "host",
      "values": [
        "localhost"
      ]
    },
    {
      "tag": "id",
      "values": [
        "G1 Old Gen",
        "CodeHeap 'non-profiled nmethods'",
        "G1 Survivor Space",
        "Compressed Class Space",
        "Metaspace",
        "G1 Eden Space",
        "CodeHeap 'non-nmethods'"
      ]
    },
  ]
}

However, when the metrics are being sent with the metric names changed from *.jvm.memory.committed.* to *.jvmMemoryCommitted.*. How can I preserve the metrics namespace in dot-notation?

See the tcpdump output below:

$ sudo tcpdump -i any -A -s0 -vv udp port 2003 | grep -i committed
tcpdump: data link type PKTAP
tcpdump: listening on any, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes
....E....5..@............E...p..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Eden_Space 178257920.00 1628102627
....E....5..@............E...p..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Eden_Space 178257920.00 1628102627
....E...o...@............E...m..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Old_Gen 465567744.00 1628102627
....E...o...@............E...m..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Old_Gen 465567744.00 1628102627
....E.......@............E...s..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Survivor_Space 10485760.00 1628102627
....E.......@............E...s..localhost.app.jvmMemoryCommitted.area.heap.id.G1_Survivor_Space 10485760.00 1628102627
....E...m...@............E...{..localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-nmethods' 3604480.00 1628102627
....E...m...@............E...{..localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-nmethods' 3604480.00 1628102627
....E....J..@............E......localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-profiled_nmethods' 10420224.00 1628102627
....E....J..@............E......localhost.app.jvmMemoryCommitted.area.nonheap.id.CodeHeap_'non-profiled_nmethods' 10420224.00 1628102627
....E.......@............E...z..localhost.app.jvmMemoryCommitted.area.nonheap.id.Compressed_Class_Space 9306112.00 1628102627
....E.......@............E...z..localhost.app.jvmMemoryCommitted.area.nonheap.id.Compressed_Class_Space 9306112.00 1628102627
....E....,..@............E...n..localhost.app.jvmMemoryCommitted.area.nonheap.id.Metaspace 69607424.00 1628102627
....E....,..@............E...n..localhost.app.jvmMemoryCommitted.area.nonheap.id.Metaspace 69607424.00 1628102627
^C444 packets captured
3200 packets received by filter
0 packets dropped by kernel```

I think the problem is that I'm using tags, but in a Hierarchical metrics system, but I can't figure out how to configure it properly. I can't seem to find my folly.

Spring Boot 2.5.2
Micrometer Core and Micrometer Registry Graphite 1.7.2
  • You were detailed in your question setup, but I can't tell what the exact question is. Can you state what you expect to happen and what isn't happening? – checketts Aug 04 '21 at 14:53
  • 1
    @checketts I've edited the post slightly. Sorry for the ambiguity. My question is how I can preserve the metric name in dot-notation as is typical for hierarchical metrics rather than the dot-notation getting camelCase'd. After thinking on it, I removed the MeterRegistryCustomizer bean that I had and tried creating a bean GraphiteMeterRegiry bean as shown in the documentation below. With that I no longer see any prefix and the dot-notation to camelCase is still happening. https://micrometer.io/docs/registry/graphite#_prefixing_your_metrics – twoversionsofme Aug 04 '21 at 19:38

1 Answers1

0

Graphite uses a HierarchicalNameMapper to convert the metric names and tags into a hierarchical string.

See https://micrometer.io/docs/registry/graphite#_hierarchical_name_mapping

I'm not certain why you mapper is camelCasing your metric name, but you can set the HierarchicalNameMapper when you construct your own GraphiteMeterRegistry and have fine tuned control of how they are generated.

checketts
  • 14,167
  • 10
  • 53
  • 82