Skip to content

Commit be826fc

Browse files
make: build from YAML config
To build a dashboard from YAML config, run ``` CONFIG=config.yml make build ``` Part of #206 Part of #207
1 parent ffcce51 commit be826fc

File tree

9 files changed

+28
-10
lines changed

9 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Option to skip Prometheus job on static build
1212
- Option to static build with custom set of sections
1313
- Custom description and Grafana tags on manual build
14+
- API to build a dashboard from YAML config
1415

1516
### Changed
1617
- Display two digits after decimal point instead of three

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ POLICY ?= autogen
33
MEASUREMENT ?= tarantool_http
44
WITH_INSTANCE_VARIABLE ?= FALSE
55
OUTPUT_STATIC_DASHBOARD ?= dashboard.json
6+
OUTPUT ?= dashboard.json
67
TITLE ?=
78

89
.PHONY: build-deps
@@ -12,6 +13,17 @@ build-deps:
1213
jb install
1314

1415

16+
.PHONY: build
17+
build:
18+
ifndef CONFIG
19+
@echo 1>&2 "CONFIG=config.yml must be set"
20+
false
21+
endif
22+
jsonnet -J ./vendor -J . \
23+
-e "local build = import 'dashboard/build/from_config.libsonnet'; local file = importstr '${CONFIG}'; build(std.parseYaml(file))" \
24+
-o ${OUTPUT}
25+
26+
1527
_build-static-prometheus:
1628
ifndef DATASOURCE
1729
@echo 1>&2 "DATASOURCE must be set"
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local config = import 'dashboard/build/config.libsonnet';
2+
local dashboard = import 'dashboard/build/dashboard.libsonnet';
3+
4+
function(cfg)
5+
dashboard(config.prepare(cfg)).build()

dashboard/build/from_ext_var.jsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local config = import 'dashboard/build/config.libsonnet';
2-
local dashboard_raw = import 'dashboard/build/dashboard_raw.libsonnet';
2+
local dashboard = import 'dashboard/build/dashboard.libsonnet';
33

44
local DATASOURCE_TYPE = std.extVar('DATASOURCE_TYPE');
55
local DASHBOARD_TEMPLATE = std.extVar('DASHBOARD_TEMPLATE');
@@ -90,4 +90,4 @@ local cfg =
9090
sections: sections,
9191
});
9292

93-
dashboard_raw(cfg).build()
93+
dashboard(cfg).build()

dashboard/build/influxdb/dashboard.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local config = import 'dashboard/build/config.libsonnet';
2-
local dashboard_raw = import 'dashboard/build/dashboard_raw.libsonnet';
2+
local dashboard = import 'dashboard/build/dashboard.libsonnet';
33
local variable = import 'dashboard/variable.libsonnet';
44

55
local cfg = config.prepare({
@@ -29,4 +29,4 @@ local cfg = config.prepare({
2929
],
3030
});
3131

32-
dashboard_raw(cfg)
32+
dashboard(cfg)

dashboard/build/influxdb/tdg_dashboard.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local config = import 'dashboard/build/config.libsonnet';
2-
local dashboard_raw = import 'dashboard/build/dashboard_raw.libsonnet';
2+
local dashboard = import 'dashboard/build/dashboard.libsonnet';
33
local variable = import 'dashboard/variable.libsonnet';
44

55
local cfg = config.prepare({
@@ -38,4 +38,4 @@ local cfg = config.prepare({
3838
],
3939
});
4040

41-
dashboard_raw(cfg)
41+
dashboard(cfg)

dashboard/build/prometheus/dashboard.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local config = import 'dashboard/build/config.libsonnet';
2-
local dashboard_raw = import 'dashboard/build/dashboard_raw.libsonnet';
2+
local dashboard = import 'dashboard/build/dashboard.libsonnet';
33
local variable = import 'dashboard/variable.libsonnet';
44

55
local cfg = config.prepare({
@@ -27,4 +27,4 @@ local cfg = config.prepare({
2727
],
2828
});
2929

30-
dashboard_raw(cfg)
30+
dashboard(cfg)

dashboard/build/prometheus/tdg_dashboard.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local config = import 'dashboard/build/config.libsonnet';
2-
local dashboard_raw = import 'dashboard/build/dashboard_raw.libsonnet';
2+
local dashboard = import 'dashboard/build/dashboard.libsonnet';
33
local variable = import 'dashboard/variable.libsonnet';
44

55
local cfg = config.prepare({
@@ -36,4 +36,4 @@ local cfg = config.prepare({
3636
],
3737
});
3838

39-
dashboard_raw(cfg)
39+
dashboard(cfg)

0 commit comments

Comments
 (0)