Giter VIP home page Giter VIP logo

hasura-metrics-demo's Introduction

hasura-metrics-demo

Spring boot application that pulls metrics data from Hasura Pro Metrics Service and notifies a downstream client (eg. Slack, etc,.)

Pre-requisites

  • 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.

Running the application

  • 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.

How it works!

  • 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.

Extending for other metrics

  • 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 wildcard metrics-*, for example metrics-54ffd6d96d-k5c6h), use kubectl port-forward metrics-54ffd6d96d-k5c6h 8090:8080 . Now the Hasura console for metrics is availble at http://localhost:8090 .

hasura-metrics-demo's People

Contributors

sandeepsamba avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.