我是ELK的新手,我已经安装了正在运行的ELK 5.0。我已经想出了日常活动的顺利进行,需要进行大量的微调,而且我可以搞清楚。
我正在使用ELK和rsyslog,而不是像filebeat这样的代理。我在客户端和服务器上启用rsyslog,在服务器rsyslog上接收日志并转发到logstash。
以下是我在Kibana上可以看到的示例消息日志
{ “@时间戳”: “2017-02-01T05:41:03 + 04:00”, “@版本”: “1”, “消息”:” root:无法解析主机 朱朱机-4- LXC-3" , “sysloghost”: “朱朱机-4- LXC-3”, “严重性”: “警报”, “设施”: “authPriv时”, “PROGRAMNAME”: “须藤” “PROCID”: “ - ”}
{ “@时间戳”: “2017-02-01T05:40:23 + 04:00”, “@版本”: “1”, “消息”:” 警告:native_choose_node:2个具有相同分数(INFINITY)的节点 运行res_mysql_vip资源。选择 juju-machine-2-lxc-0。“,”sysloghost“:”juju-machine-2-lxc 0“, “严重性”: “警告”, “设施”: “守护程序”, “PROGRAMNAME”: “pengine”, “PROCID”: “18468”}
我想添加可以显示最小信息的字段,例如主机名和ip的logsource,严重性标签和级别。目前我只能看到严重性标签而不是主机我只能看到所有日志的rsyslog的ip;而它应该显示实际的日志源ip。
以下是我的logstash配置
[root@localhost~]# more /etc/logstash/conf.d/10-syslog.conf
# This input block will listen on port 10514 for logs to come in.
# host should be an IP on the Logstash server.
# type => "rsyslog" is an optional identifier to help identify messaging streams in the pipeline.
input {
syslog {
port => 10514
type => rsyslog
}
}
# This is an empty filter block. You can later add other filters here to further process
# your log lines
filter {
if "affinity_hint subset empty" in [message]{drop{}}
}
# Output Section, filtering out rsyslog type and send to elasticsearch
output {
if [type] == "rsyslog" {
elasticsearch {
hosts=> ["localhost:9200"]
}
以下是我的json模板
[root@localhost ~]# more /etc/rsyslog.d/01-json-template.conf
template(name="json-template"
type="list") {
constant(value="{")
constant(value="\"@timestamp\":\"") property(name="timereported" dateFormat="rfc3339")
constant(value="\",\"@version\":\"1")
constant(value="\",\"message\":\"") property(name="msg" format="json")
constant(value="\",\"sysloghost\":\"") property(name="hostname")
constant(value="\",\"severity\":\"") property(name="syslogseverity-text")
constant(value="\",\"facility\":\"") property(name="syslogfacility-text")
constant(value="\",\"programname\":\"") property(name="programname")
constant(value="\",\"procid\":\"") property(name="procid")
constant(value="\"}\n")
}
请帮帮我..