Skip to content

Commit b2d8727

Browse files
dashboard: set InfluxDB measurement dynamically
After this patch, user may choose InfluxDB measurement from the list of measurements with Tarantool metrics instead of manually setting up a constant measurement on import. Part of #185
1 parent bbb57cc commit b2d8727

File tree

9 files changed

+623
-580
lines changed

9 files changed

+623
-580
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Changed
1010
- Replace LuaJit deprecated metrics with new ones
1111
- Set Prometheus `job` dynamically
12+
- Set InfluxDB `measurement` dynamically
1213

1314

1415
## [1.5.0] - 2022-09-22

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Refer to dashboard [documentation page](https://www.tarantool.io/en/doc/latest/b
4646

4747
You need to set the following variables for InfluxDB datasource:
4848

49-
- `Measurement`,
5049
- `Policy` (default valie is `autogen`).
5150

5251
Datasource variables can be obtained from your datasource configuration.
5352
You can choose `job` variable value for Prometheus datasource after import.
53+
You can choose `measurement` variable value for InfluxDB datasource after import.
5454
Variables for example monitoring cluster are described in [Monitoring cluster](#monitoring-cluster) section.
5555

5656

@@ -72,7 +72,6 @@ You can also interact with Prometheus at [localhost:9090](http://localhost:9090/
7272

7373
To set up an InfluxDB dashboard for monitoring example app, use the following variables:
7474

75-
- `Measurement`: `tarantool_http`;
7675
- `Policy`: `default`.
7776

7877
### Monitoring local app

dashboard/build/influxdb/dashboard.libsonnet

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ dashboard_raw(
1515
pluginId='influxdb',
1616
pluginName='InfluxDB',
1717
description='InfluxDB Tarantool metrics bank'
18-
).addInput(
19-
name='INFLUXDB_MEASUREMENT',
20-
label='Measurement',
21-
type='constant',
22-
value='tarantool_http',
23-
description='InfluxDB Tarantool metrics measurement'
2418
).addInput(
2519
name='INFLUXDB_POLICY',
2620
label='Policy',
2721
type='constant',
2822
value='autogen',
2923
description='InfluxDB Tarantool metrics policy'
24+
).addTemplate(
25+
grafana.template.new(
26+
name='measurement',
27+
datasource=variable.datasource.influxdb,
28+
query=std.format('SHOW MEASUREMENTS WHERE "metric_name"=\'%s\'', variable.metrics.tarantool_indicator),
29+
label='Measurement',
30+
refresh='load',
31+
)
3032
).addTemplate(
3133
grafana.template.new(
3234
name='alias',

dashboard/build/influxdb/tdg_dashboard.libsonnet

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ tdg_dashboard_raw(
1515
pluginId='influxdb',
1616
pluginName='InfluxDB',
1717
description='InfluxDB Tarantool metrics bank'
18-
).addInput(
19-
name='INFLUXDB_MEASUREMENT',
20-
label='Measurement',
21-
type='constant',
22-
value='tarantool_http',
23-
description='InfluxDB Tarantool metrics measurement'
2418
).addInput(
2519
name='INFLUXDB_POLICY',
2620
label='Policy',
2721
type='constant',
2822
value='autogen',
2923
description='InfluxDB Tarantool metrics policy'
24+
).addTemplate(
25+
grafana.template.new(
26+
name='measurement',
27+
datasource=variable.datasource.influxdb,
28+
query=std.format('SHOW MEASUREMENTS WHERE "metric_name"=\'%s\'', variable.metrics.tarantool_indicator),
29+
label='Measurement',
30+
refresh='load',
31+
)
3032
).addTemplate(
3133
grafana.template.new(
3234
name='alias',

dashboard/variable.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
influxdb: {
1515
policy: '${INFLUXDB_POLICY}',
16-
measurement: '${INFLUXDB_MEASUREMENT}',
16+
measurement: '$measurement',
1717
alias: '/^$alias$/',
1818
},
1919
metrics: {

doc/monitoring/grafana_dashboard.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ To import a specific dashboard, choose one of the following options:
208208
- upload the dashboard JSON file.
209209

210210
Set dashboard name, folder, uid (if needed), and datasource-related query parameters
211-
(InfluxDB source, measurement and policy or Prometheus source).
211+
(InfluxDB source and policy or Prometheus source).
212212

213213
.. image:: images/grafana_import_setup.png
214214
:align: left

0 commit comments

Comments
 (0)