Kotlin DSL for generating Grafana dashboards.
- Grafana Dashboards as a Code: review and vcs control over dashboards
- Reusable dashboards, panels, configs, etc
- Share visualization style across different metrics
- Easy to keep metrics up-to-date
- Easy to extend to most features of Grafana
- Easy to include in CI cycle: dashboard is a JSON-document
- Power of Kotlin language
- Graphite (
./src/examples/kotlin/ru/yoomoney/tech/grafana/dsl/examples/GrafanaGraphiteDemoLayouts.kts
) - Prometheus (
./src/examples/kotlin/ru/yoomoney/tech/grafana/dsl/examples/GrafanaPrometheusDemoLayouts.kts
) - Zabbix
See documentation at Grafana Dashboard Plugin
build.gradle
sourceSets {
grafana {
kotlin
}
}
dependencies {
grafanaCompile 'ru.yoomoney.tech:grafana-dashboard-dsl:3.0.0'
}
Code for dashboards generation must be placed in ${projectDir}/src/grafana/kotlin/
. Generation performed manually:
import ru.yoomoney.tech. grafana.dsl.dashboard
fun main(args: Array<String>) {
println(dashboard(title = "My custom dashboard") {
panels {
// ...
}
})
}
Examples are in ./src/examples/kotlin/ru/yoomoney/tech/grafana/dsl/examples
To create new dashboards, panels, metrics, and others, create a class (usually with postfix *Configuration
or*Builder
),
mark it with annotation ru.yoomoney.tech.grafana.dsl.DashboardElement
, and create data-class for it's contents,
that's implements ru.yoomoney.tech.grafana.dsl.json.Json
For example see DashboardBuilder
and Dashboard
classes
Just fork the repo and send us a pull request.
Make sure your branch builds without any warnings/issues.