Grafana 的网格工具包
项目描述
Grafana 的网格工具包
根据数百个环境的多种变体代码生成相似但不同的仪表板。基于 grafanalib
安装和快速入门
❯❯❯ 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
概述
示例仪表板
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),
)
)
变化
变体允许从相同的代码库创建不同的仪表板集合,例如每个环境的变体可以通过环境变体来实现。
您可以创建多个变体,并快速生成数百个仪表板
# 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")
编写仪表板时,您可以通过调用访问特定的变体值<VariationClass>.resolve()
# Illustrative code
environment = Environment.resolve()
print(environment.color)
print(environment.name)
您可以根据需要创建尽可能多的变体并将它们组合起来
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")
并在生成过程中使用它们,您可以根据自己的喜好模板输出目录结构!
❯❯❯ 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
命令行
检查仪表板
❯❯❯ python -m grit inspect --module dashboards
---
name: dashboards
folders:
- jmeter
- mongodb
variations:
environment:
- dev
- nab-dev
- nab-prod
- prod
- qa
- test
发布到 Grafana
# Needs .env file with some vars
❯❯❯ python -m grit publish --module grafana.dashboards --var environment=dev
生成到输出目录
❯❯❯ 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
实用程序
行
你有一些方便的实用程序
预定义的行高
各自高度的每个创建行
row3row4row5row6row7row8
如何发展
virtualenv .py3
source .py3/bin/activate
pip install -r requirements.txt
export PYTHONPATH=src
python -m grit --version
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
noroutine-grit-0.0.8.tar.gz
(11.6 kB
查看哈希)
内置分布
noroutine_grit-0.0.8-py3-none-any.whl
(12.4 kB
查看哈希)
关
noroutine_grit -0.0.8-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | b9aeecf3ea357e945950bfe5bb31c0758034c3ea8826ad2c72c88fb856cf60ea |
|
| MD5 | faeb582b41bf36854de7cf581179ab98 |
|
| 布莱克2-256 | e5a319e3f78e624764d0e3baf61a3f79307e3dca7281d288306809ac26129177 |