I want to monitor some endpoints using Prometheus black box-exporter. For that I am building a new custom "black box-exporter" image using the Docker Hub image as base under my docker file {FROM docker.io/prom/blackbox-exporter:latest} So that I can add some required certs etc. with the image.
I am successfully able to deploy the image to k8 cluster and also can view my target under "Prometheus -> status -> targets". However the target endpoint is some ip address like "target="11.11.111.111:9115" not what i defined under service monitoring yml ";.
Can someone please assist me to fix the servicemonitoring.yaml ?
Note : wget -qO- ":9115/probe?target=;module=http_2xx&debug=true" probes fine when tested from k8 blackbox pod.
Thanks in advance !
configMap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: my-blackbox-exporter-config
labels:
app: my-blackbox-exporter
data:
config.yml: |
modules:
http_2xx:
prober: http
timeout: 5s
http:
method: GET
valid_http_versions: [ "HTTP/1.1", "HTTP/2.0" ]
valid_status_codes: []
follow_redirects: true
tls_config:
insecure_skip_verify: true
ca_file: /etc/ssl/certs/certchain.pem
and serviceMonitor.yaml
---
apiVersion: monitoring.coreos/v1
kind: ServiceMonitor
metadata:
name: my-blackbox-exporter-my-monitoring
labels:
release: prometheus
spec:
endpoints:
- port: http
interval: 10s
path: /probe
scheme: http
scrapeTimeout: 60s
metricRelabelings:
- action: replace
regex: (.*)
replacement:
sourceLabels:
- __param_target
targetLabel: target
params:
module: [https_2xx]
target: []
relabelings:
- sourceLabels: [__address__]
targetLabel: __param_target
- sourceLabels: [__param_target]
targetLabel: instance
- targetLabel: __address__
replacement: my-blackbox-exporter.my-blackbox-exporter.svc.cluster.local:9115
jobLabel: my-prometheus-blackbox-exporter
namespaceSelector:
matchNames:
- my-blackbox-exporter-npo
selector:
matchLabels:
app: my-blackbox-exporter