---
# NetBoxEnterprise with metrics enabled for all components
# The operator will automatically scrape these metrics and re-expose them
# at its own /metrics endpoint with additional labels
apiVersion: netboxlabs.com/v1alpha1
kind: NetBoxEnterprise
metadata:
  name: netbox-managed-metrics
  namespace: default
spec:
  imagePullPolicy: IfNotPresent
  netbox:
    replicas: 1
    resources:
      cpu: 500
      memory: 256
    limits:
      cpu: 1000
      memory: 512
    config:
      # Enable Prometheus metrics at /metrics endpoint
      # Exposes django-prometheus metrics including:
      # - Model operations (inserts, updates, deletes)
      # - HTTP request metrics (latency, body size, response codes)
      # - REST API and GraphQL request counters
      # - Database query metrics (connections, executions, errors)
      # - Cache metrics (hits, misses, invalidations)
      metricsEnabled: true
    worker:
      replicas: 1
      resources:
        cpu: 500
        memory: 256
      limits:
        cpu: 1000
        memory: 512

  diode:
    # Enable metrics for all Diode components
    # The operator scrapes these and aggregates them at its /metrics endpoint
    config:
      ingester:
        telemetryConfig:
          environment: production
          metricsExporter: prometheus
          traceExporter: none
          # Enable Prometheus metrics endpoint at /metrics
          # Exposes metrics including:
          # - diode_ingester_service_info - Service metadata
          # - diode_ingester_service_startup_attempts_total - Startup success/failure
          # - diode_ingester_ingest_requests_total - Total ingest requests
          # - diode_ingester_ingest_entities_total - Total entities ingested by type
          metricsEnabled: true
          metricsPort: 9090
      reconciler:
        telemetryConfig:
          environment: production
          metricsExporter: prometheus
          traceExporter: none
          # Enable Prometheus metrics endpoint at /metrics
          # Exposes metrics including:
          # - diode_reconciler_service_info - Service metadata
          # - diode_reconciler_service_startup_attempts_total - Startup success/failure
          # - diode_reconciler_handle_message_total - Messages processed from Redis
          # - diode_reconciler_ingestion_log_create_total - Ingestion logs created
          # - diode_reconciler_change_set_create_total - Change sets created
          # - diode_reconciler_change_set_apply_total - Change sets applied
          # - diode_reconciler_change_create_total - Individual changes created by type
          # - diode_reconciler_change_apply_total - Individual changes applied
          metricsEnabled: true
          metricsPort: 9091
      auth:
        telemetryConfig:
          environment: production
          metricsExporter: prometheus
          traceExporter: none
          # Enable Prometheus metrics endpoint at /metrics
          # Exposes metrics including:
          # - diode_auth_service_info - Service metadata
          # - diode_auth_service_startup_attempts_total - Startup success/failure
          metricsEnabled: true
          metricsPort: 9092
    reconciler:
      replicas: 1
    ingester:
      replicas: 1
    auth:
      replicas: 1
    hydra:
      replicas: 1
  postgresql:
    external: false
  redis:
    external: false

---
# OPTION 1: Using Prometheus Operator with ServiceMonitor
# ========================================================
# When deploying the netbox-enterprise Helm chart, set:
#   metrics:
#     enabled: true
#   serviceMonitor:
#     enabled: true
#
# This will automatically create a ServiceMonitor that Prometheus Operator
# will discover and use to scrape the operator's /metrics endpoint.
#
# The operator aggregates metrics from all NetBox and Diode deployments
# and re-exposes them with additional labels (deployment, namespace, component).

---
# OPTION 2: Using standard Prometheus without operator
# =====================================================
# When deploying the netbox-enterprise Helm chart, set:
#   metrics:
#     enabled: true
#     podAnnotations: true
#
# This adds these annotations to the operator pod:
#   prometheus.io/scrape: "true"
#   prometheus.io/port: "8080"
#   prometheus.io/path: "/metrics"
#
# Standard Prometheus configured with kubernetes_sd_configs will automatically
# discover and scrape pods with these annotations.
#
# Example Prometheus configuration:
# scrape_configs:
#   - job_name: 'kubernetes-pods'
#     kubernetes_sd_configs:
#       - role: pod
#     relabel_configs:
#       - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
#         action: keep
#         regex: true
#       - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
#         action: replace
#         target_label: __metrics_path__
#         regex: (.+)
#       - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
#         action: replace
#         regex: ([^:]+)(?::\d+)?;(\d+)
#         replacement: $1:$2
#         target_label: __address__
