How to monitor multiple targets with servicemonitor ?

940 views
Skip to first unread message

enjo...@gmail.com

unread,
Apr 19, 2019, 8:57:09 AM4/19/19
to Prometheus Users
Hi all
I tried to use next servicemonitor config

apiVersion: monitoring.coreos.com/v1
kind
: ServiceMonitor
metadata
:
  labels
:
    k8s
-app: prometheus-blackbox-exporter
  name
: prometheus-blackbox-exporter
 
namespace: monitoring
spec
:
  endpoints
:
 
- interval: 60s
    port
: http-metrics
 
- interval: 60s
   
params:
     
module:
       
- health
      targets:
       
- https://google.com
       
- https://github.io

    path
: "/probe"
    targetPort
: 9115
    relabelings
:
     
- sourceLabels:
         
- __param_target
        targetLabel
: target
     
- sourceLabels:
         
- __param_module
        targetLabel
: module
  namespaceSelector
:
    matchNames
:
   
- monitoring
  selector
:
    app
: prometheus-blackbox-exporter

Also I tried to use 
      target:
       
- https://google.com
       
- https://github.io



It also doesn't work. 
Is there any way to use multiple targets with servicemonitor? 

Thanks

Maxim Efimov

unread,
Dec 2, 2019, 6:41:29 AM12/2/19
to Prometheus Users
Hi! You need more endpoint definitions for your servicemonitor differentiated by targets parameter:

apiVersion: monitoring.coreos.com/v1
kind
: ServiceMonitor
metadata
:
  labels
:
    k8s
-app: prometheus-blackbox-exporter
  name
: prometheus-blackbox-exporter
 
namespace: monitoring
spec
:
  endpoints
:
 
- interval: 60s

   
params:
     
module:
       
- health
      targets
:
       
- https://google.com

    path
: "/probe"
    targetPort
: 9115
    relabelings
:
     
- sourceLabels:
         
- __param_target
        targetLabel
: target
     
- sourceLabels:
         
- __param_module
        targetLabel
: module

 
- interval: 60s
   
params:
     
module:
       
- health
      targets
:

       
- https://github.io
    path
: "/probe"
    targetPort
: 9115
    relabelings
:
     
- sourceLabels:
         
- __param_target
        targetLabel
: target
     
- sourceLabels:
         
- __param_module
        targetLabel
: module
  namespaceSelector
:
    matchNames
:
   
- monitoring
  selector
:
    app
: prometheus-blackbox-exporter




пятница, 19 апреля 2019 г., 15:57:09 UTC+3 пользователь enjo...@gmail.com написал:

Maxim Efimov

unread,
Dec 2, 2019, 6:43:36 AM12/2/19
to Prometheus Users
Also based on your relabeling settings, your parameter should be named as target

понедельник, 2 декабря 2019 г., 14:41:29 UTC+3 пользователь Maxim Efimov написал:
Reply all
Reply to author
Forward
0 new messages