## Module 5: Monitor TiDB Using the Prometheus and Grafana

### Step 1. Check the status of the TiDB cluster

  ```bash
  tiup cluster display tidb-test
  ```

  ```output
  tiup is checking updates for component cluster ...
  Starting component `cluster`: /home/ec2-user/.tiup/components/cluster/v1.12.1/tiup-cluster display tidb-test
  Cluster type:       tidb
  Cluster name:       tidb-test
  Cluster version:    v7.5.1
  Deploy user:        tidb
  SSH type:           builtin
  Dashboard URL:      http://10.90.1.157:2379/dashboard
  Grafana URL:        http://10.90.4.229:3000
  ID                 Role          Host         Ports                            OS/Arch       Status  Data Dir                      Deploy Dir
  --                 ----          ----         -----                            -------       ------  --------                      ----------
  10.90.4.229:9093   alertmanager  10.90.4.229  9093/9094                        linux/x86_64  Up      /tidb-data/alertmanager-9093  /tidb-deploy/alertmanager-9093
  10.90.4.229:3000   grafana       10.90.4.229  3000                             linux/x86_64  Up      -                             /tidb-deploy/grafana-3000
  10.90.1.157:2379   pd            10.90.1.157  2379/2380                        linux/x86_64  Up|UI   /tidb-data/pd-2379            /tidb-deploy/pd-2379
  10.90.2.207:2379   pd            10.90.2.207  2379/2380                        linux/x86_64  Up|L    /tidb-data/pd-2379            /tidb-deploy/pd-2379
  10.90.3.169:2379   pd            10.90.3.169  2379/2380                        linux/x86_64  Up      /tidb-data/pd-2379            /tidb-deploy/pd-2379
  10.90.4.229:9090   prometheus    10.90.4.229  9090/12020                       linux/x86_64  Up      /tidb-data/prometheus-9090    /tidb-deploy/prometheus-9090
  10.90.1.127:4000   tidb          10.90.1.127  4000/10080                       linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
  10.90.2.227:4000   tidb          10.90.2.227  4000/10080                       linux/x86_64  Up      -                             /tidb-deploy/tidb-4000
  10.90.4.33:9000    tiflash       10.90.4.33   9000/8123/3930/20170/20292/8234  linux/x86_64  Up      /tidb-data/tiflash-9000       /tidb-deploy/tiflash-9000
  10.90.1.137:20160  tikv          10.90.1.137  20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
  10.90.2.24:20160   tikv          10.90.2.24   20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
  10.90.3.198:20160  tikv          10.90.3.198  20160/20180                      linux/x86_64  Up      /tidb-data/tikv-20160         /tidb-deploy/tikv-20160
  Total nodes: 12
  ```

### Step 2. Login to Grafana Dashboard

+ Click [Grafana Prometheus Dashboard](http://${LAB:HOST_MONITOR1_PUBLIC_IP}:3000) to access the Grafana URL. Enter `admin` in the `Email or username` field. Enter `admin` in the `Password` field.

![60%](https://lab-static.pingcap.com/quick-demo/GrafanaSignIn_aa_001_20220623.png)

### Step 3. Explore the Grafana Dashboard

+ On the `Search` page, expand the menu with the name as the `tidb-test`, and then click `tidb-test-Overview`.

![60%](https://lab-static.pingcap.com/quick-demo/GrafanaOverview01_aa_001_20220623.png)

![60%](https://lab-static.pingcap.com/quick-demo/GrafanaOverview02_aa_001_20220623.png)

+ Expand the `System-Info` menu of `tidb-test-Overview`, you can view the CPU and memory configuration, CPU, memory, IO, and network usage for each node, etc.

![60%](https://lab-static.pingcap.com/quick-demo/SystemInfo_en_001_20220621.png)

+ Expand the `Service Port Status` of `tidb-test-Overview`, you can view the online nodes number of each service.

![60%](https://lab-static.pingcap.com/quick-demo/ServicePortStatus_en_001_20220621.png)

+ Expand the PD monitoring page of `tidb-test-Overview`, you can get an overview of the component PD status from the PD dashboard, where the key metrics are displayed.

![60%](https://lab-static.pingcap.com/quick-demo/MonitoringIndicatorsForPD_en_001_20220621.png)

+ Expand the TiDB monitoring page of `tidb-test-Overview`, you can get an overview of the QPS, TPS, response delay, which serves as the monitoring information to be displayed or reported.

![60%](https://lab-static.pingcap.com/quick-demo/MonitoringIndicatorsForTiDBServer_en_001_20220621.png)

+ Expand the TiKV monitoring page of `tidb-test-Overview`, you can get an overview of the component TiKV status, where the key metrics are displayed. According to the Performance Map, you can check whether the status of the cluster is as expected.

![60%](https://lab-static.pingcap.com/quick-demo/MonitoringIndicatorsForTiKV_en_001_20220621.png)
