vernemq / vernemq_demo_plugin

A VerneMQ plugin demonstrating the authentication and authorization hooks.
6 stars 8 forks source link

Can we write a new plugin for create a new metrics ? #1

Closed namjithwisilica closed 6 years ago

namjithwisilica commented 6 years ago

For example count of messages on a specific topic in last one hour?

ioolkos commented 6 years ago

@namjithwisilica hi & thanks for asking. I guess this is not possible as a plugin. The reason for that is that plugins use clearly defined entry points (hooks into the message/auth/etc flow). It is of course possible to add more metrics as a core extension to VerneMQ though.

ioolkos commented 6 years ago

Actually, let me be a little more precise: Technically, a plugin is just an application that you can start alongside VerneMQ. So it's possible to create an app, that can hold additional metrics for you, and then send information to that app via the normal hooks.

To hold info about last hour message rate in a topic, you'd use the on_publish hook to send metrics to your app. (in Erlang terms, this could be a simple gen_server, holding an ETS table with your metrics).

Your metrics would not show up as part of the normal VerneMQ metrics.