1

In my prometheus.yml I have several jobs defined like:

  - job_name: alpha
    scheme: 'https'
    metrics_path: '/metrics'
    static_configs:
      - targets:
        - one.example
        - two.example
    relabel_configs:
      - source_labels: [__address__]
        regex: '(.*).example.*'
        replacement: '${1}'
        target_label: 'slug'
  • job_name: beta scheme: 'https' metrics_path: '/metrics' static_configs:
    • targets:
      • three.example
      • four.example
    relabel_configs:
    • source_labels: [address] regex: '(.).example.' replacement: '${1}' target_label: 'slug'

as you can see, only the targets differ per job, all the other configs like relabel_configs and scheme etc. are the same. Because its not only two jobs but around 20 for now, I don't want to repeat the same settings for each job. Is there no way to create a default config for all jobs?

Vietna
  • 25
  • 5

1 Answers1

1

Is there no way to create a default config for all jobs?

No, there is no such way. relabel_configs are specified on the job level.

On the other hand, if all 20 of your jobs have exactly the same relabeling config, you might consider using a single job and additional labels for distinction (I assume you distinct right now by job label):

  - job_name: unitedjod
    scheme: 'https'
    metrics_path: '/metrics'
    static_configs:
      - targets:
        - one.example
        - two.example
        labels:
          target_type: alpha
      - targets:
        - three.example
        - four.example
        labels:
          target_type: beta
    relabel_configs:
      - source_labels: [__address__]
        regex: '(.*).example.*'
        replacement: '${1}'
        target_label: 'slug'

Here first group of targets will contain label target_type with value alpha, and second group - with value beta.

markalex
  • 160
  • 5