Skip to main content

Grid Toolkit for Grafana

Generate similar but varying dashboards from code with many variations for hundreds of environments. Based on grafanalib

Installation and Quick Start

❯❯❯ virtualenv .py3
❯❯❯ source .py3/bin/activate

❯❯❯ pip install noroutine-grit

❯❯❯ python -m grit -h

# Inspect examples
❯❯❯ python -m grit inspect --module examples.dashboards
# Example output
---
name: examples.dashboards
folders:
- jmeter
- mongodb
variations:
  environment:
  - dev
  - prod
  - qa
  - test

# Generate dashboards for all environments
❯❯❯ python -m grit generate --module examples.dashboards --out 'out/{environment}' --var 'environment=*' 
# Example output 
Generating out/dev
Generating out/prod
Generating out/qa
Generating out/test

Overview

Example dashboard

GritDash(
    uid="human-id",
    version=8,
    title="your dashboard title",
    description="your dashboards description",
    tags=[
        'tag1',
        'tag2'
    ],
    timezone="browser",
    # Apply datasource to all panels in the dashboard
    dataSource="Prometheus",
    stack=Stack(
        row7(panel1),
        # Use simple utilities, row6 is row of panels of height 6
        row6(panel1, panel2),
        # Autosize panels, this will be 3 equal panels in the row
        row5(panel1, panel2, panel3),
        # ... or 4, if you want, no need to calculate coordinates
        row4(panel1, panel2, panel3, panel4),
        # ... sometimes less is more
        row3(panel1, panel2, panel3, panel4, panel5),
    )
)

Variations

Variations allow to create a different collection of dashboards from same code base, for example per-environment variation can be achieved with Environment variation.

You can create multiple variations, and quickly generate hundreds of dashboards

# Variation is just subclass of Variation
class Environment(Variation):
  color: str = "green"

Environment(name="dev", color="blue")
Environment(name="qa")
Environment(name="test")
Environment(name="prod", color="red")

When writing dashboard you can access specific variation values by calling <VariationClass>.resolve()

# Illustrative code
environment = Environment.resolve()
print(environment.color)
print(environment.name)

You create as many variations as you want and combine them

class Environment(Variation):
  color: str = "green"

Environment(name="dev", color="blue")
Environment(name="qa")
Environment(name="test")
Environment(name="prod", color="red")

class Turn(Variation):
  pass

class Taste(Variation):
  pass

class Animal(Variation):
  pass

Turn(name="first")
Turn(name="second")
Turn(name="third")

Taste(name="sweet")
Taste(name="sour")

Animal(name="rabbit")
Animal(name="donkey")
Animal(name="turtle")
Animal(name="rat")

And use all of them during generation, you can template output directory structure to your liking!

❯❯❯ python -m grit generate --module grafana.dashboards --out 'out/{turn}-{taste}-{animal}-company/{environment}' --var environment=qa environment=prod animal=* turn=first taste=sweet
Generating out/first-sweet-donkey-company/qa
Generating out/first-sweet-donkey-company/prod
Generating out/first-sweet-rabbit-company/qa
Generating out/first-sweet-rabbit-company/prod
Generating out/first-sweet-rat-company/qa
Generating out/first-sweet-rat-company/prod
Generating out/first-sweet-turtle-company/qa
Generating out/first-sweet-turtle-company/prod

Command-Line

Inspect dashboards

❯❯❯ python -m grit inspect --module dashboards
---
name: dashboards
folders:
- jmeter
- mongodb
variations:
  environment:
  - dev
  - nab-dev
  - nab-prod
  - prod
  - qa
  - test

Publish to Grafana

# Needs .env file with some vars
❯❯❯ python -m grit publish --module grafana.dashboards --var environment=dev

Generate to output directory

❯❯❯ python -m grit generate --module grafana.dashboards --out 'out/{environment}' --var environment=*
Generating out/dev
Generating out/nab-dev
Generating out/nab-prod
Generating out/prod
Generating out/qa
Generating out/test

Utilities

Rows

You have some handy utilities

Predefined row heights

Each creating row of respective height

  • row3
  • row4
  • row5
  • row6
  • row7
  • row8

How to develop

virtualenv .py3
source .py3/bin/activate
pip install -r requirements.txt
export PYTHONPATH=src
python -m grit --version

Metadata

Release files for noroutine-grit 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noroutine-grit 0.0.8
File Size Uploaded Provenance Actions
noroutine-grit-0.0.8.tar.gz 11.6 kB Without provenance Details for noroutine-grit-0.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for noroutine-grit 0.0.8
File Interpreter ABI Platform Actions
noroutine_grit-0.0.8-py3-none-any.whl Python 3 none any Details for noroutine_grit-0.0.8-py3-none-any.whl

Total release size: 24.0 kB

Release files / noroutine-grit-0.0.8.tar.gz

Download URL noroutine-grit-0.0.8.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
497775523feaff4f97b2a9a96961d79e490d90a15490fdfcd355cec4e0b47a75
BLAKE2b-256 checksum
How to use checksums
ca1d89126cdfd514c20092612a0ba4ec7174bb1d7e812262ee89c8d9aec36f12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / noroutine_grit-0.0.8-py3-none-any.whl

Download URL noroutine_grit-0.0.8-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9aeecf3ea357e945950bfe5bb31c0758034c3ea8826ad2c72c88fb856cf60ea
BLAKE2b-256 checksum
How to use checksums
e5a319e3f78e624764d0e3baf61a3f79307e3dca7281d288306809ac26129177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for noroutine-grit 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page