Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
meesk opened this issue Jan 27, 2025 · 4 comments
Open

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

meesk opened this issue Jan 27, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@meesk
Copy link

meesk commented Jan 27, 2025

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

@meesk meesk added the enhancement New feature or request label Jan 27, 2025
@jkroepke
Copy link
Member

jkroepke commented Jan 27, 2025

@QuentinBisson @GMartinez-Sisti whats your opinion about the integration of the blackbox_exporter into the kube-prometheus-stack, including Probe CRDs and a default probe which supports simple http?

If agreed, @meesk are you open to contribute the functionality?

@meesk
Copy link
Author

meesk commented Jan 28, 2025

@jkroepke yes absolutely. I feel like it should be possible, because it already provides the declaration for the CRD but no way to implement it.

@GMartinez-Sisti
Copy link
Member

GMartinez-Sisti commented Jan 28, 2025

@QuentinBisson @GMartinez-Sisti whats your opinion about the integration of the blackbox_exporter into the kube-prometheus-stack, including Probe CRDs and a default probe which supports simple http?

I think it makes sense. It's very common to require it with kube-prometheus-stack.

@QuentinBisson
Copy link
Member

I agree as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants