Grafana dashboard: Clickhouse State
Description: Clickhouse dashboard. Data for dashboard is fetched from Clickhouse system tables. 

Useful for single-node installations of Clickhouse.
Tested version of ch - 20.9.2.20.

Installation:
- Install the dahsboard
- Create user `grafana` in ch
- Grant permissions for this user
- Enable table text_log in `/etc/clickhouse-server/config.xml`
- Create notification channel for telegram, if needed

{
  "__inputs": [
    {
      "name": "DS_CLICKHOUSE_V3",
      "label": "ClickHouse V3",
      "description": "",
      "type": "datasource",
      "pluginId": "vertamedia-clickhouse-datasource",
      "pluginName": "ClickHouse"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.6.0"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "vertamedia-clickhouse-datasource",
      "name": "ClickHouse",
      "version": "2.0.2"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 13334,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": "${DS_CLICKHOUSE_V3}",
      "gridPos": {
        "h": 4,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "last"
          ],
          "defaults": {
            "decimals": 1,
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "red",
                  "value": null
                },
                {
                  "color": "green",
                  "value": 600
                }
              ]
            },
            "title": "",
            "unit": "clocks"
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto"
      },
      "pluginVersion": "6.6.0",
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "event_time",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "time_series",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    $timeSeries as t,\n    name,\n    avg(value)\nFROM $table\nWHERE $timeFilter\nand name = 'Uptime'\nGROUP BY t, name\nORDER BY name, t",
          "rawQuery": "SELECT     database,     (sum(if(active, bytes, 0))) AS size_on_disk,     formatReadableSize(sum(if(active, data_uncompressed_bytes, 0))) AS uncompressed_size,     maxIf(modification_time, active) AS latest_modification,     formatReadableSize(sum(if(NOT active, bytes, 0))) AS inactive_size FROM system.parts GROUP BY database ORDER BY sum(if(active, bytes, 0)) desc",
          "refId": "A",
          "round": "0s",
          "table": "asynchronous_metric_log",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Uptime",
      "type": "stat"
    },
    {
      "datasource": "${DS_CLICKHOUSE_V3}",
      "gridPos": {
        "h": 4,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "id": 9,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "mean"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "#EAB839",
                  "value": 60
                },
                {
                  "color": "red",
                  "value": 300
                }
              ]
            },
            "unit": "clocks"
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto"
      },
      "pluginVersion": "6.6.0",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "select max(elapsed) longest_query  from system.processes",
          "rawQuery": "select max(elapsed) longest_query  from system.processes",
          "refId": "A",
          "round": "0s"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Longest current query",
      "type": "stat"
    },
    {
      "datasource": "${DS_CLICKHOUSE_V3}",
      "gridPos": {
        "h": 4,
        "w": 12,
        "x": 0,
        "y": 4
      },
      "id": 10,
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "last"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "#EAB839",
                  "value": 60
                },
                {
                  "color": "red",
                  "value": 300
                }
              ]
            },
            "unit": "none"
          },
          "overrides": [],
          "values": true
        },
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "auto"
      },
      "pluginVersion": "6.6.0",
      "targets": [
        {
          "dateTimeType": "DATETIME",
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "select uniq(user) \"Users\", uniq(address) \"Hosts\" from system.processes",
          "rawQuery": "SELECT     concat(database, '.', table) table,     (sum(if(active, bytes, 0))) AS size_on_disk,     (sum(if(NOT active, bytes, 0))) AS inactive_size,     (maxIf(modification_time, active)) AS latest_modification,     formatReadableSize(sum(if(active, data_uncompressed_bytes, 0))) AS uncompressed_size FROM system.parts GROUP BY table ORDER BY sum(if(active, bytes, 0)) desc",
          "refId": "A",
          "round": "0s"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Active clients",
      "type": "stat"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_CLICKHOUSE_V3}",
      "gridPos": {
        "h": 4,
        "w": 12,
        "x": 12,
        "y": 4
      },
      "id": 4,
      "links": [],
      "options": {
        "colorMode": "value",
        "fieldOptions": {
          "calcs": [
            "last"
          ],
          "defaults": {
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "red",
                  "value": 1000
                }
              ]
            }
          },
          "overrides": [],
          "values": false
        },
        "graphMode": "area",
        "justifyMode": "center",
        "orientation": "auto"
      },
      "pluginVersion": "6.6.0",
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "event_time",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "time_series",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    $timeSeries as t,\n    name,\n    avg(value)\nFROM $table\nWHERE $timeFilter\nand name like 'Number%'\nGROUP BY t, name\nORDER BY name, t",
          "rawQuery": "SELECT     (intDiv(toUInt32(event_time), 20) * 20) * 1000 as t,     name,     avg(value) FROM system.asynchronous_metric_log WHERE event_time >= toDateTime(1604353247) and name like 'Number%' GROUP BY t, name ORDER BY name, t",
          "refId": "A",
          "round": "0s",
          "table": "asynchronous_metric_log",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Database objects",
      "type": "stat"
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_CLICKHOUSE_V3}",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 8
      },
      "hiddenSeries": false,
      "id": 12,
      "legend": {
        "alignAsTable": false,
        "avg": true,
        "current": false,
        "max": true,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 2,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "alias": "count()",
          "yaxis": 2
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "query_start_time",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "time_series",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    $timeSeries as t, user,\n    max(query_duration_ms) max_query_duration_ms\nFROM system.query_log\nWHERE $timeFilter\nand type = 'QueryFinish'\ngroup by t, user\nORDER BY user, t",
          "rawQuery": "select max(elapsed) longest_query  from system.processes",
          "refId": "A",
          "round": "0s",
          "table": "query_log",
          "tableLoading": false
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Query duration",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "clockms",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "decimals": null,
          "format": "short",
          "label": "Count",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "columns": [],
      "datasource": "${DS_CLICKHOUSE_V3}",
      "description": "Except  processes from grafana",
      "fontSize": "100%",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 8
      },
      "id": 16,
      "options": {},
      "pageSize": 10,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "align": "left",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "align": "left",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    user, query\nFROM $table\nwhere user != 'grafana'\n",
          "rawQuery": "select max(elapsed) longest_query  from system.processes",
          "refId": "A",
          "round": "0s",
          "table": "processes",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Current processes",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_CLICKHOUSE_V3}",
      "description": "",
      "fontSize": "100%",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 16
      },
      "id": 6,
      "options": {},
      "pageSize": 10,
      "pluginVersion": "6.6.0",
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "latest_modification",
          "thresholds": [],
          "type": "date",
          "unit": "dateTimeFromNow"
        },
        {
          "alias": "",
          "align": "left",
          "colorMode": "cell",
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "decimals": 2,
          "pattern": "size_on_disk",
          "thresholds": [
            "1e+12"
          ],
          "type": "number",
          "unit": "bits"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": "value",
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "inactive_size",
          "thresholds": [
            "1e+9"
          ],
          "type": "number",
          "unit": "decbits"
        }
      ],
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "delete_ttl_info_max",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    database,\n    (sum(if(active, bytes, 0))) AS size_on_disk,\n    (sum(if(NOT active, bytes, 0))) AS inactive_size,\n    (maxIf(modification_time, active)) AS latest_modification,\n    formatReadableSize(sum(if(active, data_uncompressed_bytes, 0))) AS uncompressed_size\nFROM system.parts\nGROUP BY database\nORDER BY sum(if(active, bytes, 0)) desc",
          "rawQuery": "SELECT     (intDiv(toUInt32(query_start_time), 15) * 15) * 1000 as t, user,     max(query_duration_ms) max_query_duration_ms FROM system.query_log WHERE query_start_time >= toDateTime(1604390471) and type = 'QueryFinish' group by t, user ORDER BY user, t",
          "refId": "A",
          "round": "0s",
          "table": "parts",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Database size",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_CLICKHOUSE_V3}",
      "description": "",
      "fontSize": "100%",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 16
      },
      "id": 7,
      "options": {},
      "pageSize": 10,
      "pluginVersion": "6.6.0",
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 0,
          "mappingType": 1,
          "pattern": "latest_modification",
          "thresholds": [],
          "type": "date",
          "unit": "dateTimeFromNow"
        },
        {
          "alias": "",
          "align": "left",
          "colorMode": "cell",
          "colors": [
            "rgba(50, 172, 45, 0.97)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "decimals": 2,
          "pattern": "size_on_disk",
          "thresholds": [
            "1e+12"
          ],
          "type": "number",
          "unit": "bits"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": "value",
          "colors": [
            "#73BF69",
            "rgba(237, 129, 40, 0.89)",
            "rgba(245, 54, 54, 0.9)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "inactive_size",
          "thresholds": [
            "1e+9"
          ],
          "type": "number",
          "unit": "decbits"
        }
      ],
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "delete_ttl_info_max",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    concat(database, '.', table) table,\n    (sum(if(active, bytes, 0))) AS size_on_disk,\n    (sum(if(NOT active, bytes, 0))) AS inactive_size,\n    (maxIf(modification_time, active)) AS latest_modification,\n    formatReadableSize(sum(if(active, data_uncompressed_bytes, 0))) AS uncompressed_size\nFROM system.parts\nGROUP BY table\nORDER BY sum(if(active, bytes, 0)) desc",
          "rawQuery": "SELECT     concat(database, '.', table) table,     (sum(if(active, bytes, 0))) AS size_on_disk,     (sum(if(NOT active, bytes, 0))) AS inactive_size,     (maxIf(modification_time, active)) AS latest_modification,     formatReadableSize(sum(if(active, data_uncompressed_bytes, 0))) AS uncompressed_size FROM system.parts GROUP BY table ORDER BY sum(if(active, bytes, 0)) desc",
          "refId": "A",
          "round": "0s",
          "table": "parts",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Table size",
      "transform": "table",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_CLICKHOUSE_V3}",
      "fontSize": "100%",
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 24
      },
      "id": 18,
      "options": {},
      "pageSize": 10,
      "showHeader": true,
      "sort": {
        "col": null,
        "desc": false
      },
      "styles": [
        {
          "alias": "Time",
          "align": "left",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "align": "left",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "event_time",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "time_series",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "select * from (\nSELECT\n    event_time,\n    toString(type) type,\n    exception,\n    query\nFROM $table\nWHERE $timeFilter\nand exception != ''\nunion all \nselect latest_fail_time event_time,\n    'Mutation'   type,\n    latest_fail_reason exception,\n    command query\nfrom system.mutations\nwhere $timeFilter and latest_fail_reason != '') order by event_time desc limit 1000",
          "rawQuery": "select max(elapsed) longest_query  from system.processes",
          "refId": "A",
          "round": "0s",
          "table": "query_log",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Last query and mutation exceptions",
      "transform": "timeseries_to_columns",
      "type": "table"
    },
    {
      "columns": [],
      "datasource": "${DS_CLICKHOUSE_V3}",
      "description": "...from system.text_log\nwhere level not in ('Information', 'Debug', 'Trace')...",
      "fontSize": "100%",
      "gridPos": {
        "h": 11,
        "w": 24,
        "x": 0,
        "y": 33
      },
      "id": 20,
      "options": {},
      "pageSize": 10,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "align": "",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "t",
          "type": "date",
          "unit": "dateTimeAsIso"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        },
        {
          "alias": "Level",
          "align": "left",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "level",
          "preserveFormat": false,
          "sanitize": true,
          "thresholds": [
            ""
          ],
          "type": "string",
          "unit": "short",
          "valueMaps": []
        },
        {
          "alias": "",
          "align": "left",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "preserveFormat": true,
          "sanitize": true,
          "thresholds": [],
          "type": "string",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "event_time",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "select $timeSeries as t, level, query_id, any(message) message from system.text_log\nwhere level not in ('Information', 'Debug', 'Trace') and $timeFilter\nGROUP BY t, level, query_id\norder by t desc\nlimit 1000",
          "rawQuery": "select max(elapsed) longest_query  from system.processes",
          "refId": "A",
          "round": "0s",
          "table": "text_log",
          "tableLoading": false
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Warning and Error from text logs",
      "transform": "table",
      "type": "table"
    },
    {
      "alert": {
        "alertRuleTags": {},
        "conditions": [
          {
            "evaluator": {
              "params": [
                121
              ],
              "type": "no_value"
            },
            "operator": {
              "type": "and"
            },
            "query": {
              "params": [
                "A",
                "10m",
                "now"
              ]
            },
            "reducer": {
              "params": [],
              "type": "avg"
            },
            "type": "query"
          }
        ],
        "executionErrorState": "alerting",
        "for": "5m",
        "frequency": "1m",
        "handler": 1,
        "message": "Please check clickhouse-server.service status and logs!",
        "name": "Clickhouse is Down",
        "noDataState": "no_data",
        "notifications": [
          {
            "uid": "sF9HeDhMk"
          }
        ]
      },
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_CLICKHOUSE_V3}",
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 44
      },
      "hiddenSeries": false,
      "id": 14,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "database": "system",
          "dateColDataType": "",
          "dateLoading": false,
          "dateTimeColDataType": "event_time",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "time_series",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "intervalFactor": 1,
          "query": "SELECT\n    $timeSeries as t,\n    count()\nFROM $table\nWHERE $timeFilter\nand type = 'QueryStart'\nGROUP BY t\nORDER BY t",
          "rawQuery": "SELECT     (intDiv(toUInt32(event_time), 20) * 20) * 1000 as t,     count() FROM system.query_log WHERE event_time >= toDateTime(1604370507) and type = 'QueryStart' GROUP BY t ORDER BY t",
          "refId": "A",
          "round": "0s",
          "table": "query_log",
          "tableLoading": false
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Query starts",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": "30s",
  "schemaVersion": 22,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Clickhouse State",
  "uid": "r4RxTDhMz",
  "version": 13,
  "description": "Clickhouse dashboard. Data for dashboard is fetched from Clickhouse system tables. \n\nUseful for single-node installations of Clickhouse.\nTested version of ch - 20.9.2.20."
}