From 5af67af8f0820cb25471c42910c2bf573b47b015 Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Wed, 1 Nov 2023 12:13:50 +1030 Subject: [PATCH] feat: adds Clickhouse metrics to Operator / Clickhouse tab --- .../jobs/init/clickhouse/init-clickhouse.sh | 6 + .../assets/charts/clickhouse_metrics.yaml | 33 +++++ .../assets/dashboards/Operator_Dashboard.yaml | 74 ++++++++--- .../datasets/clickhouse_computed_metrics.yaml | 117 ++++++++++++++++++ 4 files changed, 216 insertions(+), 14 deletions(-) create mode 100755 tutoraspects/templates/openedx-assets/assets/charts/clickhouse_metrics.yaml create mode 100644 tutoraspects/templates/openedx-assets/assets/datasets/clickhouse_computed_metrics.yaml diff --git a/tutoraspects/templates/aspects/jobs/init/clickhouse/init-clickhouse.sh b/tutoraspects/templates/aspects/jobs/init/clickhouse/init-clickhouse.sh index b67114434..139108622 100644 --- a/tutoraspects/templates/aspects/jobs/init/clickhouse/init-clickhouse.sh +++ b/tutoraspects/templates/aspects/jobs/init/clickhouse/init-clickhouse.sh @@ -55,6 +55,12 @@ GRANT {{ ON_CLUSTER }} INSERT, SELECT ON {{ ASPECTS_EVENT_SINK_DATABASE }}.* TO GRANT {{ ON_CLUSTER }} SELECT, dictGet ON {{ ASPECTS_EVENT_SINK_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; GRANT {{ ON_CLUSTER }} INSERT, SELECT ON {{ ASPECTS_VECTOR_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_VECTOR_USER }}'; GRANT {{ ON_CLUSTER }} SELECT ON {{ ASPECTS_VECTOR_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; +GRANT {{ ON_CLUSTER }} SELECT ON system.asynchronous_metrics TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; +GRANT {{ ON_CLUSTER }} SELECT ON system.disks TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; +GRANT {{ ON_CLUSTER }} SELECT ON system.events TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; +GRANT {{ ON_CLUSTER }} SELECT ON system.metrics TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; +GRANT {{ ON_CLUSTER }} SELECT ON system.replication_queue TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}'; + {{ patch("clickhouse-extra-sql") }} diff --git a/tutoraspects/templates/openedx-assets/assets/charts/clickhouse_metrics.yaml b/tutoraspects/templates/openedx-assets/assets/charts/clickhouse_metrics.yaml new file mode 100755 index 000000000..7638f7116 --- /dev/null +++ b/tutoraspects/templates/openedx-assets/assets/charts/clickhouse_metrics.yaml @@ -0,0 +1,33 @@ +_file_name: clickhouse_metrics.yaml +slice_name: ClickHouse metrics +description: null +certified_by: null +certification_details: null +viz_type: table +params: + datasource: 30__table + viz_type: table + query_mode: raw + groupby: [] + time_grain_sqla: P1D + temporal_columns_lookup: {} + all_columns: + - name + - value + - description + percent_metrics: [] + adhoc_filters: [] + order_by_cols: [] + row_limit: 1000 + server_page_length: 10 + order_desc: true + table_timestamp_format: smart_date + show_cell_bars: true + color_pn: true + extra_form_data: {} + dashboards: [] +query_context: null +cache_timeout: null +uuid: 2f84cbc3-4068-4d4d-bd40-ae348e4be95d +version: 1.0.0 +dataset_uuid: 9eee1df8-ad25-4d0f-8e53-90c277cf28e4 diff --git a/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml b/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml index 435bcfebb..f677e2262 100644 --- a/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml +++ b/tutoraspects/templates/openedx-assets/assets/dashboards/Operator_Dashboard.yaml @@ -306,7 +306,7 @@ position: - GRID_ID - TABS-7nA6MwltSD - TAB-gvqU89mvT - - ROW-cpoIgMfQUZ + - COLUMN-cpoIgMfQUZ type: CHART CHART-QN5x3ibIzS: children: [] @@ -475,6 +475,36 @@ position: - TAB-EygpebMa1 - ROW-06Qh5Kxfn type: CHART + CHART-4xInxcau02: + children: [] + id: CHART-4xInxcau02 + meta: + chartId: 647 + height: 50 + sliceName: ClickHouse Metrics + uuid: 2f84cbc3-4068-4d4d-bd40-ae348e4be95d + width: 12 + parents: + - ROOT_ID + - GRID_ID + - TABS-7nA6MwltSD + - TAB-gvqU89mvT + - COLUMN-cpoIgMfQUZ + type: CHART + COLUMN-cpoIgMfQUZ: + children: + - CHART-La3O2IbbVV + - CHART-4xInxcau02 + id: COLUMN-cpoIgMfQUZ + meta: + background: BACKGROUND_TRANSPARENT + width: 12 + parents: + - ROOT_ID + - GRID_ID + - TABS-7nA6MwltSD + - TAB-gvqU89mvT + type: COLUMN COLUMN-GDahqg06nQ: children: - MARKDOWN-EZXXAbo-Tg @@ -489,6 +519,22 @@ position: - TAB-DE73B5pXm - ROW-mPSz65tZ7E type: COLUMN + COLUMN-cZHAXyMjrZ: + children: + - CHART-YIks0931LR + - DIVIDER-Cjn1gzHg1Z + - CHART-z56xnjjWTf + id: COLUMN-cZHAXyMjrZ + meta: + background: BACKGROUND_TRANSPARENT + width: 12 + parents: + - ROOT_ID + - GRID_ID + - TABS-7nA6MwltSD + - TAB-gvqU89mvT + - ROW-npo-Vvh-xu + type: COLUMN COLUMN-eGzPLamIzw: children: - CHART-explore-21-1 @@ -506,6 +552,18 @@ position: - ROW-mPSz65tZ7E type: COLUMN DASHBOARD_VERSION_KEY: v2 + DIVIDER-Cjn1gzHg1Z: + children: [] + id: DIVIDER-Cjn1gzHg1Z + meta: {} + parents: + - ROOT_ID + - GRID_ID + - TABS-7nA6MwltSD + - TAB-gvqU89mvT + - ROW-npo-Vvh-xu + - COLUMN-cZHAXyMjrZ + type: DIVIDER DIVIDER-erPdret3HB: children: [] id: DIVIDER-erPdret3HB @@ -622,18 +680,6 @@ position: - TABS-7nA6MwltSD - TAB-6Mdnw3FZh type: ROW - ROW-cpoIgMfQUZ: - children: - - CHART-La3O2IbbVV - id: ROW-cpoIgMfQUZ - meta: - background: BACKGROUND_TRANSPARENT - parents: - - ROOT_ID - - GRID_ID - - TABS-7nA6MwltSD - - TAB-gvqU89mvT - type: ROW ROW-mPSz65tZ7E: children: - COLUMN-GDahqg06nQ @@ -691,7 +737,7 @@ position: type: TAB TAB-gvqU89mvT: children: - - ROW-cpoIgMfQUZ + - COLUMN-cpoIgMfQUZ id: TAB-gvqU89mvT meta: defaultText: Tab title diff --git a/tutoraspects/templates/openedx-assets/assets/datasets/clickhouse_computed_metrics.yaml b/tutoraspects/templates/openedx-assets/assets/datasets/clickhouse_computed_metrics.yaml new file mode 100644 index 000000000..e57e140ab --- /dev/null +++ b/tutoraspects/templates/openedx-assets/assets/datasets/clickhouse_computed_metrics.yaml @@ -0,0 +1,117 @@ +_file_name: clickhouse_computed_metrics.yaml +table_name: clickhouse_computed_metrics +main_dttm_col: null +description: null +default_endpoint: null +offset: 0 +cache_timeout: null +schema: system +sql: | + SELECT + name, + toFloat64(value) AS value, + description + FROM system.metrics + WHERE metric IN ( + 'Query', + 'DelayedInserts', + 'DistributedFilesToInsert' + ) + + UNION ALL + + SELECT + metric AS name, + round(toFloat64(value), 2) AS value, + description + FROM system.asynchronous_metrics + WHERE metric IN ('MaxPartCountForPartition', 'Uptime') + + UNION ALL + + SELECT + name, + toFloat64(value) AS value, + description + FROM system.events + WHERE event IN ( + 'RejectedInserts', + 'ReplicatedDataLoss', + 'DataAfterMergeDiffersFromReplica', + 'DataAfterMutationDiffersFromReplica' + ) + + UNION All + + SELECT + 'StuckReplicationTasks' AS name, + toFloat64(count()) AS value, + 'Replication tasks that were retried or postponed over 100 times.' AS description + FROM system.replication_queue + WHERE num_tries > 100 OR num_postponed > 100 + + UNION ALL + + SELECT + CONCAT('cluster ', name) AS name, + ROUND(SUM(free_space) / SUM(total_space), 3) * 100 AS value, + 'Free space per cluster node, as percent' AS description + FROM system.disks + GROUP BY name +params: null +template_params: null +filter_select_enabled: true +fetch_values_predicate: null +extra: null +normalize_columns: false +uuid: 9eee1df8-ad25-4d0f-8e53-90c277cf28e4 +metrics: +- metric_name: count + verbose_name: COUNT(*) + metric_type: count + expression: COUNT(*) + description: null + d3format: null + currency: null + extra: + warning_markdown: '' + warning_text: null +columns: +- column_name: value + verbose_name: null + is_dttm: false + is_active: true + type: Float64 + advanced_data_type: null + groupby: true + filterable: true + expression: null + description: null + python_date_format: null + extra: {} +- column_name: name + verbose_name: null + is_dttm: false + is_active: true + type: String + advanced_data_type: null + groupby: true + filterable: true + expression: null + description: null + python_date_format: null + extra: {} +- column_name: description + verbose_name: null + is_dttm: false + is_active: true + type: String + advanced_data_type: null + groupby: true + filterable: true + expression: null + description: null + python_date_format: null + extra: {} +version: 1.0.0 +database_uuid: 21174b6c-4d40-4958-8161-d6c3cf5e77b6