Skip to content

Commit

Permalink
Tidbmonitor add tidb_cluster target label . (#3750) (#3753)
Browse files Browse the repository at this point in the history
* cherry pick #3750 to release-1.1

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix conflict

Co-authored-by: Mike <842725815@qq.com>
Co-authored-by: BinChen <binchinsmail@gmail.com>
Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 27, 2021
1 parent 1b64ac6 commit 38fbc12
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/monitor/monitor/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ func scrapeJob(jobName string, componentPattern config.Regexp, cmodel *MonitorCo
Action: config.RelabelReplace,
TargetLabel: "component",
},
{
SourceLabels: model.LabelNames{
namespaceLabel,
instanceLabel,
},
Separator: "-",
TargetLabel: "tidb_cluster",
},
},
}
if cmodel.EnableTLSCluster {
Expand Down
60 changes: 60 additions & 0 deletions pkg/monitor/monitor/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tidb
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -131,6 +134,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tikv
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -178,6 +184,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tiflash
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -225,6 +234,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tiflash-proxy
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -272,6 +284,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-pump
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -319,6 +334,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-drainer
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -366,6 +384,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-ticdc
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -413,6 +434,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-importer
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -460,6 +484,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-lightning
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -507,6 +534,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
remote_write:
- url: http://localhost:1234
remote_timeout: 15s
Expand Down Expand Up @@ -609,6 +639,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tidb
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -659,6 +692,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tikv
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -709,6 +745,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tiflash
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -759,6 +798,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-tiflash-proxy
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -809,6 +851,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-pump
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -859,6 +904,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-drainer
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -909,6 +957,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-ticdc
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -959,6 +1010,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-importer
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -1009,6 +1063,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
- job_name: ns1-target-lightning
honor_labels: true
scrape_interval: 15s
Expand Down Expand Up @@ -1056,6 +1113,9 @@ scrape_configs:
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_component]
target_label: component
action: replace
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app_kubernetes_io_instance]
separator: '-'
target_label: tidb_cluster
`
model := &MonitorConfigModel{
ClusterInfos: []ClusterRegexInfo{
Expand Down

0 comments on commit 38fbc12

Please sign in to comment.