Prometheus - add target specific label in static_configs

后端 未结 5 528
迷失自我
迷失自我 2021-02-04 00:35

I have job definition as follows:

  - job_name: \'test-name\'
    static_configs:
      - targets: [ \'192.168.1.1:9100\', \'192.168.1.1:9101\', \'192.168.1.1:91         


        
相关标签:
5条回答
  • 2021-02-04 00:49

    For different services you should usually vary the job label, so I would suggest duplicating the scrape config with a job_name of service1 for one and service2 for the other.

    0 讨论(0)
  • 2021-02-04 00:56

    I have the same question before. Here is my solution:

    1. use job_name as the group label
    2. add more target option to separate instance and add labels

    For you the code may like this:

      - job_name: 'development'
          static_configs:
          - targets: [ '192.168.1.1:9100' ]
            labels:
              service: '1'
          - targets: [ '192.168.1.1:9101' ]
            labels:
              service: '2'
    
    0 讨论(0)
  • 2021-02-04 00:56

    Can be link this

      - job_name: 'node'
        static_configs:
        - targets: ['192.168.1.117:9100']
          labels:
            instance: 'linux-ina'
        - targets: ['192.168.1.138:9100']
          labels:
            instance: 'linux-inb'
    

    Tag name can be replaced with instance

    0 讨论(0)
  • 2021-02-04 00:59

    You can find information in here - Prometheus Good Config

    But I have used these and it worked

    
      - job_name:  'PostgreSQL-exporter'
        scrape_interval: 60s
        scrape_timeout: 60s
        static_configs:
          - targets: ['localhost:9187']
          - labels:
              name: value-for-the-name
    
    0 讨论(0)
  • 2021-02-04 01:10

    You can use File Based ServiceDiscovery to achieve this. See this Blog Post for more details.

    0 讨论(0)
提交回复
热议问题