Skip to content
Advertisement

Aggregate metric with unique id over defined time period in micrometer?

In spring-boot metrics ( with micromter and prometheous ) I can get no of log events for each threshold as follows.

HELP logback_events_total Number of error level events that made it to the logs
TYPE logback_events_total counter
logback_events_total{level="info"} 98.0
logback_events_total{level="debug"} 46.0
logback_events_total{level="trace"} 0.0
logback_events_total{level="warn"} 6.0
logback_events_total{level="error"} 2.0

This shows aggregation for each log level for whole application time. I want similar custom metrics but aggregate over defined time period. Ex: I have unique ID for operation and I want no of such operation happens over 5 min time.

  1. However I am having hard time to find such example. Therefore can anyone point me source location for above metrics in spring boot project ? ( Class name would be sufficient )
  2. Is it possible to aggregate metric with unique id over defined time period in micrometer ?

Advertisement

Answer

Adding a unique Id might ruin your metrics if it has high cardinality, I would really suggest not to do that. If you want to attach arbitrary tags to your existing meters, you can register a MeterFilter that lets you adding tags to meters.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement