Giter Club home page Giter Club logo

grafonnet-example's Introduction

Grafonnet example

This repository contains an example of a Grafana dashboard as code, defined with Grafonnet, continuously deployed to a Grafana Cloud instance, thanks to Grizzly and GitHub Actions.

What's here?

Looking for building your own example?

If you're a learning-by-doing kind of person, you can follow the steps below to build your own example.

Pre-requisites

First of all, you need to have these tools up and running before starting:

Step by step

  1. Initialize a new project:

    jb init
  2. Add Grafonnet as dependency:

    jb install github.com/grafana/grafonnet/gen/grafonnet-latest@main
  3. Create an example.jsonnet file with a basic dashboard:

    local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet';
    
    g.dashboard.new('Grafonnet example')
    + g.dashboard.withDescription('Example dashboard built with Grafonnet')
  4. Create a dashboards.libsonnet file with the main definition:

    {
      grafanaDashboards+:: {
        'example.json': (import 'example.jsonnet'),
      },
    }

    NOTE: It basically imports the example dashboard we defined in the previous step

  5. Set up Grafana auth for Grizzly as Actions secrets:

    • GRAFANA_URL with the root url of your instance
    • GRAFANA_TOKEN with your service account token
  6. Set up GitHub Actions to automatically grr apply your changes on every push to main:

    # .github/workflows/deploy.yml
    
    name: deploy
    
    on:
      push:
        branches:
          - main
    
    jobs:
      deploy:
        runs-on: ubuntu-latest
        container:
          image: grafana/grizzly:0.2.1-amd64
          env:
            GRAFANA_URL: ${{ secrets.GRAFANA_URL }}
            GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }}
        steps:
          - name: Check out code
            uses: actions/checkout@v3
          - name: Deploy dashboards
            run: grr apply dashboards.libsonnet -l debug
  7. Push new changes on example.jsonnet to main and enjoy!

Contribute

Have you detected a typo or something incorrect, and you are willing to contribute?

Please, open a pull request, and I'll be happy to review it.

grafonnet-example's People

Stargazers

 avatar  avatar  avatar

Watchers

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