考虑到要明智地使用标签,咱们须要给事物从新命名。在一个集中的、复杂的监视环境中,咱们有时没法控制正在监视的全部资源以及它们公开的监视数据。从新标记容许在本身的环境中控制、管理和潜在地标准化度量。node
常见的用例是 :docker
scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] metric_relabel_configs: - source_labels: [__name__] separator: ',' regex: '(process_cpu_seconds_total|process_open_fds)' action: drop - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] params: collect[]: - cpu - meminfo - diskstats - job_name: 'docker' static_configs: - targets: ['192.168.31.151:8080']
备注:若是咱们指定了多个源标签,须要用 ; 分开:bash
regex1;regex2;regex3spa
其实是根据已有的标签,生成一个新标签3d
scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] metric_relabel_configs: - source_labels: [__name__] separator: ',' regex: '(process_cpu_seconds_total|process_open_fds)' action: drop - source_labels: [version] regex: 'go1.*' replacement: 'go_unknown' target_label: go_version - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] params: collect[]: - cpu - meminfo - diskstats - job_name: 'docker' static_configs: - targets: ['192.168.31.151:8080']
scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] metric_relabel_configs: - source_labels: [__name__] separator: ',' regex: '(process_cpu_seconds_total|process_open_fds)' action: drop - source_labels: [version] regex: 'go1.*' replacement: 'go_unknown' target_label: go_version - regex: 'version' action: labeldrop - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100'] params: collect[]: - cpu - meminfo - diskstats - job_name: 'docker' static_configs: - targets: ['192.168.31.151:8080']