我在url中发送数据到logstash 5.2,我想在logstash中解析它,所以每个url参数都成为logstash中的变量,我可以在kibana中正确地显示它。
http://127.0.0.1:31311/?id=ID-XXXXXXXX&uid=1-37zbcuvs-izotbvbe&ev=pageload&ed=&v=1&dl=http://127.0.0.1/openpixel/&rl=&ts=1488314512294&de=windows-1252&sr=1600x900&vp=1600x303&cd=24&dt=&bn=Chrome%2056&md=false&ua=Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_11_3)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/56.0.2924.87%20Safari/537.36&utm_source=&utm_medium=&utm_term=&utm_content=&utm_campaign=
这是我的logstash conf文件:
input
{
http
{
host => "127.0.0.1"
port => 31311
}
}
output
{
elasticsearch
{
hosts => ["localhost:9200"]
}
stdout
{
codec => rubydebug
}
}
答案 0 :(得分:4)
您可以使用grok过滤条件来匹配您网址中的参数:
filter {
grok {
match => [ "message", "%{URIPARAM:url}" ]
}
然后您可能必须使用kv过滤器才能拆分数据:
kv {
source => "url"
field_split => "&"
}
这StackOverflow post可能会变得很方便。希望这有帮助!