alloy:
  create: false
  name: alloy-config
  key: config.alloy

  uiPathPrefix: "/alloy"

  configMap:
    content: |-

      logging {
        level  = "info"
        format = "logfmt"
      }

      loki.write "local_loki" {
          endpoint {
              url = "http://loki-loki-distributed-gateway/loki/api/v1/push"
          }
      }

      discovery.kubernetes "pod" {
        role = "pod"
      }

      discovery.kubernetes "nodes" {
        role = "node"
      }

      discovery.kubernetes "services" {
        role = "service"
      }

      discovery.kubernetes "endpoints" {
        role = "endpoints"
      }

      discovery.kubernetes "endpointslices" {
        role = "endpointslice"
      }

      discovery.kubernetes "ingresses" {
        role = "ingress"
      }

      discovery.relabel "pod_logs" {
        targets = discovery.kubernetes.pod.targets

        rule {
          source_labels = ["__meta_kubernetes_namespace"]
          action        = "replace"
          target_label  = "namespace"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_name"]
          action        = "replace"
          target_label  = "pod"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_node_name"]
          action        = "replace"
          target_label  = "node"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_container_name"]
          action        = "replace"
          target_label  = "container"
        }

      }

      loki.source.kubernetes "all_pod_logs" {
        targets    = discovery.relabel.pod_logs.output
        forward_to = [loki.write.local_loki.receiver]
      }
