sunfmin / notebook

My Note Book
2 stars 0 forks source link

Support for JSON log events logged to STDOUT in Kubernetes #59

Open sunfmin opened 4 years ago

sunfmin commented 4 years ago

Support for JSON log events logged to STDOUT

https://github.com/kubernetes/kubernetes/issues/15795

Screen Shot 2019-12-09 at 7 40 59 PM
    <filter reform.**>
       type parser
       format /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<log>.*)/
       format json
       reserve_data true
       suppress_parse_error_log true
       key_name log
       hash_value_field fields
     </filter>

     <match reform.**>
       tag raw.kubernetes.${tag_suffix[4].split('-')[0..-2].join('-').split('_')[1..2].join('.')}
       <record>
         severity ${record['fields']['level'] || if record['stream'] == 'stderr' then 'ERROR' else 'INFO' end}
       </record>
     </match>