admin管理员组文章数量:1429940
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.
本文标签: How to add AWS labels to Loki logs with AlloyStack Overflow
版权声明:本文标题:How to add AWS labels to Loki logs with Alloy? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745554877a2663125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论