Skip to content

Commit e5f6494

Browse files
dashboard: in-built variable for rate interval
In Grafana 7.2 `$__rate_interval` for Prometheus rate() metrics was introduced [1]. This patch replaces user-specified `$rate_time_range` variable with in-built `$__rate_interval`. Since `$__rate_interval` should be enough to cover all rate cases, this patch also removes all code traces of rate time range configuration. 1. https://grafana.com/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/ Closes #127
1 parent eb0990b commit e5f6494

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1106
-1709
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
## Changed
1313
- Set default Prometheus job to `tarantool`
1414
- Set default InfluxDB measurement to `tarantool_http`
15+
- Use in-built `$__rate_interval` instead of user-defined `$rate_time_range`
1516

1617

1718
## [1.3.0] - 2022-06-29

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
JOB ?= tarantool
2-
RATE_TIME_RANGE ?= 2m
32
POLICY ?= autogen
43
MEASUREMENT ?= tarantool_http
54
OUTPUT_STATIC_DASHBOARD ?= dashboard.json
@@ -17,11 +16,9 @@ ifndef DATASOURCE
1716
false
1817
endif
1918
# JOB is optional, default is "tarantool"
20-
# RATE_TIME_RANGE is optional, default is "2m"
2119
jsonnet -J ./vendor -J . \
2220
--ext-str DATASOURCE=${DATASOURCE} \
2321
--ext-str JOB=${JOB} \
24-
--ext-str RATE_TIME_RANGE=${RATE_TIME_RANGE} \
2522
dashboard/build/prometheus/${DASHBOARD_BUILD_SOURCE} -o ${OUTPUT_STATIC_DASHBOARD}
2623

