繁体   English   中英

从Logstash日志创建Kibana图

[英]Create a Kibana graph from logstash logs

我需要根据特定值在kibana中创建一个图形。

这是我的logstash的原始日志:

2016-03-14T15:01:21.061Z Accueil-PC 14-03-2016 16:01:19.926 [pool-3-thread-1] INFO com.github.vspiewak.loggenerator.SearchRequest - id=300,ip=84.102.53.31,brand=Apple,name=iPhone 5S,model=iPhone 5S - Gris sideral - Disque 64Go,category=Mobile,color=Gris sideral,options=Disque 64Go,price=899.0

在此日志行中,我具有id信息“ id = 300”。 为了使用id值在Kibana中创建图形,我想要一个新字段。 所以我有一个特定的grok配置:

grok {
 match => ["message", "(?<mycustomnewfield>id=%{INT}+)"]        
}

通过这种转换,我得到以下JSON:

{
"_index": "metrics-2016.03.14",
"_type": "logs",
"_id": "AVN1k-cJcXxORIbORG7w",
"_score": null,
"_source": {
  "message": "{\"message\":\"14-03-2016 15:42:18.739 [pool-1950-thread-1] INFO com.github.vspiewak.loggenerator.SellRequest - id=300,ip=54.226.24.77,email=client951@gmail.com,sex=F,brand=Apple,name=iPad R\\\\xE9tina,model=iPad R\\\\xE9tina - Noir,category=Tablette,color=Noir,price=509.0\\\\r\",\"@version\":\"1\",\"@timestamp\":\"2016-03-14T14:42:19.040Z\",\"path\":\"D:\\\\LogStash\\\\logstash-2.2.2\\\\logstash-2.2.2\\\\bin\\\\logs.logs.txt\",\"host\":\"Accueil-PC\",\"type\":\"metrics-type\",\"mycustomnewfield\":\"300\"}",
 "@version": "1",
 "@timestamp": "2016-03-14T14:42:19.803Z",
 "host": "127.0.0.1",
 "port": 57867
},
"fields": {
 "@timestamp": [
  1457966539803
 ]
},
"sort": [
 1457966539803
]}

实际上创建了一个新字段(字段“ mycustomnewfield”),但是在消息字段中! 结果,当我尝试创建图形时,在kibana中看不到它。 我试图在Kibana中创建“脚本字段”,但只能访问数字字段。

是否应在elasticSearch中使用特定映射创建索引以创建新字段?

我的配置实际上出了点问题。 我应该在问题中粘贴整个配置。 实际上,我将Logstash用作托运人,也用作日志服务器。 在服务器端,我修改了配置:

input {
tcp {
    port => "yyyy"
    host => "x.x.x.x"
    mode => "server"
    codec => json # I forgot this option
}}

因为Logstash发货人实际上正在发送json,所以我需要就此向服务器提出建议。 现在,我在消息字段中不再有消息字段,并且我的新字段已插入正确的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM