2017-01-04 107 views
0

我們正在Google雲Dataproc羣集上運行Spark任務(大量Spark流)。google-fluentd:更改雲日誌記錄中的嚴重性log_level

我們正在使用雲日誌記錄來收集spark工作生成的所有日誌。 目前它正在生成大量的「INFO」消息,導致整個日誌卷大小爲幾TB。

我想編輯google-fluentd配置,將日誌級別限制爲「錯誤」級別而不是「INFO」。

試圖將配置設置爲"log_level error",但沒有奏效。 也是其在/etc/google-fluentd/google-fluentd.conf在評論部分提到# Currently severity is a seperate field from the Cloud Logging log_level.

# Fluentd config to tail the hadoop, hive, and spark message log. 
# Currently severity is a seperate field from the Cloud Logging log_level. 
<source> 
    type tail 
    format multi_format 
    <pattern> 
     format /^((?<time>[^ ]* [^ ]*) *(?<severity>[^ ]*) *(?<class>[^ ]*): (?<message>.*))/ 
/etc/google-fluentd/google-fluentd.conf/etc/google-fluentd/google-fluentd.conf/etc/google-fluentd/google-fluentd.conf  time_format %Y-%m-%d %H:%M:%S,%L 
    </pattern> 
    <pattern> 
     format none 
    </pattern> 
    path /var/log/hadoop*/*.log,/var/log/hadoop-yarn/userlogs/**/stderr,/var/log/hive/*.log,/var/log/spark/*.log, 
    pos_file /var/tmp/fluentd.dataproc.hadoop.pos 
    refresh_interval 2s 
    read_from_head true 
    tag raw.tail.* 
</source> 

回答

2

正確的。正如評論所述,@log_level和嚴重程度並不相同,這充其量是令人困惑的。 @log_level配置組件的記錄器的詳細程度,而severity是Stackdriver記錄攝取的字段。

爲了使fluentd在ERROR下排除任何severity,您可以添加一個grep過濾器到/etc/google-fluentd/google-fluentd.conf,明確地將這些過濾器按名稱排除。

在某一點上<match **>塊之前添加以下內容:

<filter raw.tail.**> 
    @type grep 
    exclude1 severity (DEBUG|INFO|NOTICE|WARNING) 
</filter> 

這將檢查記錄爲severity場,如果該值的正則表達式匹配的拒絕。

相關問題