duanming7961 2017-02-20 03:53
浏览 75
已采纳

Logstash csvparsefailure和dateparsefailure

I am using this filter to parse some csv data that I am generating from a php file. I am taking the output from a gpu monitoring tool called msi afterburner which outputs a .hml file. There are a tonne of white spaces and an irrelevant header which my php file removes and outputs comma separated value.

 filter 
    {
        csv 
        {
            columns => ["somename","@timestamp","cpu.avg.temp","gpu.temp","fan.speed","gpu.usage","bus.usage","fan.tachometer","clock.core","framerate.hz","framerate.ms","cpu.temp.1","cpu.temp.2","cpu.temp.3","cpu.temp.4"]
            separator => ","
            skip_empty_columns => "true"
        }
        mutate 
        {
            convert => ["somename","integer"]
            convert => ["cpu.avg.temp","float"]
            convert => ["gpu.temp","float"]
            convert => ["fan.speed","float"]
            convert => ["gpu.usage","float"]
            convert => ["bus.usage","float"]
            convert => ["fan.tachometer","float"]
            convert => ["clock.core", "float"]
            convert => ["framerate.hz","float"]
            convert => ["framerate.ms","float"]
            convert => ["cpu.temp.1","float"]
            convert => ["cpu.temp.2","float"]
            convert => ["cpu.temp.3","float"]
            convert => ["cpu.temp.4","float"]
        }
        date 
        {
            match => ["@timestamp", "dd-MM-yyyyHH:mm:ss"]
        }
    }

This is the output logstash is throwing at me. I am wondering if this is due to the fact that my date format is bad or if at the end of my message there appears to be a special character ''. I am wondering if logstash is even able to read dd-MM-yyyyHH:mm:ss format where year and hour are stuck together, if not I might be in a bit of trouble.

{
          "path" => "C:\\Users\\Public\\Documents\\gpumetrics.csv",
      "somename" => 80,
    "@timestamp" => 2017-02-20T02:33:10.764Z,
      "@version" => "1",
          "host" => "DESKTOP-Q8UEATO",
       "message" => "80,19-02-201721:33:10,32.000,41.000,0.000,0.000,0.000,0.000,215.000,0.000,0.000,31.000,32.000,30.000,31.000",
          "type" => "csv",
          "tags" => [
        [0] "_csvparsefailure",
        [1] "_dateparsefailure"
    ]
} 

Here are a few sample lines from my log file. As you may notice, there is a field before timestamp. I am wondering if this is allowed.

80,19-02-201713:20:32,44.000,43.000,0.000,0.000,0.000,0.000,215.000,,,37.000,42.000,41.000,38.000
80,19-02-201713:20:33,47.000,43.000,0.000,0.000,0.000,0.000,215.000,,,46.000,47.000,45.000,44.000
80,19-02-201713:20:34,53.000,43.000,0.000,0.000,0.000,0.000,215.000,,,35.000,50.000,36.000,37.000
80,19-02-201713:20:35,37.000,43.000,0.000,0.000,0.000,0.000,215.000,,,37.000,37.000,37.000,34.000
80,19-02-201713:20:36,34.000,44.000,0.000,0.000,0.000,0.000,1582.000,0.000,0.000,39.000,34.000,33.000,36.000
80,19-02-201713:20:37,46.000,44.000,0.000,0.000,0.000,0.000,1582.000,0.000,0.000,45.000,37.000,43.000,37.000
  • 写回答

1条回答 默认 最新

  • dscrn1974 2017-02-20 05:18
    关注

    Your problem can be solved very simply by changing the name of your timestamp variable since @timestamp is created internally before your line is parsed.

    filter 
        {
            csv 
            {
                                   remove the @
                                        |
                                        v
                columns => ["somename","timestamp","cpu.avg.temp","gpu.temp","fan.speed","gpu.usage","bus.usage","fan.tachometer","clock.core","framerate.hz","framerate.ms","cpu.temp.1","cpu.temp.2","cpu.temp.3","cpu.temp.4"]
                separator => ","
                skip_empty_columns => "true"
            }
            ...
            date 
            {
                match => ["timestamp", "dd-MM-yyyyHH:mm:ss"]
                           ^
                           |
                      remove the @
            }
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!