Prometheus黑匣子导出器与VictoriaMetrics

huangapple go评论50阅读模式
英文:

Prometheus blackbox exporter with VictoriaMetrics

问题

I'm trying to setup a blackbox exporter to monitor external web urls. I have installed the blackbox using Helm.

values.yaml 只有上述配置部分已被修改。

I have then updated VM Secret - additional-scrape-configs to scrape Probe from blackbox

VMAgent doesn't pull any metrics for the target https://myrlsek8s.my.local/grafana. I have already tested blackbox functionality by using curl curl -s "http://my-prometheus-blackbox-exporter.monitoring.svc.cluster.local:9115/probe?target=https://myrlsek8s.my.local/grafana&module=http_2xx" and this works fine.

Not sure what I'm missing here! I tried to create VMProbe but still no success in getting probe metrics into VictoriaMetrics.

Any help is really appreciated.

PS: I do not use Prometheus, I use VictoriaMetrics Agent for scraping the targets.

I'm expecting the probe metrics to be pulled into VictoriaMetrics.

英文:

I'm trying to setup a blackbox exporter to monitor external web urls. I have installed the blackbox using Helm

helm install my -f ./values.yaml prometheus-community/prometheus-blackbox-exporter -n monitoring

ConfigMap - my-prometheus-blackbox-exporter
apiVersion: v1
data:
  blackbox.yaml: |
    modules:
      http_2xx:
        http:
          follow_redirects: true
          preferred_ip_protocol: ip4
          tls_config:
            insecure_skip_verify: true
          valid_http_versions:
          - HTTP/1.1
          - HTTP/2.0
        prober: http
        timeout: 5s
      http_4xx:
        http:
          follow_redirects: true
          method: GET
          preferred_ip_protocol: ip4
          tls_config:
            insecure_skip_verify: true
          valid_http_versions:
          - HTTP/1.1
          - HTTP/2.0
          valid_status_codes:
          - 404
          - 405
        prober: http
        timeout: 5s
kind: ConfigMap

values.yaml only has been modified for above config map.

I have then updated VM Secret - additional-scrape-configs to scrape Probe from blackbox

apiVersion: v1
kind: Secret
metadata:
  name: additional-scrape-configs
  namespace: monitoring
stringData:
  prometheus-additional.yaml: |
    - job_name: 'blackbox'
      metrics_path: /probe
      params:
        module: [http_2xx]
      static_configs:
       - targets:
          - https://myrlsek8s.my.local/grafana
      relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: my-prometheus-blackbox-exporter.monitoring.svc.cluster.local:9115

VMAgent doesn't pull any metrics for the target https://myrlsek8s.my.local/grafana. I have already tested blackbox functionality by using curl
curl -s "http://my-prometheus-blackbox-exporter.monitoring.svc.cluster.local:9115/probe?target=https://myrlsek8s.my.local/grafana&module=http_2xx" and this works fine

Not sure what I'm missing here! I tried to create VMProbe but still no success in getting probe metrics into VictoriaMetrics.

cat << EOF | kubectl apply -f -
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMProbe
metadata:
  name: probe-agent
  namespace: monitoring
spec:
  jobName: blackbox
  vmProberSpec:
     # by default scheme http, and path is /probe
     url: my-prometheus-blackbox-exporter.monitoring.svc.cluster.local:9115
  module: http_2xx
  targets:
   staticConfig: 
      targets:
      - vmagent-my-vm-victoria-metrics-k8s-stack.monitoring.svc:8429/health
	  - https://myrlsek8s.my.local/grafana
  interval: 2s 
EOF

Any help is really appreciated.

PS: I do not use Prometheus, I use VictoriaMetrics Agent for scraping the targets.

I'm expecting the probe metrics to be pulled into VictoriaMetrics

答案1

得分: 2

你可以尝试使用VMStaticScrape。以下是一些示例:

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMStaticScrape
metadata:
  name: probe-agent
  namespace: monitoring
  labels:
    {{- include "prometheus-blackbox-exporter.labels" . | nindent 4 }}
spec:
  targetEndpoints:
    - targets:
        - https://victoriametrics.com
      params:
        module: [http_2xx]
      path: /probe
      relabelConfigs:
        - source_labels: [__address__]
          target_label: __param_target
        - source_labels: [__param_target]
          target_label: instance
        - target_label: __address__
          replacement: {{ include "prometheus-blackbox-exporter.fullname" . }}.{{ .Release.Namespace }}:9115

请注意,这是一段YAML配置代码。

英文:

You can try to use VMStaticScrape. Here is some example

    apiVersion: operator.victoriametrics.com/v1beta1
kind: VMStaticScrape
metadata:
  name: probe-agent
  namespace: monitoring
  labels:
    {{- include "prometheus-blackbox-exporter.labels" . | nindent 4 }}
spec:
  targetEndpoints:
    - targets:
        - https://victoriametrics.com
      params:
        module: [http_2xx]
      path: /probe
      relabelConfigs:
        - source_labels: [ __address__ ]
          target_label: __param_target
        - source_labels: [ __param_target ]
          target_label: instance
        - target_label: __address__
          replacement: {{ include "prometheus-blackbox-exporter.fullname" . }}.{{ .Release.Namespace }}:9115```

</details>



huangapple
  • 本文由 发表于 2023年3月21日 00:09:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75792690.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定