zoukankan      html  css  js  c++  java
  • Logstash修改UTC时间为东八区时间(北京时间)

    logstash时间戳@timestamp修改为北京时间

    input {
        beats {
            port => "5044"
        }
    }
    filter {
            grok {
                match => [ # 此处的^A为vim下的CTRL+A
                    "message", "time^B%{INT:timestamp}^Aid^B%{NOTSPACE:sn}^Aasr^B%{NOTSPACE:asr}^Anlp^B%{DATA:nlp}^Adomain^B%{JAVACLASS:domain}^Aintent^B%{NOTSPACE:intent}"
                ]
            }
            date {
                match => ["timestamp", "UNIX_MS"]
                target => "@timestamp"
            }
            ruby {
                code => "event.set('temp', event.get('@timestamp').time.localtime + 8*60*60); event.set('@timestamp', event.get('temp'))"
            }
    }
    output {
    #    stdout { codec => rubydebug }
        file {
            codec => line {format => "%{message}"}
            path => "/home/admin/data/speech/speech.log.%{+YYYYMMdd}"
        }
        file {
            codec => line {format => "%{+YYYY-MM-dd HH:mm:ss}^A%{sn}^A%{asr}^A%{nlp}^A%{domain}^A%{intent}"}
            path => "/home/admin/data/speech/speech%{+YYYY-MM-dd}"
        }
    }

    logstash@timestampUTC时间修改为北京时间

    filter {
        ruby {
            code => "event.set('timestamp', event.get('@timestamp').time.localtime + 8*60*60)"
        }
        ruby {
            code => "event.set('@timestamp',event.get('timestamp'))"
        }
        mutate {
            remove_field => ["timestamp"]
        }
    }
  • 相关阅读:
    hdu 1312 Red and Black
    hdu 1573 X问题
    广工校赛决赛之简单的数论题
    最大的LeftMax与rightMax之差绝对值
    POJ 2385 Apple Catching
    hdu 1171 Big Event in HDU
    ACM比赛经验
    BestCoder Valentine's Day Round
    使用ffmpeg进行视频封面截取
    使用ODP.NET连接Oracle数据库
  • 原文地址:https://www.cnblogs.com/fat-girl-spring/p/13610251.html
Copyright © 2011-2022 走看看