From 74628a978b47df5c45a3ff2a540c47aace2f79b4 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Wed, 29 May 2024 16:43:50 +0200 Subject: [PATCH] mixin: add tooltip with all series on Queries dashboard (#8179) * mixin: add tooltip with all series on Queries dashbaord Before After This PR also adds a utility to make this easier. Signed-off-by: Dimitar Dimitrov * Don't overwrite options Signed-off-by: Dimitar Dimitrov * Update tests Signed-off-by: Dimitar Dimitrov --------- Signed-off-by: Dimitar Dimitrov --- .../metamonitoring/grafana-dashboards.yaml | 14 +++--- .../dashboards/mimir-queries.json | 8 ++-- .../dashboards/mimir-rollout-progress.json | 2 +- .../dashboards/mimir-tenants.json | 2 +- .../dashboards/mimir-writes-resources.json | 2 +- .../dashboards/mimir-queries.json | 8 ++-- .../dashboards/mimir-rollout-progress.json | 2 +- .../dashboards/mimir-tenants.json | 2 +- .../dashboards/mimir-writes-resources.json | 2 +- .../dashboards/dashboard-utils.libsonnet | 45 +++++++------------ .../mimir-mixin/dashboards/queries.libsonnet | 2 + .../dashboards/rollout-progress.libsonnet | 4 +- .../mimir-mixin/dashboards/tenants.libsonnet | 18 ++------ .../dashboards/writes-resources.libsonnet | 4 +- 14 files changed, 45 insertions(+), 70 deletions(-) diff --git a/operations/helm/tests/metamonitoring-values-generated/mimir-distributed/templates/metamonitoring/grafana-dashboards.yaml b/operations/helm/tests/metamonitoring-values-generated/mimir-distributed/templates/metamonitoring/grafana-dashboards.yaml index 36948547a3..53e5892f8a 100644 --- a/operations/helm/tests/metamonitoring-values-generated/mimir-distributed/templates/metamonitoring/grafana-dashboards.yaml +++ b/operations/helm/tests/metamonitoring-values-generated/mimir-distributed/templates/metamonitoring/grafana-dashboards.yaml @@ -12724,8 +12724,8 @@ data: "showLegend": true }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, "span": 4, @@ -12772,8 +12772,8 @@ data: "showLegend": true }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, "span": 4, @@ -26210,7 +26210,7 @@ data: "stacking": "none", "tooltip": { "mode": "multi", - "sort": "none" + "sort": "desc" }, "xField": "Workload", "xTickLabelRotation": 0, @@ -34459,7 +34459,7 @@ data: }, "tooltip": { "mode": "multi", - "sort": "none" + "sort": "desc" } }, "span": 6, @@ -37814,7 +37814,7 @@ data: "showLegend": true }, "tooltip": { - "mode": "single", + "mode": "multi", "sort": "desc" } }, diff --git a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-queries.json b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-queries.json index 9dc428d4cf..f5ff32848f 100644 --- a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-queries.json +++ b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-queries.json @@ -1696,8 +1696,8 @@ "showLegend": true }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, "span": 4, @@ -1744,8 +1744,8 @@ "showLegend": true }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, "span": 4, diff --git a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-rollout-progress.json b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-rollout-progress.json index 734a630e0b..58a60488fd 100644 --- a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-rollout-progress.json +++ b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-rollout-progress.json @@ -122,7 +122,7 @@ "stacking": "none", "tooltip": { "mode": "multi", - "sort": "none" + "sort": "desc" }, "xField": "Workload", "xTickLabelRotation": 0, diff --git a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-tenants.json b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-tenants.json index 7baa6f3094..99f8939032 100644 --- a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-tenants.json +++ b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-tenants.json @@ -2431,7 +2431,7 @@ }, "tooltip": { "mode": "multi", - "sort": "none" + "sort": "desc" } }, "span": 6, diff --git a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-writes-resources.json b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-writes-resources.json index fa17ba1326..c7818c4257 100644 --- a/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-writes-resources.json +++ b/operations/mimir-mixin-compiled-baremetal/dashboards/mimir-writes-resources.json @@ -480,7 +480,7 @@ "showLegend": true }, "tooltip": { - "mode": "single", + "mode": "multi", "sort": "desc" } }, diff --git a/operations/mimir-mixin-compiled/dashboards/mimir-queries.json b/operations/mimir-mixin-compiled/dashboards/mimir-queries.json index 940ef798f5..7ce566e961 100644 --- a/operations/mimir-mixin-compiled/dashboards/mimir-queries.json +++ b/operations/mimir-mixin-compiled/dashboards/mimir-queries.json @@ -1696,8 +1696,8 @@ "showLegend": true }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, "span": 4, @@ -1744,8 +1744,8 @@ "showLegend": true }, "tooltip": { - "mode": "single", - "sort": "none" + "mode": "multi", + "sort": "desc" } }, "span": 4, diff --git a/operations/mimir-mixin-compiled/dashboards/mimir-rollout-progress.json b/operations/mimir-mixin-compiled/dashboards/mimir-rollout-progress.json index 734a630e0b..58a60488fd 100644 --- a/operations/mimir-mixin-compiled/dashboards/mimir-rollout-progress.json +++ b/operations/mimir-mixin-compiled/dashboards/mimir-rollout-progress.json @@ -122,7 +122,7 @@ "stacking": "none", "tooltip": { "mode": "multi", - "sort": "none" + "sort": "desc" }, "xField": "Workload", "xTickLabelRotation": 0, diff --git a/operations/mimir-mixin-compiled/dashboards/mimir-tenants.json b/operations/mimir-mixin-compiled/dashboards/mimir-tenants.json index 66bac4c7b6..c3dd5b0855 100644 --- a/operations/mimir-mixin-compiled/dashboards/mimir-tenants.json +++ b/operations/mimir-mixin-compiled/dashboards/mimir-tenants.json @@ -2431,7 +2431,7 @@ }, "tooltip": { "mode": "multi", - "sort": "none" + "sort": "desc" } }, "span": 6, diff --git a/operations/mimir-mixin-compiled/dashboards/mimir-writes-resources.json b/operations/mimir-mixin-compiled/dashboards/mimir-writes-resources.json index 503a6b84c2..b119b22a5f 100644 --- a/operations/mimir-mixin-compiled/dashboards/mimir-writes-resources.json +++ b/operations/mimir-mixin-compiled/dashboards/mimir-writes-resources.json @@ -504,7 +504,7 @@ "showLegend": true }, "tooltip": { - "mode": "single", + "mode": "multi", "sort": "desc" } }, diff --git a/operations/mimir-mixin/dashboards/dashboard-utils.libsonnet b/operations/mimir-mixin/dashboards/dashboard-utils.libsonnet index 8be5838b79..ec1f23cc18 100644 --- a/operations/mimir-mixin/dashboards/dashboard-utils.libsonnet +++ b/operations/mimir-mixin/dashboards/dashboard-utils.libsonnet @@ -226,18 +226,15 @@ local utils = import 'mixin-utils/utils.libsonnet'; // shows all values on tooltip, descending. Also turns on exemplars, unless 4th parameter is false. hiddenLegendQueryPanel(queries, legends, legendLink=null, exemplars=true):: $.queryPanel(queries, legends, legendLink) + + $.showAllTooltip + { - options: { + options+: { legend+: { showLegend: false, // Work round Grafana turning showLegend back on when we have // schemaVersion<37. https://github.com/grafana/grafana/issues/54472 displayMode: 'hidden', }, - tooltip+: { - mode: 'multi', - sort: 'desc', - }, }, fieldConfig+: { defaults+: { @@ -335,6 +332,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; containerCPUUsagePanel(instanceName, containerName):: $.timeseriesPanel('CPU') + $.queryPanel($.resourceUtilizationAndLimitQueries('cpu', instanceName, containerName), $.resourceUtilizationAndLimitLegend('{{%s}}' % $._config.per_instance_label)) + + $.showAllTooltip + { fieldConfig+: { overrides+: [ @@ -348,12 +346,6 @@ local utils = import 'mixin-utils/utils.libsonnet'; }, }, }, - options+: { - tooltip: { - mode: 'multi', - sort: 'desc', - }, - }, }, // The provided componentName should be the name of a component among the ones defined in $._config.instance_names. @@ -365,6 +357,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; containerMemoryWorkingSetPanel(instanceName, containerName):: $.timeseriesPanel('Memory (workingset)') + $.queryPanel($.resourceUtilizationAndLimitQueries('memory_working', instanceName, containerName), $.resourceUtilizationAndLimitLegend('{{%s}}' % $._config.per_instance_label)) + + $.showAllTooltip + { fieldConfig+: { overrides+: [ @@ -378,12 +371,6 @@ local utils = import 'mixin-utils/utils.libsonnet'; }, }, }, - options+: { - tooltip: { - mode: 'multi', - sort: 'desc', - }, - }, }, // The provided componentName should be the name of a component among the ones defined in $._config.instance_names. @@ -395,6 +382,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; containerMemoryRSSPanel(instanceName, containerName):: $.timeseriesPanel('Memory (RSS)') + $.queryPanel($.resourceUtilizationAndLimitQueries('memory_rss', instanceName, containerName), $.resourceUtilizationAndLimitLegend('{{%s}}' % $._config.per_instance_label)) + + $.showAllTooltip + { fieldConfig+: { overrides+: [ @@ -408,12 +396,6 @@ local utils = import 'mixin-utils/utils.libsonnet'; }, }, }, - options+: { - tooltip: { - mode: 'multi', - sort: 'desc', - }, - }, }, // The provided componentName should be the name of a component among the ones defined in $._config.instance_names. @@ -425,6 +407,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; containerGoHeapInUsePanel(instanceName, containerName):: $.timeseriesPanel('Memory (go heap inuse)') + $.queryPanel($.resourceUtilizationQuery('memory_go_heap', instanceName, containerName), '{{%s}}' % $._config.per_instance_label) + + $.showAllTooltip + { fieldConfig+: { defaults+: { @@ -434,12 +417,6 @@ local utils = import 'mixin-utils/utils.libsonnet'; }, }, }, - options+: { - tooltip: { - mode: 'multi', - sort: 'desc', - }, - }, }, // The provided componentName should be the name of a component among the ones defined in $._config.instance_names. @@ -937,6 +914,16 @@ local utils = import 'mixin-utils/utils.libsonnet'; }, }, + // Shows all series' values in the tooltip and sorts them in descending order. + showAllTooltip:: { + options+: { + tooltip+: { + mode: 'multi', + sort: 'desc', + }, + }, + }, + // Switches a panel from lines (default) to bars. bars:: { fieldConfig+: { diff --git a/operations/mimir-mixin/dashboards/queries.libsonnet b/operations/mimir-mixin/dashboards/queries.libsonnet index 5dae3e71dc..4a02d1f2f5 100644 --- a/operations/mimir-mixin/dashboards/queries.libsonnet +++ b/operations/mimir-mixin/dashboards/queries.libsonnet @@ -420,6 +420,7 @@ local filename = 'mimir-queries.json'; '{{stage}}' ) + $.stack + + $.showAllTooltip + { fieldConfig+: { defaults+: { unit: 's' } } }, ) .addPanel( @@ -431,6 +432,7 @@ local filename = 'mimir-queries.json'; '{{stage}}' ) + $.stack + + $.showAllTooltip + { fieldConfig+: { defaults+: { unit: 's' } } }, ) .addPanel( diff --git a/operations/mimir-mixin/dashboards/rollout-progress.libsonnet b/operations/mimir-mixin/dashboards/rollout-progress.libsonnet index 4ada30bc1f..0aeba3f156 100644 --- a/operations/mimir-mixin/dashboards/rollout-progress.libsonnet +++ b/operations/mimir-mixin/dashboards/rollout-progress.libsonnet @@ -101,6 +101,7 @@ local filename = 'mimir-rollout-progress.json'; min=0, max=1 ) + + $.showAllTooltip + { id: 1, gridPos: { h: 13, w: 10, x: 0, y: 0 }, @@ -123,9 +124,6 @@ local filename = 'mimir-rollout-progress.json'; options+: { xField: 'Workload', orientation: 'horizontal', - tooltip+: { - mode: 'multi', - }, }, transformations: [ { diff --git a/operations/mimir-mixin/dashboards/tenants.libsonnet b/operations/mimir-mixin/dashboards/tenants.libsonnet index 0e233cfc7c..5d1c185da5 100644 --- a/operations/mimir-mixin/dashboards/tenants.libsonnet +++ b/operations/mimir-mixin/dashboards/tenants.libsonnet @@ -96,6 +96,7 @@ local filename = 'mimir-tenants.json'; '{{pod}}', ], ) + + $.showAllTooltip + { fieldConfig+: { defaults+: { custom+: { fillOpacity: 0 } }, @@ -107,10 +108,6 @@ local filename = 'mimir-tenants.json'; ], }, options+: { - tooltip+: { - mode: 'multi', - sort: 'desc', - }, legend+: { showLegend: false }, }, } + @@ -144,6 +141,7 @@ local filename = 'mimir-tenants.json'; '{{pod}}', ], ) + + $.showAllTooltip + { fieldConfig+: { defaults+: { custom+: { fillOpacity: 0 } }, @@ -155,10 +153,6 @@ local filename = 'mimir-tenants.json'; ], }, options+: { - tooltip+: { - mode: 'multi', - sort: 'desc', - }, legend+: { showLegend: false }, }, } + @@ -762,7 +756,8 @@ local filename = 'mimir-tenants.json'; (sum(rate(cortex_bucket_index_estimated_compaction_jobs_errors_total{%s}[$__rate_interval])) == 0) ||| % [$.jobMatcher($._config.job_names.compactor), $.jobMatcher($._config.job_names.compactor)], '{{ job }}', - ) + { + ) + + $.showAllTooltip + { fieldConfig+: { defaults+: { custom+: { @@ -771,11 +766,6 @@ local filename = 'mimir-tenants.json'; }, }, }, - options+: { - tooltip+: { - mode: 'multi', - }, - }, } + $.panelDescription( 'Estimated Compaction Jobs', diff --git a/operations/mimir-mixin/dashboards/writes-resources.libsonnet b/operations/mimir-mixin/dashboards/writes-resources.libsonnet index aba99c5c3f..b0ea061746 100644 --- a/operations/mimir-mixin/dashboards/writes-resources.libsonnet +++ b/operations/mimir-mixin/dashboards/writes-resources.libsonnet @@ -57,10 +57,8 @@ local filename = 'mimir-writes-resources.json'; 'sum by(%s) (cortex_ingester_memory_series{%s})' % [$._config.per_instance_label, $.jobMatcher($._config.job_names.ingester)], '{{%s}}' % $._config.per_instance_label ) + + $.showAllTooltip + { - options+: { - tooltip+: { sort: 'desc' }, - }, fieldConfig+: { defaults+: { custom+: {