Add prometheus metrics endpoint
We should think about adding an endpoint which exports metrics for prometheus (https://prometheus.io/) so that we can easily monitor a Fusio app. As client we should use s. https://packagist.org/packages/promphp/prometheus_client_php
Hi I would like to work on this issue can you let me know how i can solve this issue.
Hi @sreenath-tm this sounds great, so the task is not easy but I try to make a rough guide.
Using the Prometheus PHP Client
At first you need to checkout the https://github.com/apioo/fusio-impl repository, this is the place where all backend logic is contained. Then we need to add the promphp/prometheus_client_php as dependency and also add a new method to the container https://github.com/apioo/fusio-impl/blob/master/src/Dependency/Container.php to expose the client as service. There we also need to configure the fitting storage for the client i.e. redis etc., we need to see whats the best way is to configure those settings.
Add an event listener
If we have a client we then need to create a new EventListener i.e. PrometheusListener which listens for specific events and collects metrics from the system i.e. in case a user was created etc. As reference you can take a look at the https://github.com/apioo/fusio-impl/blob/master/src/EventListener/WebhookListener.php
Create a route
Then we need to create a route which exposes the collected information. We should probably expose those information under the /system route since for now I would think, that we dont need any authentication for this endpoint.
Therefor you need to create a fitting action under https://github.com/apioo/fusio-impl/tree/master/src/System/Action and then you need to register the route i.e. /system/prometheus at https://github.com/apioo/fusio-impl/blob/master/src/Migrations/NewInstallation.php#L541
So these are just the first pointers, please feel free to take a look at it and let me know in case you have further questions.