我如何解析logstash中的多行json文件到哈希?

时间:2015-02-26 22:06:23

标签: elasticsearch logstash kibana

我有一个有效的多行JSON文件。我想解析它,并将其作为字段名称和值分配为字段值。

是否可以自动执行?

input {
  file {
    path => "/home/logstash/xunit.json"
    codec => json
  }
} 

output {
  stdout {}
  elasticsearch {
    protocol => "http"
    codec => "json"
    host => "kibana.dev"
    port => "9200"
  }
}

使用此配置后,我看到添加了某些内容..但我无法看到我的json中出现的字段。是否可以获取名称,严重程度,状态,开始和停止约会?

我的json示例:

[ 
  {
    "uid" : "441d1d1dd296fe60",
    "name" : "test_buylinks",
    "title" : "Test buylinks",
    "time" : {
      "start" : 1419621623182,
      "stop" : 1419621640491,
      "duration" : 17309
    },
    "severity" : "NORMAL",
    "status" : "FAILED"
  }, 
  {
    "uid" : "a88c89b377aca0c9",
    "name" : "test_buylinks",
    "title" : "Test buylinks",
    "time" : {
      "start" : 1419621623182,
      "stop" : 1419621640634,
      "duration" : 17452
    },
    "severity" : "NORMAL",
    "status" : "FAILED"
  }, 
  {
    "uid" : "32c3f8b52386c85c",
    "name" : "test_buylinks",
    "title" : "Test buylinks",
    "time" : {
      "start" : 1419621623185,
      "stop" : 1419621640826,
      "duration" : 17641
    },
    "severity" : "NORMAL",
    "status" : "FAILED"
  } 
]

0 个答案:

没有答案