diff --git a/pkg/monitor/monitor/template.go b/pkg/monitor/monitor/template.go index 25d4e11df6..d1ca2f8f4f 100644 --- a/pkg/monitor/monitor/template.go +++ b/pkg/monitor/monitor/template.go @@ -165,7 +165,17 @@ func buildAddressRelabelConfigByComponent(kind string) *config.RelabelConfig { case "tiflash": return f() case "tiflash-proxy": - return f() + return &config.RelabelConfig{ + Action: config.RelabelReplace, + Regex: addressPattern, + Replacement: "$1.$2-tiflash-peer:$3", + TargetLabel: "__address__", + SourceLabels: model.LabelNames{ + podNameLabel, + instanceLabel, + model.LabelName(fmt.Sprintf(additionalPortLabelPattern, "tiflash_proxy")), + }, + } case "pump": return &config.RelabelConfig{ Action: config.RelabelReplace, diff --git a/pkg/monitor/monitor/template_test.go b/pkg/monitor/monitor/template_test.go index 0c97d056c1..44403f2005 100644 --- a/pkg/monitor/monitor/template_test.go +++ b/pkg/monitor/monitor/template_test.go @@ -253,10 +253,10 @@ scrape_configs: target_label: __metrics_path__ action: replace - source_labels: [__meta_kubernetes_pod_name, __meta_kubernetes_pod_label_app_kubernetes_io_instance, - __meta_kubernetes_pod_annotation_prometheus_io_port] + __meta_kubernetes_pod_annotation_tiflash_proxy_prometheus_io_port] regex: (.+);(.+);(.+) target_label: __address__ - replacement: $1.$2-tiflash-proxy-peer:$3 + replacement: $1.$2-tiflash-peer:$3 action: replace - source_labels: [__meta_kubernetes_namespace] target_label: kubernetes_namespace @@ -622,10 +622,10 @@ scrape_configs: target_label: __metrics_path__ action: replace - source_labels: [__meta_kubernetes_pod_name, __meta_kubernetes_pod_label_app_kubernetes_io_instance, - __meta_kubernetes_pod_annotation_prometheus_io_port] + __meta_kubernetes_pod_annotation_tiflash_proxy_prometheus_io_port] regex: (.+);(.+);(.+) target_label: __address__ - replacement: $1.$2-tiflash-proxy-peer:$3 + replacement: $1.$2-tiflash-peer:$3 action: replace - source_labels: [__meta_kubernetes_namespace] target_label: kubernetes_namespace