Giter Site home page Giter Site logo

metrist-grafana-datasource's Introduction

Metrist Datasource for Grafana

Getting started

Add the golang and mage plugin through asdf and install the required versions stated in .tool-versions

 asdf plugin-add golang
 asdf plugin-add mage
 asdf plugin-add nodejs
 asdf install

Quickest way to get started is to run

# NPM
npm ci

# Go
go get
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest # Required for openapi codegen
asdf reshim

mage -v                          # Build the backend
npm run dev                      # Build the frontend
npm run server                   # Run grafana server
npm run server:with-plugin       # Run grafana server with the datasource plugin ready to be installed pointed to dev
npm run server:with-plugin-local # Run grafana server with the datasource plugin ready to be installed pointed to local
npm run server:with-plugin-prod  # Run grafana server with the datasource plugin ready to be installed pointed to prod

Running the Frontend, Backend and Installing the plugin

  1. Run npm run server:with-plugin
  2. In a separate terminal run the frontend npm run dev
  3. Head over to http://localhost:3000/datasources -> Add data source -> Search for Metrist
  4. Click on the Metrist plugin. This will install the plugin
  5. Configure the API Key and click Save and test

Frontend

  1. Install dependencies

    npm install
  2. Build plugin in development mode or run in watch mode

    npm run dev
    
    # or
    
    npm run watch
  3. Build plugin in production mode

    npm run build
  4. Run the tests (using Jest)

    # Runs the tests and watches for changes
    npm run test
    
    # Exists after running all the tests
    npm run lint:ci
  5. Spin up a Grafana instance and run the plugin inside it (using Docker)

    npm run server
  6. Run the E2E tests (using Cypress)

    # Spin up a Grafana instance first that we tests against
    npm run server
    
    # Start the tests
    npm run e2e
  7. Run the linter

    npm run lint
    
    # or
    
    npm run lint:fix

Backend

  1. Update Grafana plugin SDK for Go dependency to the latest minor version:

    go get
  2. Build backend plugin binaries for Linux, Windows and Darwin:

    mage -v
  3. List all available Mage targets for additional commands:

    mage -l

OpenAPI Generated Code

The code in pkg/internal/openapi.go is generated by oapi-codegen. Our backend exposes an openapi v3 spec at /api/openapi which codegen can use

  1. install oapi codegen go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest then asdf reshim if using asdf

  2. Run the following to generate the go file

    oapi-codegen -package internal -generate types,client <url to /api/openapi for backend>.yaml >  pkg/internal/openapi.go

Learn more

Below you can find source code for existing app plugins and other related documentation.

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.