apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: buildkit
  namespace: monitoring
  labels:
    app.kubernetes.io/part-of: osdc-monitoring
spec:
  namespaceSelector:
    matchNames:
      - buildkit
  selector:
    matchLabels:
      app.kubernetes.io/name: buildkitd
      app.kubernetes.io/component: build-service
  endpoints:
    - port: metrics
      path: /debug/metrics_prometheus
      interval: 60s
      metricRelabelings:
        # Drop Go runtime metrics — high cardinality, no operational value
        - action: drop
          sourceLabels: [__name__]
          regex: "go_.*"
        # Drop process metrics — duplicated by node-exporter
        - action: drop
          sourceLabels: [__name__]
          regex: "process_.*"
        # Drop promhttp and target_info — internal handler metrics, no value
        - action: drop
          sourceLabels: [__name__]
          regex: "promhttp_.*|target_info"
        # Drop histogram buckets — keep _sum/_count for latency tracking
        - action: drop
          sourceLabels: [__name__]
          regex: ".*_bucket"
