Welcome to mirror list, hosted at ThFree Co, Russian Federation.

template_db_tidb_pd_http.yaml « tidb_pd_http « tidb_http « db « templates - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 01512e840da04c213b0ba34b92f6e3fc6153e2dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
zabbix_export:
  version: '6.2'
  date: '2022-04-06T20:01:17Z'
  groups:
    -
      uuid: 748ad4d098d447d492bb935c907f652f
      name: Templates/Databases
  templates:
    -
      uuid: 43596328d4d74a5592906a9e08e3fd96
      template: 'TiDB PD by HTTP'
      name: 'TiDB PD by HTTP'
      description: |
        The template to monitor PD server of TiDB cluster by Zabbix that works without any external scripts.
        Most of the metrics are collected in one go, thanks to Zabbix bulk data collection.
        Don't forget to change the macros {$PD.URL}, {$PD.PORT}.
        
        Template `TiDB PD by HTTP` — collects metrics by HTTP agent from PD /metrics endpoint and from monitoring API.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback
        
        Template tooling version used: 0.41
      groups:
        -
          name: Templates/Databases
      items:
        -
          uuid: 3a1fd879a08a445cbf438f3d68078111
          name: 'PD: Get instance metrics'
          type: HTTP_AGENT
          key: pd.get_metrics
          history: '0'
          trends: '0'
          value_type: TEXT
          description: 'Get TiDB PD instance metrics.'
          preprocessing:
            -
              type: CHECK_NOT_SUPPORTED
              parameters:
                - ''
            -
              type: PROMETHEUS_TO_JSON
              parameters:
                - ''
          url: '{$PD.URL}:{$PD.PORT}/metrics'
          tags:
            -
              tag: component
              value: raw
        -
          uuid: 7eb740eed4eb43a0a449e1c1436e582b
          name: 'PD: Get instance status'
          type: HTTP_AGENT
          key: pd.get_status
          history: '0'
          trends: '0'
          value_type: TEXT
          description: 'Get TiDB PD instance status info.'
          preprocessing:
            -
              type: CHECK_NOT_SUPPORTED
              parameters:
                - ''
              error_handler: CUSTOM_VALUE
              error_handler_params: '{"status": "0"}'
          url: '{$PD.URL}:{$PD.PORT}/pd/api/v1/status'
          tags:
            -
              tag: component
              value: health
            -
              tag: component
              value: raw
        -
          uuid: 101266930d0747748bf3cbd9259e2818
          name: 'PD: GRPC Commands total, rate'
          type: DEPENDENT
          key: pd.grpc_command.rate
          delay: '0'
          history: 7d
          value_type: FLOAT
          description: 'The rate at which gRPC commands are completed.'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name == "grpc_server_handling_seconds_count")].value.sum()'
              error_handler: DISCARD_VALUE
            -
              type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: pd.get_metrics
          tags:
            -
              tag: component
              value: grpc
        -
          uuid: c18f702f68bf4fed94a598daffdada8a
          name: 'PD: Status'
          type: DEPENDENT
          key: pd.status
          delay: '0'
          history: 7d
          trends: '0'
          value_type: CHAR
          description: 'Status of PD instance.'
          valuemap:
            name: 'Service state'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.status
              error_handler: CUSTOM_VALUE
              error_handler_params: '1'
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: pd.get_status
          tags:
            -
              tag: component
              value: health
          triggers:
            -
              uuid: ab1d0d23dad844099e42debb71512887
              expression: 'last(/TiDB PD by HTTP/pd.status)=0'
              name: 'PD: Instance is not responding'
              priority: AVERAGE
              tags:
                -
                  tag: scope
                  value: availability
        -
          uuid: 0b71c8a5104b46ebbeabe0d708b6676e
          name: 'PD: Uptime'
          type: DEPENDENT
          key: pd.uptime
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: uptime
          description: 'The runtime of each PD instance.'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.start_timestamp
            -
              type: JAVASCRIPT
              parameters:
                - |
                  //use boottime to calculate uptime
                  return (Math.floor(Date.now()/1000)-Number(value));
          master_item:
            key: pd.get_status
          tags:
            -
              tag: component
              value: application
          triggers:
            -
              uuid: 9f47a19f6f424df598e74c5a653ebf27
              expression: 'last(/TiDB PD by HTTP/pd.uptime)<10m'
              name: 'PD: has been restarted'
              event_name: 'PD: has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes'
              manual_close: 'YES'
              tags:
                -
                  tag: scope
                  value: notice
        -
          uuid: c7e8e9bf01d04e5db25bd8eaafff3b80
          name: 'PD: Version'
          type: DEPENDENT
          key: pd.version
          delay: '0'
          history: 7d
          trends: '0'
          value_type: CHAR
          description: 'Version of the PD instance.'
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - $.version
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: pd.get_status
          tags:
            -
              tag: component
              value: application
          triggers:
            -
              uuid: 6fb6045405af4c89b09750f57ada472a
              expression: 'last(/TiDB PD by HTTP/pd.version,#1)<>last(/TiDB PD by HTTP/pd.version,#2) and length(last(/TiDB PD by HTTP/pd.version))>0'
              name: 'PD: Version has changed'
              event_name: 'PD: Version has changed (new version: {ITEM.VALUE})'
              priority: INFO
              description: 'PD version has changed. Ack to close.'
              manual_close: 'YES'
              tags:
                -
                  tag: scope
                  value: notice
      discovery_rules:
        -
          uuid: cd1f27cf5f1d4f6f84032386ec7f8abb
          name: 'Cluster metrics discovery'
          type: DEPENDENT
          key: pd.cluster.discovery
          delay: '0'
          description: 'Discovery cluster specific metrics.'
          item_prototypes:
            -
              uuid: fe49e1de54214fb0ac882feb42fdee3b
              name: 'TiDB cluster: Number of regions'
              type: DEPENDENT
              key: 'pd.cluster_status.leader_count[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The total count of cluster Regions.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "leader_count")].value.first()'
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: regions
            -
              uuid: 0950ba514e05447c8cfe726ec2d76944
              name: 'TiDB cluster: Current peer count'
              type: DEPENDENT
              key: 'pd.cluster_status.region_count[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The current count of all cluster peers.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "region_count")].value.first()'
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: peers
            -
              uuid: d39f58372e3f464c87b2ec42acdf2061
              name: 'TiDB cluster: Storage capacity'
              type: DEPENDENT
              key: 'pd.cluster_status.storage_capacity[{#SINGLETON}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              units: B
              description: 'The total storage capacity for this TiDB cluster.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "storage_capacity")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: storage
            -
              uuid: c72e6a2f89d041c4bf764021b9bc182c
              name: 'TiDB cluster: Storage size'
              type: DEPENDENT
              key: 'pd.cluster_status.storage_size[{#SINGLETON}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              units: B
              description: 'The storage size that is currently used by the TiDB cluster.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "storage_size")].value.first()'
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: storage
            -
              uuid: 517cea991add45319d30047ac96fd9e4
              name: 'TiDB cluster: Disconnect stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_disconnected[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The count of disconnected stores.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_disconnected_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
              trigger_prototypes:
                -
                  uuid: 077d39f8ea194081a9d0c5dfdec4d1b5
                  expression: 'last(/TiDB PD by HTTP/pd.cluster_status.store_disconnected[{#SINGLETON}])>0'
                  name: 'TiDB cluster: There are disconnected TiKV nodes'
                  priority: WARNING
                  description: 'PD does not receive a TiKV heartbeat within 20 seconds. Normally a TiKV heartbeat comes in every 10 seconds.'
                  tags:
                    -
                      tag: scope
                      value: availability
            -
              uuid: 7125a7c858264f339e879c1389c6c027
              name: 'TiDB cluster: Down stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_down[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The count of down stores.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_down_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
              trigger_prototypes:
                -
                  uuid: 526b935d3fa04825b7544eb6efd50ab5
                  expression: 'last(/TiDB PD by HTTP/pd.cluster_status.store_down[{#SINGLETON}])>0'
                  name: 'TiDB cluster: There are offline TiKV nodes'
                  priority: AVERAGE
                  description: 'PD has not received a TiKV heartbeat for a long time.'
                  tags:
                    -
                      tag: scope
                      value: availability
            -
              uuid: c3bd9d1e0f6c427ab5232e57769030d1
              name: 'TiDB cluster: Lowspace stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_low_space[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The count of low space stores.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_low_space_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
              trigger_prototypes:
                -
                  uuid: 87ef0f211afd4d58adec05007ef1d263
                  expression: 'last(/TiDB PD by HTTP/pd.cluster_status.store_low_space[{#SINGLETON}])>0'
                  name: 'TiDB cluster: There are low space TiKV nodes'
                  priority: AVERAGE
                  description: 'Indicates that there is no sufficient space on the TiKV node.'
                  tags:
                    -
                      tag: scope
                      value: capacity
            -
              uuid: 3c24fb49463b45f199dbc3955e87d01b
              name: 'TiDB cluster: Offline stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_offline[{#SINGLETON}]'
              delay: '0'
              history: 7d
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_offline_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
            -
              uuid: 476a1b6e3c9b4b41ae1637f0e12801c9
              name: 'TiDB cluster: Tombstone stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_tombstone[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The count of tombstone stores.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_tombstone_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
            -
              uuid: 89db2b996fbe41bdb6b82ccf75139090
              name: 'TiDB cluster: Unhealth stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_unhealth[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The count of unhealthy stores.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_unhealth_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
            -
              uuid: ff80108e2a5e45779a428a6fd31ea089
              name: 'TiDB cluster: Normal stores'
              type: DEPENDENT
              key: 'pd.cluster_status.store_up[{#SINGLETON}]'
              delay: '0'
              history: 7d
              description: 'The count of healthy storage instances.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_cluster_status" && @.labels.type == "store_up_count")].value.first()'
                -
                  type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: cluster
                -
                  tag: component
                  value: stores
          trigger_prototypes:
            -
              uuid: 843d566b33bc401390c2a633d08bb033
              expression: 'min(/TiDB PD by HTTP/pd.cluster_status.storage_size[{#SINGLETON}],5m)/last(/TiDB PD by HTTP/pd.cluster_status.storage_capacity[{#SINGLETON}])*100>{$PD.STORAGE_USAGE.MAX.WARN}'
              name: 'TiDB cluster: Current storage usage is too high'
              event_name: 'TiDB cluster: Current storage usage is too high (over {$PD.STORAGE_USAGE.MAX.WARN}% for 5m)'
              priority: WARNING
              description: 'Over {$PD.STORAGE_USAGE.MAX.WARN}% of the cluster space is occupied.'
              tags:
                -
                  tag: scope
                  value: capacity
          graph_prototypes:
            -
              uuid: 270de7aa73cf454cb147a3f5b39ebb35
              name: 'TiDB cluster: Storage Usage[{#SINGLETON}]'
              graph_items:
                -
                  color: 1A7C11
                  item:
                    host: 'TiDB PD by HTTP'
                    key: 'pd.cluster_status.storage_size[{#SINGLETON}]'
                -
                  sortorder: '1'
                  color: 2774A4
                  item:
                    host: 'TiDB PD by HTTP'
                    key: 'pd.cluster_status.storage_capacity[{#SINGLETON}]'
          master_item:
            key: pd.get_metrics
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name=="pd_cluster_status")]'
              error_handler: CUSTOM_VALUE
              error_handler_params: '[]'
            -
              type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value != "[]" ? [{''{#SINGLETON}'': ''''}] : []);'
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        -
          uuid: 113c6ba7d7f74051b042241441c43db0
          name: 'gRPC commands discovery'
          type: DEPENDENT
          key: pd.grpc_command.discovery
          delay: '0'
          description: 'Discovery grpc commands specific metrics.'
          item_prototypes:
            -
              uuid: 7b96abc0e68a405ea5693f4f445936fe
              name: 'PD: GRPC Commands: {#GRPC_METHOD}, rate'
              type: DEPENDENT
              key: 'pd.grpc_command.rate[{#GRPC_METHOD}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The rate per command type at which gRPC commands are completed.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "grpc_server_handling_seconds_count" && @.labels.grpc_method == "{#GRPC_METHOD}")].value.first()'
                -
                  type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: grpc
                -
                  tag: grpc_method
                  value: '{#GRPC_METHOD}'
          master_item:
            key: pd.get_metrics
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name == "grpc_server_handling_seconds_count")]'
              error_handler: DISCARD_VALUE
            -
              type: JAVASCRIPT
              parameters:
                - |
                  var lookup = {},
                      result = [];
                  
                  JSON.parse(value).forEach(function (item) {
                      var grpc_method = item.labels.grpc_method;
                      if (!(lookup[grpc_method])) {
                          lookup[grpc_method] = 1;
                          result.push({ "{#GRPC_METHOD}": grpc_method });
                      }
                  })
                  
                  return JSON.stringify(result);
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        -
          uuid: 2cb28d7c862d442a84b5942eb4b54e2f
          name: 'Region discovery'
          type: DEPENDENT
          key: pd.region.discovery
          delay: '0'
          description: 'Discovery region specific metrics.'
          item_prototypes:
            -
              uuid: 024bf1d31bbd40a49d683d962887c6e0
              name: 'PD: Region heartbeat: error, rate'
              type: DEPENDENT
              key: 'pd.region_heartbeat.error.rate[{#STORE_ADDRESS}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The count of heartbeats with the error status per second.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_scheduler_region_heartbeat" && @.labels.status == "err" && @.labels.type == "report" && @.labels.address == "{#STORE_ADDRESS}")].value.sum()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                -
                  type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: address
                  value: '{#STORE_ADDRESS}'
                -
                  tag: component
                  value: regions
            -
              uuid: 1d1d686f5c544a89a691a9b75e5c3b11
              name: 'PD: Region heartbeat: active, rate'
              type: DEPENDENT
              key: 'pd.region_heartbeat.ok.rate[{#STORE_ADDRESS}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The count of heartbeats with the ok status per second.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_scheduler_region_heartbeat" && @.labels.status == "ok" && @.labels.type == "report" && @.labels.address == "{#STORE_ADDRESS}")].value.sum()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                -
                  type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: address
                  value: '{#STORE_ADDRESS}'
                -
                  tag: component
                  value: regions
            -
              uuid: c44f934ce8a144afa95252041535ef44
              name: 'PD: Region schedule push: total, rate'
              type: DEPENDENT
              key: 'pd.region_heartbeat.push.err.rate[{#STORE_ADDRESS}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_scheduler_region_heartbeat" && @.labels.type == "push" && @.labels.address == "{#STORE_ADDRESS}")].value.sum()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                -
                  type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: address
                  value: '{#STORE_ADDRESS}'
                -
                  tag: component
                  value: regions
            -
              uuid: ea76344669de4251a0e7bef35d70494a
              name: 'PD: Region heartbeat: total, rate'
              type: DEPENDENT
              key: 'pd.region_heartbeat.rate[{#STORE_ADDRESS}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The count of heartbeats reported to PD per instance per second.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_scheduler_region_heartbeat" && @.labels.type == "report" && @.labels.address == "{#STORE_ADDRESS}")].value.sum()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                -
                  type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: address
                  value: '{#STORE_ADDRESS}'
                -
                  tag: component
                  value: regions
          master_item:
            key: pd.get_metrics
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name == "pd_scheduler_region_heartbeat")]'
              error_handler: DISCARD_VALUE
            -
              type: JAVASCRIPT
              parameters:
                - |
                  var lookup = {},
                      result = [];
                  
                  JSON.parse(value).forEach(function (item) {
                      var address = item.labels.address;
                      if (!(lookup[address])) {
                          lookup[address] = 1;
                          result.push({ "{#STORE_ADDRESS}": address });
                      }
                  })
                  
                  return JSON.stringify(result);
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        -
          uuid: 771ba9e078a14ca489eb2acf906080e9
          name: 'Region labels discovery'
          type: DEPENDENT
          key: pd.region_labels.discovery
          delay: '0'
          description: 'Discovery region labels specific metrics.'
          item_prototypes:
            -
              uuid: 117efc3f2fe64c51a18cd3be162185ea
              name: 'TiDB cluster: Regions label: {#TYPE}'
              type: DEPENDENT
              key: 'pd.region_labels[{#TYPE}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The number of Regions in different label levels.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_regions_label_level" && @.labels.type == "{#TYPE}")].value.first()'
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: regions
                -
                  tag: type
                  value: '{#TYPE}'
          master_item:
            key: pd.get_metrics
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name == "pd_regions_label_level")]'
              error_handler: DISCARD_VALUE
            -
              type: JAVASCRIPT
              parameters:
                - |
                  output = JSON.parse(value).map(function(item){
                       return {
                           "{#TYPE}": item.labels.type,
                       }})
                   return JSON.stringify({"data": output})
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        -
          uuid: ffbf9adaa72842fdbb49c008625c1575
          name: 'Region status discovery'
          type: DEPENDENT
          key: pd.region_status.discovery
          delay: '0'
          description: 'Discovery region status specific metrics.'
          item_prototypes:
            -
              uuid: 45ef4940b0454492b70116d8958c9b11
              name: 'TiDB cluster: Regions status: {#TYPE}'
              type: DEPENDENT
              key: 'pd.region_status[{#TYPE}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The health status of Regions indicated via the count of unusual Regions including pending peers, down peers, extra peers, offline peers, missing peers, learner peers and incorrect namespaces.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_regions_status" && @.labels.type == "{#TYPE}")].value.first()'
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: regions
                -
                  tag: type
                  value: '{#TYPE}'
              trigger_prototypes:
                -
                  uuid: 2bc6b48bbfd8436e80903ea947571501
                  expression: 'min(/TiDB PD by HTTP/pd.region_status[{#TYPE}],5m)>0'
                  name: 'TiDB cluster: There are unresponsive peers'
                  discover: NO_DISCOVER
                  priority: WARNING
                  description: 'The number of Regions with an unresponsive peer reported by the Raft leader.'
                  tags:
                    -
                      tag: scope
                      value: availability
                -
                  uuid: 1f80bd81d11345f59699617113a0cad5
                  expression: 'min(/TiDB PD by HTTP/pd.region_status[{#TYPE}],5m)>{$PD.MISS_REGION.MAX.WARN}'
                  name: 'TiDB cluster: Too many missed regions'
                  event_name: 'TiDB cluster: Too many missed regions (over {$PD.MISS_REGION.MAX.WARN} in 5m)'
                  discover: NO_DISCOVER
                  priority: WARNING
                  description: 'The number of Region replicas is smaller than the value of max-replicas. When a TiKV machine is down and its downtime exceeds max-down-time, it usually leads to missing replicas for some Regions during a period of time. When a TiKV node is made offline, it might result in a small number of Regions with missing replicas.'
                  tags:
                    -
                      tag: scope
                      value: availability
          master_item:
            key: pd.get_metrics
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name == "pd_regions_status")]'
              error_handler: DISCARD_VALUE
            -
              type: JAVASCRIPT
              parameters:
                - |
                  output = JSON.parse(value).map(function(item){
                       return {
                           "{#TYPE}": item.labels.type,
                       }})
                   return JSON.stringify({"data": output})
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          overrides:
            -
              name: 'Too many missed regions trigger'
              step: '1'
              filter:
                conditions:
                  -
                    macro: '{#TYPE}'
                    value: miss_peer_region_count
                    formulaid: A
              operations:
                -
                  operationobject: TRIGGER_PROTOTYPE
                  operator: LIKE
                  value: 'Too many missed regions'
                  status: ENABLED
                  discover: DISCOVER
            -
              name: 'Unresponsive peers trigger'
              step: '2'
              filter:
                conditions:
                  -
                    macro: '{#TYPE}'
                    value: down_peer_region_count
                    formulaid: A
              operations:
                -
                  operationobject: TRIGGER_PROTOTYPE
                  operator: LIKE
                  value: 'There are unresponsive peers'
                  status: ENABLED
                  discover: DISCOVER
        -
          uuid: b4b8007810ad4f7ba8da212cdde5b71b
          name: 'Running scheduler discovery'
          type: DEPENDENT
          key: pd.scheduler.discovery
          delay: '0'
          description: 'Discovery scheduler specific metrics.'
          item_prototypes:
            -
              uuid: c6748a20540f49b293795bc72480dda7
              name: 'TiDB cluster: Scheduler status: {#KIND}'
              type: DEPENDENT
              key: 'pd.scheduler[{#KIND}]'
              delay: '0'
              history: 7d
              value_type: FLOAT
              description: 'The current running schedulers.'
              preprocessing:
                -
                  type: JSONPATH
                  parameters:
                    - '$[?(@.name == "pd_regions_status" && @.labels.type == "allow" && @.labels.kind == "{#KIND}")].value.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: pd.get_metrics
              tags:
                -
                  tag: component
                  value: scheduler
                -
                  tag: scheduler
                  value: '{#KIND}'
          master_item:
            key: pd.get_metrics
          preprocessing:
            -
              type: JSONPATH
              parameters:
                - '$[?(@.name == "pd_scheduler_status" && @.labels.type == "allow")]'
              error_handler: DISCARD_VALUE
            -
              type: JAVASCRIPT
              parameters:
                - |
                  output = JSON.parse(value).map(function(item){
                       return {
                           "{#KIND}": item.labels.kind,
                       }})
                   return JSON.stringify({"data": output})
            -
              type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
      tags:
        -
          tag: class
          value: database
        -
          tag: target
          value: pd
        -
          tag: target
          value: tidb
      macros:
        -
          macro: '{$PD.MISS_REGION.MAX.WARN}'
          value: '100'
          description: 'Maximum number of missed regions'
        -
          macro: '{$PD.PORT}'
          value: '2379'
          description: 'The port of PD server metrics web endpoint'
        -
          macro: '{$PD.STORAGE_USAGE.MAX.WARN}'
          value: '80'
          description: 'Maximum percentage of cluster space used'
        -
          macro: '{$PD.URL}'
          value: localhost
          description: 'PD server URL'
      valuemaps:
        -
          uuid: bce54cbdf2b8487985f9c7847a4c4918
          name: 'Service state'
          mappings:
            -
              value: '0'
              newvalue: Down
            -
              value: '1'
              newvalue: Up