prometheus 標籤使用

 標籤的配置使用

考慮到要明智地使用標籤,咱們須要給事物從新命名。在一個集中的、複雜的監視環境中,咱們有時沒法控制正在監視的全部資源以及它們公開的監視數據。從新標記容許在本身的環境中控制、管理和潛在地標準化度量node

常見的用例是 :docker

  • 刪除沒必要要的指標。
  • 從指標中刪除敏感或不須要的籤。
  • 添加、編輯或修改指標的籤值格式。

 

刪除metrics

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']
相關文章
相關標籤/搜索