Skip to content

[kube-prometheus-stack] Define custom Probe CRD's within Chart #5241

Open
@meesk

Description

@meesk

Is your feature request related to a problem ?

I'm currently writing a Probe definition to scrape some targets using the ingress target (via blackbox exporter), however, there is no way to create a Probe CRD using a built in functionality. Currently I have to write my own template to create these Probe CRD's. As far as I know, this currently is not possible. Some ingresses differ which requires me to write multiple Probe CRD's. It would be nice to create Probes dynamically built into the chart.

If there is already an alternative or any reason why this shouldn't be supported, please let me know.

Describe the solution you'd like.

Provide a built in solution to create Probe CRD's.

Describe alternatives you've considered.

Using my own template, for example:

{{- range .Values.prometheus.prometheusSpec.probes }}
apiVersion: monitoring.coreos.com/v1
kind: Probe
metadata:
  name: {{ .name }}
  namespace: prometheus
  labels:
    release: prometheus
spec:
  jobName: {{ .name }}
  interval: 2m
  prober:
    url: prometheus-blackbox-exporter.prometheus.svc.cluster.local:9115
  targets:
    ingress:
      namespaceSelector:
        matchNames:
          - dev
      selector:
        matchLabels:
        {{- range $key, $val := .matchLabels }}
          {{ $key }}: {{ $val | quote }}
        {{- end }}
      relabelingConfigs:
        - action: replace
          replacement: prometheus-blackbox-exporter.prometheus.svc.cluster.local:9115
          targetLabel: __address__
        - action: replace
          sourceLabels: [__meta_kubernetes_ingress_host, __meta_kubernetes_ingress_path, __meta_kubernetes_ingress_annotation_prometheus_io_probe_path]
          regex: {{ .regex.pattern }}
          replacement: {{ .regex.replacement }}
          targetLabel: __param_target
        - action: replace
          sourceLabels: [__param_target]
          targetLabel: target
        - action: replace
          sourceLabels: [__meta_kubernetes_ingress_name]
          targetLabel: instance
        - action: replace
          sourceLabels: [__meta_kubernetes_ingress_annotation_prometheus_io_module]
          targetLabel: module
        - action: replace
          sourceLabels: [module]
          targetLabel: __param_module
        - action: labeldrop
          regex: __meta_kubernetes_ingress_.*
{{- end }}

Then in my values I currently do something like:

     probes:
        - name: microservice-probe
          matchLabels:
            prometheus.io/probe: 'true' # label defined on ingress
            prometheus.io/probe-template: template-a # label defined on ingress
          regex: 
            pattern: [some-regex-pattern]
            replacement: [some-replacement]

This is ofcourse just an example of my current implementation, it would need more customization.

Additional context.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions