nais/unleasherator

Enable Prometheus scraping for Unleash instances

Starefossen opened this issue · 0 comments

Allow Prometheus to scrape metrics from Unleash instances.

  • Add new PrometheusConfig for Unleash
type PrometheusConfig struct {
  // +kubebuilder:default=true
  Enabled bool `json:"enabled,omitempty"`

  // +kubebuilder:default=/internal-backstage/prometheus
  Endpoint string `json:"endpoint"`

  // Maybe more?
  • Add new ServiceMonitor resource as part of Unleash reconciler:
# example ServiceMonitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: example-app
  labels:
    team: frontend
spec:
  selector:
    matchLabels:
      app: example-app
  endpoints:
  - port: web

https://prometheus-operator.dev/docs/operator/design/#servicemonitor

The ServiceMonitor custom resource definition (CRD) allows to declaratively define how a dynamic set of services should be monitored. Which services are selected to be monitored with the desired configuration is defined using label selections. This allows an organization to introduce conventions around how metrics are exposed, and then following these conventions new services are automatically discovered, without the need to reconfigure the system.