从rsyslog向Kibana发送JSON

从rsyslog向Kibana发送JSON,json,logstash,kibana,syslog,rsyslog,Json,Logstash,Kibana,Syslog,Rsyslog,我使用rsyslog监视我的系统日志,并将它们发送到Logstash+Kibana 我的系统日志消息记录为JSON。它们可以看起来像这样: {"foo":"bar", "timegenerated": 43843274834} rsyslog配置如下: module(load="omelasticsearch") #define a template to print all fields of the message template(name="messageToES" type="li

我使用rsyslog监视我的系统日志,并将它们发送到Logstash+Kibana

我的系统日志消息记录为JSON。它们可以看起来像这样:

{"foo":"bar", "timegenerated": 43843274834}
rsyslog配置如下:

module(load="omelasticsearch")

#define a template to print all fields of the message
template(name="messageToES" type="list" option.json="on") {
  property(name="msg")
}
*.* action(type="omelasticsearch"
       server="localserverhere"
       serverport="80"
       template="messageToES")
Kibana很好,因为如果我对它运行CURL命令,它就会收到记录。代码如下:

curl -XPOST myserver/test/bar -d '{"test": "baz", "timegenerated":1447145221519}'
当我运行rsyslogs并将其指向虚拟服务器时,我可以看到带有有效json的传入请求。然而,当我将它指向我的logstash服务器时,它不会显示在logstash或kibana中


有人知道如何将系统日志作为json发送到Kibana/logstash吗?

我从未使用过它,但看起来您的配置文件中缺少了一些东西。这些文件有一个非常详尽的例子:

module(load="omelasticsearch")
template(name="testTemplate"
     type="list"
     option.json="on") {
       constant(value="{")
         constant(value="\"timestamp\":\"")      property(name="timereported" dateFormat="rfc3339")
         constant(value="\",\"message\":\"")     property(name="msg")
         constant(value="\",\"host\":\"")        property(name="hostname")
         constant(value="\",\"severity\":\"")    property(name="syslogseverity-text")
         constant(value="\",\"facility\":\"")    property(name="syslogfacility-text")
         constant(value="\",\"syslogtag\":\"")   property(name="syslogtag")
       constant(value="\"}")
     }
action(type="omelasticsearch"
   server="myserver.local"
   serverport="9200"
   template="testTemplate"
   searchIndex="test-index"
   searchType="test-type"
   bulkmode="on"
   queue.type="linkedlist"
   queue.size="5000"
   queue.dequeuebatchsize="300"
   action.resumeretrycount="-1")

根据您尝试执行的操作,您似乎需要插入
localserverhere
,其中显示
myserver.local
。看起来你在端口80上也有ES接收东西,所以你应该输入
80
而不是
9200

你不“发送”任何东西给kibana,而是发送给elasticsearch,让kibana为你查询。检查你的日志和elasticsearch日志。将stdout{}输出节添加到logstash,查看它的想法。在logstash(命令行标志)中打开调试。