Learn by Directing AI
All materials

alloy-config.yaml

yamlalloy-config.yaml
discovery.docker "containers" {
  host = "unix:///var/run/docker.sock"
}

loki.source.docker "default" {
  host       = "unix:///var/run/docker.sock"
  targets    = discovery.docker.containers.targets
  forward_to = [loki.process.filter.receiver]
}

loki.process "filter" {
  stage.docker {}

  stage.match {
    selector = "{container=~\".*tourism-portal.*\"}"
    stage.static_labels {
      values = {
        service = "tourism-portal",
      }
    }
  }

  stage.match {
    selector = "{container=~\".*guide-system.*\"}"
    stage.static_labels {
      values = {
        service = "guide-system",
      }
    }
  }

  stage.match {
    selector = "{container=~\".*operations-platform.*\"}"
    stage.static_labels {
      values = {
        service = "operations-platform",
      }
    }
  }

  forward_to = [loki.write.local.receiver]
}

loki.write "local" {
  endpoint {
    url = "http://loki:3100/loki/api/v1/push"
  }
}