How to add AWS labels to Loki logs with Alloy? - Stack Overflow

I have an alloy config that takes docker logs, adds a container label using the provided meta data from

I have an alloy config that takes docker logs, adds a container label using the provided meta data from discovery.docker, and dispatches them to Loki -- this works great.

However, I'm struggling to find out how to add other labels to my logs, such as the instanceId of my AWS EC2 instance, or other relevant info about the machine it's running on.

Here is my config:

discovery.docker "local" {
  host = "unix:///var/run/docker.sock"
}

// Add a "container" label
discovery.relabel "docker" {
  targets = []
  
  rule {
      source_labels = ["__meta_docker_container_name"]
      regex = "/(.*)"
      target_label = "container"
  }
}

// Read logs from docker containers
loki.source.docker "local" {
  host = "unix:///var/run/docker.sock"
  targets = discovery.docker.local.targets
  forward_to = [loki.write.grafana_cloud.receiver]
  relabel_rules = discovery.relabel.docker.rules
}

// Send to Loki
loki.write "grafana_cloud" {
  endpoint {
    url = "loki:3100/loki/api/v1/push"

    basic_auth {
      username = sys.env("LOKI_USER")
      password = sys.env("LOKI_TOKEN")
    }
  }
}

My question

How can I modify this to add additional labels to my logs about the EC2 server? I can see there's an discovery.ec2 component, but not sure how I can get that to link up with my logs.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745554878a4632759.html

相关推荐

  • How to add AWS labels to Loki logs with Alloy? - Stack Overflow

    I have an alloy config that takes docker logs, adds a container label using the provided meta data from

    20小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信