grafanacountermicrometerredis-streams

How to meter an external counter in Micrometer?


I want to meter an external system counter in Micrometer.

For the context: I want to provide Redis Streams specific metrics like https://redis.io/docs/latest/commands/xinfo-groups/

There is a field called entries-read, and the docs says:

entries-read: the logical "read counter" of the last entry delivered to the group's consumers

I noticed I cannot use Micrometer Counter because it only increases the value.

Should I use Gauge for this type of external counter or there is another way?


Solution

  • If it is truly a counter (monotonic), you can use FunctionCounter, you can find many use-cases in Micrometer's codebase.

    If it is not (non-monotonic), you can use a Gauge.