[英]Can't able to import json data from file by Logstash
I'm trying to import JSON data from my log file mylogs.log
. 我正在尝试从日志文件
mylogs.log
导入JSON数据。 Following is my logstash config file. 以下是我的logstash配置文件。
input {
stdin { }
file {
codec => "json"
path => "/logs/mylogs.log"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter{
json{
source => "message"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "jsonlog"
}
stdout { codec => rubydebug }
file {
path => "/logs/out.log"
}
}
After executing this config file, if I passed any JSON data it's getting parse & sending to Elasticsearch instance. 执行完此配置文件后,如果我传递了任何JSON数据,它将被解析并发送到Elasticsearch实例。 I can see from Elasticsearch instance.
我可以从Elasticsearch实例中看到。 But, whatever data exist in log file those not get imported by logstash.
但是,无论日志文件中存在哪些数据,logstash都不会导入这些数据。
Also, when I manually adding JSON data which getting parse by Logstash & send Elasticsearch instance... those data also not gettign logged in my OUTPUT file. 另外,当我手动添加通过Logstash解析并发送Elasticsearch实例的JSON数据时,这些数据也不会被gettign记录在我的OUTPUT文件中。
Don't know what is the issue. 不知道是什么问题。
My sample JSON data which I'm using. 我正在使用的样本JSON数据。
{ "logger":"com.myApp.ClassName", "timestamp":"1456976539634", "level":"ERROR", "thread":"pool-3-thread-19", "message":"Danger. There was an error", "throwable":"java.Exception" }
{ "logger":"com.myApp.ClassName", "timestamp":"1456976539649", "level":"ERROR", "thread":"pool-3-thread-16", "message":"I cannot go on", "throwable":"java.Exception" }
OK, after making following modification file path plugin in Lagstash config file it's working now. 好的,在Lagstash配置文件中制作了以下修改文件路径插件后,它现在可以工作了。
input {
stdin { }
file {
codec => "json"
path => "/home/suresh/Desktop/tools/logstash-5.1.1/logs/mylogs.log"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter{
json{
source => "message"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "jsonlog2"
}
stdout { codec => rubydebug }
file {
path => "/home/suresh/Desktop/tools/logstash-5.1.1/logs/out.log"
}
}
But, I'm getting an error of "tags" => [ [0] "_jsonparsefailure" ]
但是,我收到了
"tags" => [ [0] "_jsonparsefailure" ]
Response from Console- 控制台回应-
{
"path" => "/home/suresh/Desktop/tools/logstash-5.1.1/logs/mylogs.log",
"@timestamp" => 2016-12-27T09:56:08.854Z,
"level" => "ERROR",
"logger" => "com.myApp.ClassName",
"throwable" => "java.Exception",
"@version" => "1",
"host" => "BLR-SOFT-245",
"thread" => "pool-3-thread-19",
"message" => "Danger. There was an error",
"timestamp" => "1456976539634",
"tags" => [
[0] "_jsonparsefailure"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.