# ============================================================================
# kube-prometheus-stack Helm Values
# ============================================================================
# Install with:
# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# helm repo update
# helm install prometheus prometheus-community/kube-prometheus-stack \
#   --namespace monitoring \
#   --create-namespace \
#   -f prometheus-values.yaml
# ============================================================================

# Global settings
fullnameOverride: "prometheus"

# Prometheus configuration
prometheus:
  enabled: true

  prometheusSpec:
    # Resource limits
    resources:
      requests:
        cpu: 200m
        memory: 512Mi
      limits:
        cpu: 500m
        memory: 1Gi

    # Retention
    retention: 7d
    retentionSize: "5GB"

    # Storage (use OCI Block Volume)
    storageSpec:
      volumeClaimTemplate:
        spec:
          storageClassName: oci-bv
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 10Gi

    # Service monitor selector - monitor all namespaces
    serviceMonitorSelectorNilUsesHelmValues: false
    serviceMonitorSelector: {}
    serviceMonitorNamespaceSelector: {}

    # Pod monitor selector
    podMonitorSelectorNilUsesHelmValues: false
    podMonitorSelector: {}
    podMonitorNamespaceSelector: {}

    # Additional scrape configs for undateable services
    additionalScrapeConfigs:
      - job_name: 'undateable-services'
        kubernetes_sd_configs:
          - role: pod
            namespaces:
              names:
                - undateable
        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__
          - source_labels: [__meta_kubernetes_namespace]
            action: replace
            target_label: namespace
          - source_labels: [__meta_kubernetes_pod_name]
            action: replace
            target_label: pod
          - source_labels: [__meta_kubernetes_pod_label_app]
            action: replace
            target_label: app

# Grafana configuration
grafana:
  enabled: true

  # Admin credentials
  adminUser: admin
  # adminPassword will be auto-generated, get with:
  # kubectl get secret -n monitoring prometheus-grafana -o jsonpath="{.data.admin-password}" | base64 -d

  # Resource limits
  resources:
    requests:
      cpu: 100m
      memory: 256Mi
    limits:
      cpu: 300m
      memory: 512Mi

  # Persistence
  persistence:
    enabled: true
    storageClassName: oci-bv
    size: 5Gi

  # Ingress for Grafana
  ingress:
    enabled: true
    ingressClassName: nginx
    annotations:
      cert-manager.io/cluster-issuer: "letsencrypt-prod"
    hosts:
      - grafana.undateable.me
    tls:
      - secretName: grafana-tls
        hosts:
          - grafana.undateable.me

  # Additional data sources
  additionalDataSources: []

  # Default dashboards
  defaultDashboardsEnabled: true
  defaultDashboardsTimezone: utc

  # Sidecar for dashboard provisioning
  sidecar:
    dashboards:
      enabled: true
      label: grafana_dashboard
      labelValue: "1"
      searchNamespace: ALL
    datasources:
      enabled: true
      defaultDatasourceEnabled: true

# Alertmanager configuration
alertmanager:
  enabled: true

  alertmanagerSpec:
    resources:
      requests:
        cpu: 50m
        memory: 64Mi
      limits:
        cpu: 100m
        memory: 128Mi

    storage:
      volumeClaimTemplate:
        spec:
          storageClassName: oci-bv
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 2Gi

  # Alert configuration
  config:
    global:
      resolve_timeout: 5m

    route:
      group_by: ['alertname', 'namespace']
      group_wait: 30s
      group_interval: 5m
      repeat_interval: 12h
      receiver: 'null'
      routes:
        - match:
            alertname: Watchdog
          receiver: 'null'
        - match:
            severity: critical
          receiver: 'critical-alerts'
        - match:
            severity: warning
          receiver: 'warning-alerts'

    receivers:
      - name: 'null'
      - name: 'critical-alerts'
        # Configure Slack, PagerDuty, email, etc.
        # slack_configs:
        #   - api_url: 'https://hooks.slack.com/services/XXX'
        #     channel: '#alerts-critical'
      - name: 'warning-alerts'
        # slack_configs:
        #   - api_url: 'https://hooks.slack.com/services/XXX'
        #     channel: '#alerts-warning'

# Node Exporter
nodeExporter:
  enabled: true
  resources:
    requests:
      cpu: 50m
      memory: 32Mi
    limits:
      cpu: 100m
      memory: 64Mi

# Kube State Metrics
kubeStateMetrics:
  enabled: true
  resources:
    requests:
      cpu: 50m
      memory: 64Mi
    limits:
      cpu: 100m
      memory: 128Mi

# Prometheus Operator
prometheusOperator:
  enabled: true
  resources:
    requests:
      cpu: 100m
      memory: 128Mi
    limits:
      cpu: 200m
      memory: 256Mi

# Disable components we don't need
kubeEtcd:
  enabled: false  # OKE manages etcd
kubeControllerManager:
  enabled: false  # OKE manages this
kubeScheduler:
  enabled: false  # OKE manages this
kubeProxy:
  enabled: true
