2017-10-23 2 views
0

Ich bin neu in Fluentd. Ich benutze Stackdriver in GKE und ich passe die Fluentd-Konfiguration in GKE an, um einige Änderungen an den Logs vorzunehmen.Logging mit Fluentd - Warum erscheint die Ausgabe der JSON-Log-Datei als textpayload (nicht als jsonpayload)?

In meiner Konfigurationsdatei für die Protokolle meiner Container Ich habe:

<source> 
    type tail 
    format json 
    time_key time 
    path /var/log/containers/*.log 
    pos_file /var/log/gcp-containers.log.pos 
    time_format %Y-%m-%dT%H:%M:%S.%N%Z 
    tag reform.* 
    read_from_head true 
</source> 

Die Protokolle von einigen Containern sind json objests, aber ich sehe ihre Ausgabe als textpayload (wenn ich die eingebaute in Fluentd ermöglichen auf GKE erscheinen sie als jsonpayload).

Ich verstehe nicht, was das verursachen könnte. Ich würde mich über jeden Hinweis freuen.

Antwort

0

Ihr Fluentd-Extraktor kann den Protokolleintrag nicht analysieren. Sie müssen also die Protokollzeile in Felder aufteilen und sie werden in Stackdriver Logging als jsonpayload angezeigt. Zum Beispiel funktioniert dies Nginx Access Log Parser

<source> 
    @type tail 
    format /^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$/ 
time_format %d/%b/%Y:%H:%M:%S %z 
    path /var/log/nginx/*.access.log 
    path_key log_path 
    pos_file /var/lib/google-fluentd/pos/nginx-access.pos 
    read_from_head true 
    tag nginx-access 
</source>