2724
.PHONY: build-static-prometheus

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ Refer to dashboard [documentation page](https://www.tarantool.io/en/doc/latest/b
5151

5252
You need to set the following variables for Prometheus datasource:
5353

54-
- `Job`,
55-
- `Rate time range` (default valie is `2m`).
54+
- `Job`.
5655

5756
Datasource variables can be obtained from your datasource configuration.
5857
Variables for example monitoring cluster are described in [Monitoring cluster](#monitoring-cluster) section.
@@ -81,8 +80,7 @@ To set up an InfluxDB dashboard for monitoring example app, use the following va
8180

8281
To set up an Prometheus dashboard for monitoring example app, use the following variables:
8382

84-
- `Job`: `tarantool`;
85-
- `Rate time range`: `2m`.
83+
- `Job`: `tarantool`.
8684

8785
### Monitoring local app
8886

@@ -128,7 +126,6 @@ Following targets are available:
128126
Variables for Prometheus targets:
129127
- `DATASOURCE`: name of a Prometheus data source;
130128
- `JOB` (optional, default `tarantool`): name of a Prometheus job collecting your application metrics;
131-
- `RATE_TIME_RANGE` (optional, default `2m`): rps computation rate time range;
132129
- `OUTPUT_STATIC_DASHBOARD` (optional, default `dashboard.json`): compiled dashboard file.
133130

134131
Variables for InfluxDB targets:
@@ -277,7 +274,6 @@ You can add your own custom panels to the bottom of the template dashboard.
277274
datasource_type, # Target datasource type. Use grafana-dashboard/dashboard/variable.libsonnet to fill this value
278275
metric_name, # Target metric name to select
279276
job, # (Prometheus only) Prometheus metrics job. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
280-
rate_time_range, # (Prometheus only) Prometheus rps computation rate time range. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
281277
policy, # (InfluxDB only) InfluxDB metrics policy. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
282278
measurement, # (InfluxDB only) InfluxDB metrics measurement. If you use default input variables, use grafana-dashboard/dashboard/variable.libsonnet to fill this value
283279
)
@@ -292,7 +288,6 @@ You can add your own custom panels to the bottom of the template dashboard.
292288
```jsonnet
293289
datasource=variable.datasource.prometheus,
294290
job=variable.prometheus.job,
295-
rate_time_range=variable.prometheus.rate_time_range
296291
```
297292
in your targets.
298293
@@ -347,7 +342,6 @@ You can add your own custom panels to the bottom of the template dashboard.
347342
datasource_type=variable.datasource_type.prometheus,
348343
metric_name='my_component_load_metric_count',
349344
job=variable.prometheus.job,
350-
rate_time_range=variable.prometheus.rate_time_range,
351345
))
352346
```
353347
Corresponding InfluxDB panels could be built with

dashboard/build/prometheus/dashboard.libsonnet

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ local variable = import 'dashboard/variable.libsonnet';
66
dashboard_raw(
77
datasource=variable.datasource.prometheus,
88
job=variable.prometheus.job,
9-
rate_time_range=variable.prometheus.rate_time_range
109
).addInput(
1110
name='DS_PROMETHEUS',
1211
label='Prometheus',
@@ -20,12 +19,6 @@ dashboard_raw(
2019
type='constant',
2120
value='tarantool',
2221
description='Prometheus Tarantool metrics job'
23-
).addInput(
24-
name='PROMETHEUS_RATE_TIME_RANGE',
25-
label='Rate time range',
26-
type='constant',
27-
value='2m',
28-
description='Time range for computing rps graphs with rate(). At the very minimum it should be two times the scrape interval.'
2922
).addTemplate(
3023
grafana.template.custom(
3124
name='job',
@@ -34,12 +27,4 @@ dashboard_raw(
3427
hide='variable',
3528
label='Prometheus job',
3629
)
37-
).addTemplate(
38-
grafana.template.custom(
39-
name='rate_time_range',
40-
query='${PROMETHEUS_RATE_TIME_RANGE}',
41-
current='${PROMETHEUS_RATE_TIME_RANGE}',
42-
hide='variable',
43-
label='rate() time range',
44-
)
4530
)

dashboard/build/prometheus/dashboard_raw.libsonnet

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local dashboard = import 'dashboard/dashboard.libsonnet';
44
local section = import 'dashboard/section.libsonnet';
55
local variable = import 'dashboard/variable.libsonnet';
66

7-
function(datasource, job, rate_time_range) dashboard.new(
7+
function(datasource, job) dashboard.new(
88
grafana.dashboard.new(
99
title='Tarantool dashboard',
1010
description='Dashboard for Tarantool application and database server monitoring, based on grafonnet library.',
@@ -55,83 +55,71 @@ function(datasource, job, rate_time_range) dashboard.new(
5555
datasource_type=variable.datasource_type.prometheus,
5656
datasource=datasource,
5757
job=job,
58-
rate_time_range=rate_time_range,
5958
)
6059
).addPanels(
6160
section.http(
6261
datasource_type=variable.datasource_type.prometheus,
6362
datasource=datasource,
6463
job=job,
65-
rate_time_range=rate_time_range,
6664
)
6765
).addPanels(
6866
section.net(
6967
datasource_type=variable.datasource_type.prometheus,
7068
datasource=datasource,
7169
job=job,
72-
rate_time_range=rate_time_range,
7370
)
7471
).addPanels(
7572
section.slab(
7673
datasource_type=variable.datasource_type.prometheus,
7774
datasource=datasource,
7875
job=job,
79-
rate_time_range=rate_time_range,
8076
)
8177
).addPanels(
8278
section.space(
8379
datasource_type=variable.datasource_type.prometheus,
8480
datasource=datasource,
8581
job=job,
86-
rate_time_range=rate_time_range,
8782
)
8883
).addPanels(
8984
section.vinyl(
9085
datasource_type=variable.datasource_type.prometheus,
9186
datasource=datasource,
9287
job=job,
93-
rate_time_range=rate_time_range,
9488
)
9589
).addPanels(
9690
section.cpu(
9791
datasource_type=variable.datasource_type.prometheus,
9892
datasource=datasource,
9993
job=job,
100-
rate_time_range=rate_time_range,
10194
)
10295
).addPanels(
10396
section.runtime(
10497
datasource_type=variable.datasource_type.prometheus,
10598
datasource=datasource,
10699
job=job,
107-
rate_time_range=rate_time_range,
108100
)
109101
).addPanels(
110102
section.luajit(
111103
datasource_type=variable.datasource_type.prometheus,
112104
datasource=datasource,
113105
job=job,
114-
rate_time_range=rate_time_range,
115106
)
116107
).addPanels(
117108
section.operations(
118109
datasource_type=variable.datasource_type.prometheus,
119110
datasource=datasource,
120111
job=job,
121-
rate_time_range=rate_time_range,
122112
)
123113
).addPanels(
124114
section.crud(
125115
datasource_type=variable.datasource_type.prometheus,
126116
datasource=datasource,
127117
job=job,
128-
rate_time_range=rate_time_range,
129118
)
130119
).addPanels(
131120
section.expirationd(
132121
datasource_type=variable.datasource_type.prometheus,
133122
datasource=datasource,
134123
job=job,
135-
rate_time_range=rate_time_range,
136124
)
137125
)

dashboard/build/prometheus/dashboard_static.jsonnet

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ local dashboard_raw = import 'dashboard/build/prometheus/dashboard_raw.libsonnet
33
dashboard_raw(
44
datasource=std.extVar('DATASOURCE'),
55
job=std.extVar('JOB'),
6-
rate_time_range=std.extVar('RATE_TIME_RANGE'),
76
).build()

dashboard/build/prometheus/tdg_dashboard.libsonnet

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ local variable = import 'dashboard/variable.libsonnet';
66
tdg_dashboard_raw(
77
datasource=variable.datasource.prometheus,
88
job=variable.prometheus.job,
9-
rate_time_range=variable.prometheus.rate_time_range
109
).addInput(
1110
name='DS_PROMETHEUS',
1211
label='Prometheus',
@@ -20,12 +19,6 @@ tdg_dashboard_raw(
2019
type='constant',
2120
value='tarantool',
2221
description='Prometheus Tarantool metrics job'
23-
).addInput(
24-
name='PROMETHEUS_RATE_TIME_RANGE',
25-
label='Rate time range',
26-
type='constant',
27-
value='2m',
28-
description='Time range for computing rps graphs with rate(). At the very minimum it should be two times the scrape interval.'
2922
).addTemplate(
3023
grafana.template.custom(
3124
name='job',
@@ -34,12 +27,4 @@ tdg_dashboard_raw(
3427
hide='variable',
3528
label='Prometheus job',
3629
)
37-
).addTemplate(
38-
grafana.template.custom(
39-
name='rate_time_range',
40-
query='${PROMETHEUS_RATE_TIME_RANGE}',
41-
current='${PROMETHEUS_RATE_TIME_RANGE}',
42-
hide='variable',
43-
label='rate() time range',
44-
)
4530
)

0 commit comments

Comments
 (0)