Package: noroutine-grit
Grid Toolkit for GrafanaGenerate similar but varying dashboards from code with many variations for hundreds of environments. Based on grafanalibInstallation and Quick Start❯❯❯virtualenv.py3
❯❯❯source.py3/bin/activate

❯❯❯pipinstallnoroutine-grit

❯❯❯python-mgrit-h# Inspect examples❯❯❯python-mgritinspect--moduleexamples.dashboards# Example output---
name:examples.dashboards
folders:
-jmeter
-mongodb
variations:environment:-dev-prod-qa-test# Generate dashboards for all environments❯❯❯python-mgritgenerate--moduleexamples.dashboards--out'out/{environment}'--var'environment=*'# Example outputGeneratingout/dev
Generatingout/prod
Generatingout/qa
Generatingout/testOverviewExample dashboardGritDash(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 dashboarddataSource="Prometheus",stack=Stack(row7(panel1),# Use simple utilities, row6 is row of panels of height 6row6(panel1,panel2),# Autosize panels, this will be 3 equal panels in the rowrow5(panel1,panel2,panel3),# ... or 4, if you want, no need to calculate coordinatesrow4(panel1,panel2,panel3,panel4),# ... sometimes less is morerow3(panel1,panel2,panel3,panel4,panel5),))VariationsVariations 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 VariationclassEnvironment(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 codeenvironment=Environment.resolve()print(environment.color)print(environment.name)You create as many variations as you want and combine themclassEnvironment(Variation):color:str="green"Environment(name="dev",color="blue")Environment(name="qa")Environment(name="test")Environment(name="prod",color="red")classTurn(Variation):passclassTaste(Variation):passclassAnimal(Variation):passTurn(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-mgritgenerate--modulegrafana.dashboards--out'out/{turn}-{taste}-{animal}-company/{environment}'--varenvironment=qaenvironment=prodanimal=*turn=firsttaste=sweet
Generatingout/first-sweet-donkey-company/qa
Generatingout/first-sweet-donkey-company/prod
Generatingout/first-sweet-rabbit-company/qa
Generatingout/first-sweet-rabbit-company/prod
Generatingout/first-sweet-rat-company/qa
Generatingout/first-sweet-rat-company/prod
Generatingout/first-sweet-turtle-company/qa
Generatingout/first-sweet-turtle-company/prodCommand-LineInspect dashboards❯❯❯ python -m grit inspect --module dashboards---name:dashboardsfolders:-jmeter-mongodbvariations:environment:-dev-nab-dev-nab-prod-prod-qa-testPublish to Grafana# Needs .env file with some vars
❯❯❯ python -m grit publish --module grafana.dashboards --var environment=devGenerate to output directory❯❯❯python-mgritgenerate--modulegrafana.dashboards--out'out/{environment}'--varenvironment=*
Generatingout/dev
Generatingout/nab-dev
Generatingout/nab-prod
Generatingout/prod
Generatingout/qa
Generatingout/testUtilitiesRowsYou have some handy utilitiesPredefined row heightsEach creating row of respective heightrow3row4row5row6row7row8How to developvirtualenv .py3
source .py3/bin/activate
pip install -r requirements.txt
export PYTHONPATH=src
python -m grit --version