From 4c302234ff2e478d65647238112a94383a608ea3 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Thu, 16 Dec 2021 13:34:35 +0100 Subject: [PATCH] monitoring/grafana: Replace missing legendFormat warning with error Signed-off-by: Pere Diaz Bou --- .../jsonnet/grafana_dashboards.jsonnet | 31 +++++++++---------- monitoring/grafana/dashboards/tests/util.py | 14 +++++++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/monitoring/grafana/dashboards/jsonnet/grafana_dashboards.jsonnet b/monitoring/grafana/dashboards/jsonnet/grafana_dashboards.jsonnet index 8a957e935518b..f2f6736fbe6e3 100644 --- a/monitoring/grafana/dashboards/jsonnet/grafana_dashboards.jsonnet +++ b/monitoring/grafana/dashboards/jsonnet/grafana_dashboards.jsonnet @@ -733,7 +733,7 @@ local addStyle(alias, colorMode, colors, dateFormat, decimals, mappingType, patt local RbdDetailsPanel(title, formatY1, expr1, expr2, x, y, w, h) = graphPanelSchema({}, title, '', 'null as zero', false, formatY1, formatY1, null, null, 0, 1, '$Datasource') .addTargets( - [addTargetSchema(expr1, 1, 'time_series', 'Write'),addTargetSchema(expr2, 1, 'time_series', 'Read')]) + {gridPos: {x: x, y: y, w: w, h: h}}; + [addTargetSchema(expr1, 1, 'time_series', '{{pool}} Write'),addTargetSchema(expr2, 1, 'time_series', '{{pool}} Read')]) + {gridPos: {x: x, y: y, w: w, h: h}}; dashboardSchema( 'RBD Details', 'Detailed Performance of RBD Images (IOPS/Throughput/Latency)', 'YhCYGcuZz', 'now-1h', false, 16, [], '', {refresh_intervals:['5s','10s','30s','1m','5m','15m','30m','1h','2h','1d'],time_options:['5m','15m','1h','6h','12h','24h','2d','7d','30d']} @@ -988,18 +988,18 @@ local addStyle(alias, colorMode, colors, dateFormat, decimals, mappingType, patt '$datasource', '', {"col": 5,"desc": true}, [PoolOverviewStyle('', 'Time', 'hidden', 'short', null, [], []),PoolOverviewStyle('', 'instance', 'hidden', 'short', null, [], []),PoolOverviewStyle('', 'job', 'hidden', 'short', null, [], []),PoolOverviewStyle('Pool Name', 'name', 'string', 'short', null, [], []),PoolOverviewStyle('Pool ID', 'pool_id', 'hidden', 'none', null, [], []),PoolOverviewStyle('Compression Factor', 'Value #A', 'number', 'none', null, [], []),PoolOverviewStyle('% Used', 'Value #D', 'number', 'percentunit', 'value', ['70','85'], []),PoolOverviewStyle('Usable Free', 'Value #B', 'number', 'bytes', null, [], []),PoolOverviewStyle('Compression Eligibility', 'Value #C', 'number', 'percent', null, [], []),PoolOverviewStyle('Compression Savings', 'Value #E', 'number', 'bytes', null, [], []),PoolOverviewStyle('Growth (5d)', 'Value #F', 'number', 'bytes', 'value', ['0', '0'], []),PoolOverviewStyle('IOPS', 'Value #G', 'number', 'none', null, [], []),PoolOverviewStyle('Bandwidth', 'Value #H', 'number', 'Bps', null, [], []),PoolOverviewStyle('', '__name__', 'hidden', 'short', null, [], []),PoolOverviewStyle('', 'type', 'hidden', 'short', null, [], []),PoolOverviewStyle('', 'compression_mode', 'hidden', 'short', null, [], []),PoolOverviewStyle('Type', 'description', 'string', 'short', null, [], []),PoolOverviewStyle('Stored', 'Value #J', 'number', 'bytes', null, [], []),PoolOverviewStyle('', 'Value #I', 'hidden', 'short', null, [], []),PoolOverviewStyle('Compression', 'Value #K', 'string', 'short', null, [], [{"text": "ON","value": "1"}])], 'Pool Overview', 'table' ) .addTargets( - [addTargetSchema('(ceph_pool_compress_under_bytes / ceph_pool_compress_bytes_used > 0) and on(pool_id) (((ceph_pool_compress_under_bytes > 0) / ceph_pool_stored_raw) * 100 > 0.5)', 1, 'table', ''), - addTargetSchema('ceph_pool_max_avail * on(pool_id) group_left(name) ceph_pool_metadata', 1, 'table', ''), - addTargetSchema('((ceph_pool_compress_under_bytes > 0) / ceph_pool_stored_raw) * 100', 1, 'table', ''), - addTargetSchema('(ceph_pool_percent_used * on(pool_id) group_left(name) ceph_pool_metadata)', 1, 'table', ''), - addTargetSchema('(ceph_pool_compress_under_bytes - ceph_pool_compress_bytes_used > 0)', 1, 'table', ''), - addTargetSchema('delta(ceph_pool_stored[5d])', 1, 'table', ''), - addTargetSchema('rate(ceph_pool_rd[30s]) + rate(ceph_pool_wr[30s])', 1, 'table', ''), - addTargetSchema('rate(ceph_pool_rd_bytes[30s]) + rate(ceph_pool_wr_bytes[30s])', 1, 'table', ''), - addTargetSchema('ceph_pool_metadata', 1, 'table', ''), - addTargetSchema('ceph_pool_stored * on(pool_id) group_left ceph_pool_metadata', 1, 'table', ''), - addTargetSchema('ceph_pool_metadata{compression_mode!="none"}', 1, 'table', ''), - addTargetSchema('', '', '', '')] + [addTargetSchema('(ceph_pool_compress_under_bytes / ceph_pool_compress_bytes_used > 0) and on(pool_id) (((ceph_pool_compress_under_bytes > 0) / ceph_pool_stored_raw) * 100 > 0.5)', 1, 'table', 'A'), + addTargetSchema('ceph_pool_max_avail * on(pool_id) group_left(name) ceph_pool_metadata', 1, 'table', 'B'), + addTargetSchema('((ceph_pool_compress_under_bytes > 0) / ceph_pool_stored_raw) * 100', 1, 'table', 'C'), + addTargetSchema('(ceph_pool_percent_used * on(pool_id) group_left(name) ceph_pool_metadata)', 1, 'table', 'D'), + addTargetSchema('(ceph_pool_compress_under_bytes - ceph_pool_compress_bytes_used > 0)', 1, 'table', 'E'), + addTargetSchema('delta(ceph_pool_stored[5d])', 1, 'table', 'F'), + addTargetSchema('rate(ceph_pool_rd[30s]) + rate(ceph_pool_wr[30s])', 1, 'table', 'G'), + addTargetSchema('rate(ceph_pool_rd_bytes[30s]) + rate(ceph_pool_wr_bytes[30s])', 1, 'table', 'H'), + addTargetSchema('ceph_pool_metadata', 1, 'table', 'I'), + addTargetSchema('ceph_pool_stored * on(pool_id) group_left ceph_pool_metadata', 1, 'table', 'J'), + addTargetSchema('ceph_pool_metadata{compression_mode!=\"none\"}', 1, 'table', 'K'), + addTargetSchema('', '', '', 'L')] ) + {gridPos: {x: 0, y: 3, w: 24, h: 6}}, PoolOverviewGraphPanel( 'Top $topk Client IOPS by Pool', @@ -1171,7 +1171,7 @@ local addStyle(alias, colorMode, colors, dateFormat, decimals, mappingType, patt addPieChartSchema(alias, '$datasource', description, 'Under graph', 'pie', title, 'current'); local OsdOverviewSingleStatPanel(colors, format, title, description, valueName, colorValue, gaugeMaxValue, gaugeShow, sparkLineShow, thresholds, expr, targetFormat, x, y, w, h) = addSingelStatSchema(colors, '$datasource', format, title, description, valueName, colorValue, gaugeMaxValue, gaugeShow, sparkLineShow, thresholds) - .addTarget(addTargetSchema(expr, 1, targetFormat, '')) + {gridPos: {x: x, y: y, w: w, h: h}}; + .addTarget(addTargetSchema(expr, 1, targetFormat, '')) + {gridPos: {x: x, y: y, w: w, h: h}}; dashboardSchema( 'OSD Overview', '', 'lo02I1Aiz', 'now-1h', '10s', 16, [], '', {refresh_intervals:['5s','10s','30s','1m','5m','15m','30m','1h','2h','1d'],time_options:['5m','15m','1h','6h','12h','24h','2d','7d','30d']} @@ -1287,8 +1287,7 @@ local addStyle(alias, colorMode, colors, dateFormat, decimals, mappingType, patt 'OSD Objectstore Types' ) .addTarget(addTargetSchema('count(ceph_bluefs_wal_total_bytes)', 1, 'time_series', 'bluestore')) - .addTarget(addTargetSchema('count(ceph_osd_metadata) - count(ceph_bluefs_wal_total_bytes)', 1, 'time_series', 'filestore')) - .addTarget(addTargetSchema('absent(ceph_bluefs_wal_total_bytes)*count(ceph_osd_metadata)', 1, 'time_series', 'filestore')) + {gridPos: {x: 4, y: 8, w: 4, h: 8}}, + .addTarget(addTargetSchema('count(ceph_osd_metadata) - count(ceph_bluefs_wal_total_bytes)', 1, 'time_series', 'filestore')) + {gridPos: {x: 4, y: 8, w: 4, h: 8}}, OsdOverviewPieChartPanel( {}, 'The pie chart shows the various OSD sizes used within the cluster', diff --git a/monitoring/grafana/dashboards/tests/util.py b/monitoring/grafana/dashboards/tests/util.py index 7b6391a34ab67..1b7e1ac265df3 100644 --- a/monitoring/grafana/dashboards/tests/util.py +++ b/monitoring/grafana/dashboards/tests/util.py @@ -40,6 +40,8 @@ def add_dashboard_queries(data: Dict[str, Any], dashboard_data: Dict[str, Any], """ if 'panels' not in dashboard_data: return + error = 0 + dashboard_title = dashboard_data['title'] for panel in dashboard_data['panels']: if ( 'title' in panel @@ -50,15 +52,21 @@ def add_dashboard_queries(data: Dict[str, Any], dashboard_data: Dict[str, Any], for target in panel['targets']: title = panel['title'] legend_format = target['legendFormat'] if 'legendFormat' in target else "" - query_id = title + '-' + legend_format + query_id = f'{title}-{legend_format}' if query_id in data['queries']: # NOTE: If two or more panels have the same name and legend it # might suggest a refactoring is needed or add something else # to identify each query. - cprint((f'WARNING: Query in panel "{title}" with legend "{legend_format}"' - ' already exists'), 'yellow') + conflict_file = data['queries'][query_id]['path'].split('/')[-1] + file = path.split('/')[-1] + cprint((f'ERROR: Query in panel "{title}" with legend "{legend_format}"' + f' already exists. Conflict "{conflict_file}" ' + f'with: "{file}"'), 'red') + error = 1 data['queries'][query_id] = {'query': target['expr'], 'path': path} data['stats'][path]['total'] += 1 + if error: + raise RuntimeError(f'Missing legend_format in queries, please add a proper value.') def add_dashboard_variables(data: Dict[str, Any], dashboard_data: Dict[str, Any]) -> None: -- 2.39.5