Prometheus에서 메트릭 이름 앞에 네임 스페이스를 추가하는 방법은 무엇입니까?

Aug 18 2020

prometheus.yml에 정적 구성이 있습니다.

  - job_name: 'myjob'
    static_configs:
      - targets: ['monitoring.api.endpoint.net']

그리고 예를 들어 cpu_usage, disk_write_ops등의 다양한 메트릭을받습니다 . compute_cpu_usage레이블 재 지정 도구와 같이 네임 스페이스에 모두 넣을 수 있습니까?

답변

1 VasiliyShakhunov Aug 18 2020 at 20:11

이 솔루션을 찾았습니다.

static_configs:
  - targets: ['monitoring.api.endpoint.net']
metric_relabel_configs:
- source_labels: [__name__]
  regex: '(.*)'
  replacement: 'compute_${1}'
  target_label: __name__