Skip to content

Commit 95462ab

Browse files
add parametrize
1 parent 93b92d7 commit 95462ab

File tree

2 files changed

+66
-21
lines changed

2 files changed

+66
-21
lines changed

dashboard/panels/cpu.libsonnet

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ local prometheus = grafana.prometheus;
9191
influxdb.target(
9292
rawQuery=true,
9393
// query=|||
94-
// SELECT non_negative_derivative(sum("value"), 1s)
94+
// SELECT non_negative_derivative(SUM("value"), 1s)
9595
// FROM "$policy"."$measurement"
9696
// WHERE (("metric_name" = 'tnt_cpu_user_time' OR "metric_name" = 'tnt_cpu_system_time') AND "label_pairs_alias" =~ /^$alias$/)
9797
// AND $timeFilter
9898
// GROUP BY time($__interval), "label_pairs_alias" fill(none)
9999
// |||,
100100
query=std.format(|||
101-
SELECT non_negative_derivative(sum("value"), 1s)
101+
SELECT non_negative_derivative(SUM("value"), 1s)
102102
FROM %(measurement_with_policy)s
103103
WHERE (("metric_name" = '%(metric_user_time)s' OR "metric_name" = '%(metric_system_time)s') AND %(filters)s)
104104
AND $timeFilter
@@ -194,7 +194,7 @@ local prometheus = grafana.prometheus;
194194
// GROUP BY time($__interval)
195195
// |||,
196196
influx_query=std.format(|||
197-
SELECT non_negative_derivative(sum("value"), 1s)
197+
SELECT non_negative_derivative(SUM("value"), 1s)
198198
FROM %(measurement_with_policy)s
199199
WHERE (("metric_name" = '%(metric_user_time)s' OR "metric_name" = '%(metric_system_time)s') AND %(filters)s)
200200
AND $timeFilter

dashboard/panels/runtime.libsonnet

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ local variable = import 'dashboard/variable.libsonnet';
104104

105105
total_memory(
106106
cfg,
107-
title='Total memory usage',
107+
title='Total memory per cluster',
108108
description=|||
109109
Total memory used by Tarantool.
110110
|||,
@@ -130,20 +130,37 @@ local variable = import 'dashboard/variable.libsonnet';
130130
else if cfg.type == variable.datasource_type.influxdb then
131131
influxdb.target(
132132
rawQuery=true,
133-
query=|||
134-
SELECT SUM("value") AS total_memory_per_cluster
135-
FROM "$policy"."$measurement"
136-
WHERE ("metric_name" = 'tnt_memory' OR "metric_name" = 'tnt_memory_virt')
133+
// query=|||
134+
// SELECT SUM("value") AS total_memory_per_cluster
135+
// FROM "$policy"."$measurement"
136+
// WHERE ("metric_name" = 'tnt_memory' OR "metric_name" = 'tnt_memory_virt')
137+
// AND $timeFilter
138+
// GROUP BY time($__interval)
139+
// |||,
140+
query=std.format(|||
141+
SELECT SUM("value")
142+
FROM %(measurement_with_policy)s
143+
WHERE (("metric_name" = '%(metric_memory)s' OR "metric_name" = '%(metric_memory_virt)s') AND %(filters)s)
137144
AND $timeFilter
138145
GROUP BY time($__interval)
139-
|||,
146+
|||, {
147+
measurement_with_policy: std.format('%(policy_prefix)s"%(measurement)s"', {
148+
policy_prefix: if cfg.policy == 'default' then '' else std.format('"%(policy)s".', cfg.policy),
149+
measurement: cfg.measurement,
150+
}),
151+
metric_memory: cfg.metrics_prefix + 'tnt_memory',
152+
metric_memory_virt: cfg.metrics_prefix + 'tnt_memory_virt',
153+
filters: if common.influxdb_query_filters(common.remove_field(cfg.filters, 'label_pairs_alias')) != ''
154+
then common.influxdb_query_filters(common.remove_field(cfg.filters, 'label_pairs_alias'))
155+
else 'true',
156+
}),
140157
alias=title,
141158
)
142159
),
143160

144161
total_resident_memory(
145162
cfg,
146-
title='Total resident memory usage',
163+
title='Total resident memory per cluster',
147164
description=|||
148165
Resident memory used by Tarantool instance.
149166
|||,
@@ -160,20 +177,34 @@ local variable = import 'dashboard/variable.libsonnet';
160177
else if cfg.type == variable.datasource_type.influxdb then
161178
influxdb.target(
162179
rawQuery=true,
163-
query=|||
164-
SELECT SUM("value") AS total_resident_memory
165-
FROM "$policy"."$measurement"
166-
WHERE "metric_name" = 'tnt_memory' AND "label_pairs_alias" =~ /^$alias$/
180+
// query=|||
181+
// SELECT SUM("value") AS total_resident_memory
182+
// FROM "$policy"."$measurement"
183+
// WHERE "metric_name" = 'tnt_memory' AND "label_pairs_alias" =~ /^$alias$/
184+
// AND $timeFilter
185+
// GROUP BY time($__interval)
186+
// |||,
187+
query=std.format(|||
188+
SELECT SUM("value")
189+
FROM %(measurement_with_policy)s
190+
WHERE "metric_name" = '%(metric_memory)s' AND %(filters)s
167191
AND $timeFilter
168192
GROUP BY time($__interval)
169-
|||,
193+
|||, {
194+
measurement_with_policy: std.format('%(policy_prefix)s"%(measurement)s"', {
195+
policy_prefix: if cfg.policy == 'default' then '' else std.format('"%(policy)s".', cfg.policy),
196+
measurement: cfg.measurement,
197+
}),
198+
metric_memory: cfg.metrics_prefix + 'tnt_memory',
199+
filters: common.influxdb_query_filters(cfg.filters),
200+
}),
170201
alias=title,
171202
)
172203
),
173204

174205
total_virtual_memory(
175206
cfg,
176-
title='Total virtual memory usage',
207+
title='Total virtual memory per cluster',
177208
description=|||
178209
Virtual memory used by Tarantool instance.
179210
|||,
@@ -190,13 +221,27 @@ local variable = import 'dashboard/variable.libsonnet';
190221
else if cfg.type == variable.datasource_type.influxdb then
191222
influxdb.target(
192223
rawQuery=true,
193-
query=|||
194-
SELECT SUM("value") AS total_virt_memory
195-
FROM "$policy"."$measurement"
196-
WHERE "metric_name" = 'tnt_memory_virt' AND "label_pairs_alias" =~ /^$alias$/
224+
// query=|||
225+
// SELECT SUM("value") AS total_virt_memory
226+
// FROM "$policy"."$measurement"
227+
// WHERE "metric_name" = 'tnt_memory_virt' AND "label_pairs_alias" =~ /^$alias$/
228+
// AND $timeFilter
229+
// GROUP BY time($__interval)
230+
// |||,
231+
query=std.format(|||
232+
SELECT SUM("value")
233+
FROM %(measurement_with_policy)s
234+
WHERE "metric_name" = '%(metric_memory_virt)s' AND %(filters)s
197235
AND $timeFilter
198236
GROUP BY time($__interval)
199-
|||,
237+
|||, {
238+
measurement_with_policy: std.format('%(policy_prefix)s"%(measurement)s"', {
239+
policy_prefix: if cfg.policy == 'default' then '' else std.format('"%(policy)s".', cfg.policy),
240+
measurement: cfg.measurement,
241+
}),
242+
metric_memory_virt: cfg.metrics_prefix + 'tnt_memory_virt',
243+
filters: common.influxdb_query_filters(cfg.filters),
244+
}),
200245
alias=title,
201246
)
202247
),

0 commit comments

Comments
 (0)