Way to list defined Metrics & Graphs?

Is there a way to list all registered instances of Metric & Graph? Use case is that when developing a plugin, whatever its type, its useful to re-use existing metric & graph definitions as not having to reinvent the wheel. However, it seems pretty difficult to determine which actually exist, given that we aren’t used metric_info anymore.

I often find myself instantiating a Metric only to find errors about it having been defined already in ~site/var/log/apache/error.log

I’d be fine with any method, be it some kind of clever CLI tool usage or even a piece of code to insert somewhere that goes through the registered instances & prints them to some kind of log file. Ideally I’d like a method that not only goes through base CheckMK, but also through installed third-party packages.

Thanks.

PS: I’m aware of this list, but that one has a couple of drawbacks:

  • seems to be pre-2.3.0/2.4.0 era
  • only lists the metric names, not their definitions, which is kind of important for scaling (bits? bytes?) and type to get right (e.g. number of bytes vs. bytes per second…)
2 Likes

AFAIK there is no way to do this anymore :frowning: However I would also appreciate if this functionality could be added to the new plugins API.

For me this was also a severe problem when migrating plugins to the new API since we built a plugin that parses Prometheus metrics and tries to reuse existing metric definitions (especially render functions). Our current workaround is to implement the required definitions ourselves.

1 Like

Yeah, same, thanks. And then look at the logs & delete those for which the aforementioned error about duplicate metrics occurs. Definitely not the best way to go about things.