How to monitor multiple targets with servicemonitor ?

949 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