Grafana Loki 的 Fluentd 动态标签

Fluentd Dynamic Labeling for Grafana Loki

我用 grafana loki 设置了 fluentd,因为我有多个微服务将日志传播到 fluentd,所以我无法在 Grafana 中区分和过滤日志。任何人都可以帮助我将我的标签添加为标签,以便我可以像在 grafana {tag:"tag.name"} 中一样查询它。下面添加了我的 fluentd 配置。

<match TEST.**>
  @type loki  
  url "http://localhost:3100" 
 flush_interval 1s 
 flush_at_shutdown true 
 buffer_chunk_limit 1m  
extra_labels {"job":"TEST", "host":"ward_workstation", "agent":"fluentd"}  
<label>    
  filename  
</label>
</match>

使用动态标签

<filter TEST.**>
    @Type record_transformer
      <record>
        tag_name ${tag}
</record>
</filter>



<match TEST.**>
  @type loki  
  url "http://localhost:3100" 
 flush_interval 1s 
 flush_at_shutdown true 
 buffer_chunk_limit 1m  
extra_labels {"job":"TEST", "host":"ward_workstation", "agent":"fluentd"}  
<label>    
  tag_name
</label>
</match>