2017-02-28 99 views
0

我正在將一個url中的數據發送到logstash 5.2,我想在logstash中解析它,所以每個url參數都成爲logstash中的一個變量,我可以在kibana中正確顯示它。在logstash中解析url參數

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 
    } 
} 

回答

1

測試幾樣行,您可以使用神交過濾器來匹配您的網址您的PARAMS這樣:

filter { 
    grok { 
    match => [ "message", "%{URIPARAM:url}" ] 
    } 

然後您會必須使用kv過濾器才能拆分您的數據:

kv { 
    source => "url" 
    field_split => "&" 
    } 

這個SO可能會派上用場。希望這可以幫助!