ebpf_exporter icon indicating copy to clipboard operation
ebpf_exporter copied to clipboard

Support to add const labels for metrics

Open wenlxie opened this issue 3 years ago • 3 comments

This is to support user cam add some const labels for each metrics. eg: user can add the node fqdn info when running in k8s world.

wenlxie avatar Nov 04 '21 09:11 wenlxie

This sort of thing is usually accomplished from the scraping side:

  • https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs

Do you have an example of any other exporter in prometheus org that allows const labels instead?

bobrik avatar Nov 04 '21 16:11 bobrik

@bobrik Thanks for the information.

Maybe this can be the example: https://github.com/prometheus/influxdb_exporter/blob/master/main.go#L275 which consider about to add const labels to the metrics.

For the cases that I mentioned, metric_relabel_configs can be the solution. Actually this is also the way we are using now.

But with the const labels which can be specified by the args, this can bring more flexiable for users.

wenlxie avatar Nov 05 '21 07:11 wenlxie

Because I needed exactly this on my exporter and was about to upvote:

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: ebpf-prometheus
spec:
  selector:
    matchLabels:
      app: ebpf-exporter
  namespaceSelector:
    matchNames:
    - ebpf-exporter
  podMetricsEndpoints:
  - port: prometheus
    interval: 10s
    relabelings:
    - action: replace
      sourceLabels:
      - __meta_kubernetes_pod_node_name
      targetLabel: instance    

timbuchwaldt avatar Dec 14 '21 12:12 timbuchwaldt