Spring boot application that pulls metrics data from Hasura Pro Metrics Service and notifies a downstream client (eg. Slack, etc,.)
- Access to a Hasura Pro Backend (LUX) service, especially the Metrics service URL and its admin-secret.
- Slack App/Channel to post the error messages and User/Bot token to authenticate with the Slack API (Reference) having correct scopes.
- Add the Hasura Metrics service Graphql API URl, Metrics servcie admin secret, Slack USer/Bot token and Slack channel/App id to application.properties file.
- Build and run the Spring boot application.
- The class ErrorFetchingService.java has the funtion that queries the metrics API to get the errors that occurred in the last 10 seconds.
- The class ErrorNotificationJob.java has the scheduler that runs the above query every 10 seconds (Configurable in code). For Non empty responses , it calls the
notify
method in SlackNotifier.java to post the error to Slack.
- The metrics service of LUX is itself a Hasura graphql engine and the Hasura console is exposed (by default) on port 8080 of the container/pod. The
graphiql
view of metrics service is self-documenting about the metrics exposed as graphql-apis. They can be consumed just like any other Graphql resources from other applications.- An easy way to access the metrics service's console is to use
kubectl port-forward
(Reference). To map local port 8090 to port 8080 of the metrics pod (by default has name matching the wildcardmetrics-*
, for examplemetrics-54ffd6d96d-k5c6h
), usekubectl port-forward metrics-54ffd6d96d-k5c6h 8090:8080
. Now the Hasura console for metrics is availble athttp://localhost:8090
.
- An easy way to access the metrics service's console is to use