¿Cómo expandir JSON en Fluentd?
Sep 29 2020
¿Hay alguna manera de filtrar la cadena JSON anidada en campos separados en fluentd?
JSON actual:
{
Value1: "something",
Value2: "something",
Message:{
Value3: "Something",
Value3: "Something"
}
}
Lo que quiero (o algo similar):
{
Value1: "something",
Value2: "something",
Message.Value3: "Something",
Message.Value3: "Something"
}
El JSON no tiene que aplanarse como en el ejemplo anterior, pero quiero que los valores estén en sus propios campos separados (columnas) cuando lleguen a elasticsearch. En otras salas, quiero dividir la cadena de mensaje larga única en varios campos que contiene.
Respuestas
1 MaxLobur Sep 29 2020 at 02:54
Prueba esto:
<source>
...
</source>
<filter myapp**>
@type parser
key_name Message
format multi_format
<pattern>
format json # try parsing json in the first place
</pattern>
<pattern>
format none # leave as is if this is not json (plaintext)
</pattern>
reserve_data true # keep the original Message field in case anything go wrong
</filter>
<match myapp**>
...
</match>
Analizador multiformato: https://github.com/repeatedly/fluent-plugin-multi-format-parser