apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: buildkit-haproxy
  namespace: monitoring
  labels:
    app.kubernetes.io/part-of: osdc-monitoring
spec:
  namespaceSelector:
    matchNames:
      - buildkit
  selector:
    matchLabels:
      app.kubernetes.io/name: buildkitd-lb
      app.kubernetes.io/component: load-balancer
  endpoints:
    - port: metrics
      interval: 60s
      metricRelabelings:
        # Keep only operationally important HAProxy metrics
        - action: keep
          sourceLabels: [__name__]
          regex: "haproxy_server_status|haproxy_server_current_sessions|haproxy_server_connection_errors_total|haproxy_backend_current_sessions"
