首页   注册   登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Logstash

logstash 如何将时间戳 UNIX_MS 转化为北京时间?

  •  
  •   wildcat007 · 2016-12-23 11:55:00 +08:00 · 2870 次点击
    这是一个创建于 1025 天前的主题,其中的信息可能已经有所发展或是发生改变。
    日志内容如下
    {"id":"549","msg-type":"activity","date":"1482372059180","thread-id":"628913","query-id":"16363060","user":"uuuser","priv_user":"uuuser","ip":"10.7.32.64","cmd":"show_create_table","query":"SHOW CREATE TABLE `uc_logindata`"}

    搭建 elk ,但是想把 date 改成北京时间,不知道 filter 如何去写?

    目前的 filter 格式如下
    input {
    file {
    type => "mysql-audit"
    path => ["/opt/audit_logs/mysql-audit/*"]
    }
    }

    filter{
    json {
    source => "message"
    target => "json"
    }
    }


    output {
    stdout {
    codec => rubydebug
    }
    elasticsearch {
    hosts => ["172.19.11.32:9200"]
    }
    }


    输出后的结果如下
    {
    "path" => "/opt/audit_logs/mysql-audit/test.json",
    "@timestamp" => 2016-12-23T03:05:49.752Z,
    "@version" => "1",
    "host" => "0.0.0.0",
    "json" => {
    "date" => "1482372059180",
    "query-id" => "16363060",
    "msg-type" => "activity",
    "ip" => "10.7.32.64",
    "query" => "SHOW CREATE TABLE `uc_logindata`",
    "priv_user" => "uuuser",
    "id" => "7",
    "cmd" => "show_create_table",
    "user" => "uuuser",
    "thread-id" => "628913"
    },
    "message" => "{\"id\":\"7\",\"msg-type\":\"activity\",\"date\":\"1482372059180\",\"thread-id\":\"628913\",\"query-id\":\"16363060\",\"user\":\"uuuser\",\"priv_user\":\"uuuser\",\"ip\":\"10.7.32.64\",\"cmd\":\"show_create_table\",\"query\":\"SHOW CREATE TABLE `uc_logindata`\"}",
    "type" => "mysql-audit",
    "tags" => []
    }
    1 回复  |  直到 2016-12-23 12:15:01 +08:00
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   3543 人在线   最高记录 5043   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.3 · 24ms · UTC 05:27 · PVG 13:27 · LAX 22:27 · JFK 01:27
    ♥ Do have faith in what you're doing.