[
    {
        "schemaTableName": {
            "schemaName": "cluster_storage",
            "tableName": "tikv"
        },
        "columns": [
            {
                "name": "cluster_id",
                "type": "varchar(64)",
                "comment": "the id of the cluster the tikv component belong to"
            },
            {
                "name": "instance",
                "type": "varchar(64)",
                "comment": "the instance id of the tikv component, it's unique for each tikv in the same cluster"
            },
            {
                "name": "store_size",
                "type": "double",
                "comment": "the storage size used by this tikv measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tikv_store_size_bytes{type=\"used\",cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "capacity_size",
                "type": "double",
                "comment": "the total storage this tikv can use measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tikv_store_size_bytes{type=\"capacity\",cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            }
        ],
        "comment": "the capacity and usage of storage for each tikv component in the cluster"
    },
    {
        "schemaTableName": {
            "schemaName": "cluster_storage",
            "tableName": "tiflash"
        },
        "columns": [
            {
                "name": "cluster_id",
                "type": "varchar(64)",
                "comment": "the id of the cluster the tiflash component belong to"
            },
            {
                "name": "instance",
                "type": "varchar(64)",
                "comment": "the instance id of the tiflash component, it's unique for each tiflash in the same cluster"
            },
            {
                "name": "store_size",
                "type": "double",
                "comment": "the storage size used by this tiflash measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tiflash_system_current_metric_StoreSizeUsed{cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "capacity_size",
                "type": "double",
                "comment": "the total storage this tiflash can use measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tiflash_system_current_metric_StoreSizeCapacity{cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            }
        ],
        "comment": "the capacity and usage of storage for each tiflash component in the cluster"
    },
    {
        "schemaTableName": {
            "schemaName": "cluster_metrics",
            "tableName": "current_tidb_instance_resource"
        },
        "comment": "current resource by instance of tidb component in a specified cluster",
        "columns": [
            {
                "name": "cluster_id",
                "type": "varchar(64)",
                "comment": "the id of the cluster given by user"
            },
            {
                "name": "instance",
                "type": "varchar(64)",
                "comment": "the instance id of tidb component, it's unique for each tidb component in the same cluster"
            },
            {
                "name": "uptime",
                "type": "double",
                "comment": "uptime of tidb component measured in seconds",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg by (instance) ((time() - process_start_time_seconds{component=\"tidb\", cluster_id=~\".*{{.ClusterID}}\"}))",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_usage",
                "type": "double",
                "comment": "cpu usage of tidb component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(rate(node_cpu_seconds_total{mode!=\"idle\",component=\"tidb\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_usage",
                "type": "double",
                "comment": "memory usage of tidb component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"tidb\", cluster_id=~\".*{{.ClusterID}}\"} - node_memory_MemAvailable_bytes{component=\"tidb\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_limit",
                "type": "double",
                "comment": "cpu limit of tidb component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(tidb_server_maxprocs{component=\"tidb\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_limit",
                "type": "double",
                "comment": "memory limit of tidb component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"tidb\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            }
        ]
    },
    {
        "schemaTableName": {
            "schemaName": "cluster_metrics",
            "tableName": "current_tikv_instance_resource"
        },
        "comment": "current resource by instance of tikv component in a specified cluster",
        "columns": [
            {
                "name": "cluster_id",
                "type": "varchar(64)",
                "comment": "the id of the cluster given by user"
            },
            {
                "name": "instance",
                "type": "varchar(64)",
                "comment": "the instance id of tikv component, it's unique for each tikv component in the same cluster"
            },
            {
                "name": "uptime",
                "type": "double",
                "comment": "uptime of tikv component measured in seconds",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg by (instance) ((time() - process_start_time_seconds{component=\"tikv\", cluster_id=~\".*{{.ClusterID}}\"}))",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_usage",
                "type": "double",
                "comment": "cpu usage of tikv component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(rate(node_cpu_seconds_total{mode!=\"idle\",component=\"tikv\", cluster_id=~\".*{{.ClusterID}}\"})) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_usage",
                "type": "double",
                "comment": "memory usage of tikv component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"tikv\", cluster_id=~\".*{{.ClusterID}}\"} - node_memory_MemAvailable_bytes{component=\"tikv\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "io_bps_write",
                "type": "double",
                "comment": "write io of tikv component measured in MB_per_second",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "(sum(rate(tikv_engine_flow_bytes{db=\"kv\", type=\"wal_file_bytes\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) + (sum(rate(tikv_engine_flow_bytes{db=\"raft\", type=\"wal_file_bytes\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) or (0 * sum(rate(raft_engine_write_size_sum{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance))) + (sum(rate(raft_engine_write_size_sum{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) or (0 * sum(rate(tikv_engine_flow_bytes{db=\"raft\", type=\"wal_file_bytes\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance)))) /1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "io_bps_read",
                "type": "double",
                "comment": "read io of tikv component measured in MB_per_second",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(rate(tikv_engine_flow_bytes{db=\"kv\", type=~\"bytes_read|iter_bytes_read\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) /1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "storage_usage",
                "type": "double",
                "comment": "disk usage of tikv component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tikv_store_size_bytes{type=\"used\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_limit",
                "type": "double",
                "comment": "cpu limit of tikv component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(tikv_server_cpu_cores_quota{component=\"tikv\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_limit",
                "type": "double",
                "comment": "memory limit of tikv component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"tikv\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "storage_limit",
                "type": "double",
                "comment": "disk limit of tikv component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(tikv_store_size_bytes{type=\"capacity\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            }
        ]
    },
    {
        "schemaTableName": {
            "schemaName": "cluster_metrics",
            "tableName": "current_tiflash_instance_resource"
        },
        "comment": "current resource by instance of tiflash component in a specified cluster",
        "columns": [
            {
                "name": "cluster_id",
                "type": "varchar(64)",
                "comment": "the id of the cluster given by user"
            },
            {
                "name": "instance",
                "type": "varchar(64)",
                "comment": "the instance id of tiflash component, it's unique for each tiflash component in the same cluster"
            },
            {
                "name": "uptime",
                "type": "double",
                "comment": "uptime of tiflash component measured in seconds",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg by (instance) (tiflash_system_asynchronous_metric_Uptime{cluster_id=~\".*{{.ClusterID}}\"})",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_usage",
                "type": "double",
                "comment": "cpu usage of tiflash component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(rate(node_cpu_seconds_total{mode!=\"idle\",component=\"tiflash\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_usage",
                "type": "double",
                "comment": "memory usage of tiflash component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"tiflash\", cluster_id=~\".*{{.ClusterID}}\"} - node_memory_MemAvailable_bytes{component=\"tiflash\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "io_bps_write",
                "type": "double",
                "comment": "write io of tiflash component measured in MB_per_second",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "(sum(rate(tiflash_system_profile_event_WriteBufferFromFileDescriptorWriteBytes{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) + sum(rate(tiflash_system_profile_event_PSMWriteBytes{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) + sum(rate(tiflash_system_profile_event_WriteBufferAIOWriteBytes{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance)) /1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "io_bps_read",
                "type": "double",
                "comment": "read io of tiflash component measured in MB_per_second",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "(sum(rate(tiflash_system_profile_event_ReadBufferFromFileDescriptorReadBytes{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) + sum(rate(tiflash_system_profile_event_PSMReadBytes{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) + sum(rate(tiflash_system_profile_event_ReadBufferAIOReadBytes{cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance)) /1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "storage_usage",
                "type": "double",
                "comment": "disk usage of tiflash component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tiflash_system_current_metric_StoreSizeUsed{cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_limit",
                "type": "double",
                "comment": "cpu limit of tiflash component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(tiflash_system_current_metric_LogicalCPUCores{cluster_id=~\".*{{.ClusterID}}\"}) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_limit",
                "type": "double",
                "comment": "memory limit of tiflash component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"tiflash\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "storage_limit",
                "type": "double",
                "comment": "disk limit of tiflash component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(tiflash_system_current_metric_StoreSizeCapacity{cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            }
        ]
    },
    {
        "schemaTableName": {
            "schemaName": "cluster_metrics",
            "tableName": "current_pd_instance_resource"
        },
        "comment": "current resource by instance of pd component in a specified cluster",
        "columns": [
            {
                "name": "cluster_id",
                "type": "varchar(64)",
                "comment": "the id of the cluster given by user"
            },
            {
                "name": "instance",
                "type": "varchar(64)",
                "comment": "the instance id of pd component, it's unique for each pd component in the same cluster"
            },
            {
                "name": "uptime",
                "type": "double",
                "comment": "uptime of pd component measured in seconds",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg by (instance) ((time() - process_start_time_seconds{component=\"pd\", cluster_id=~\".*{{.ClusterID}}\"}))",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_usage",
                "type": "double",
                "comment": "cpu usage of pd component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "sum(rate(node_cpu_seconds_total{mode!=\"idle\",component=\"pd\", cluster_id=~\".*{{.ClusterID}}\"}[$__rate_interval])) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_usage",
                "type": "double",
                "comment": "memory usage of pd component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"pd\", cluster_id=~\".*{{.ClusterID}}\"} - node_memory_MemAvailable_bytes{component=\"pd\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "cpu_limit",
                "type": "double",
                "comment": "cpu limit of pd component measured in percentage",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "count(count by (instance,cpu)(node_cpu_seconds_total{component=\"pd\", cluster_id=~\".*{{.ClusterID}}\"})) by (instance) *100",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            },
            {
                "name": "memory_limit",
                "type": "double",
                "comment": "memory limit of pd component measured in GiB",
                "meta": {
                    "datasource": {
                        "uid": "aC208JH4z",
                        "type": "prometheus"
                    },
                    "expr": "avg(node_memory_MemTotal_bytes{component=\"pd\", cluster_id=~\".*{{.ClusterID}}\"}) by (instance) /1024/1024/1024",
                    "referer": "https://clinic.pingcap.com?var-org={{.OrgID}}&var-org_type=cloud&var-tidb_cluster={{.ClusterID}}"
                }
            }
        ]
    }
]