Re: geoip conflict
Posted: Thu Feb 21, 2019 3:36 pm
ok ill give it a shot
Support for Nagios products and services
https://support.nagios.com/forum/
Code: Select all
geoip {
database => "/usr/share/GeoIP/GeoLiteCity.dat"
source => "IPAddress"
}Code: Select all
match => { "message" => "result=\"%{WORD:result}\" ip=\"%{IP:IP}\" action=\"%{WORD:action}\" params=\"Username: %{USER:params}\" user=\"%{USER:user}\" tenant=\"%{WORD:tenant}\""}
match => { "message" => "result=\"%{WORD:result}\" ip=\"%{IP:IP}\" action=\"%{WORD:action}\" params=\"Username=%{USER:params}\" user=\"%{USER:user}\" tenant=\"%{WORD:tenant}\""}Code: Select all
"Username: %{USER:params}Code: Select all
"Username=%{USER:params}'You were putting your match in { instead of [
Code: Select all
result=\"%{WORD:result}If you're trying to change one incoming field to another, I would just create another filter. So if the log is coming in with 'IP' as the field, we can do:benhank wrote:how do I change the field IP to Ipaddress.
Code: Select all
mutate {
replace => { "Ipaddress" => "%{IP}" }
}
In this case, the difference is just matching the literal text of the log line. If you have a log format where you use a colon, likeso here goes:
first, looking closely at this filter I see that it is listed with with one difference:line 1Code: Select all
match => { "message" => "result=\"%{WORD:result}\" ip=\"%{IP:IP}\" action=\"%{WORD:action}\" params=\"Username: %{USER:params}\" user=\"%{USER:user}\" tenant=\"%{WORD:tenant}\""} match => { "message" => "result=\"%{WORD:result}\" ip=\"%{IP:IP}\" action=\"%{WORD:action}\" params=\"Username=%{USER:params}\" user=\"%{USER:user}\" tenant=\"%{WORD:tenant}\""}Line 2Code: Select all
"Username: %{USER:params}Code: Select all
"Username=%{USER:params}
Code: Select all
result: "okay" IP: "127.0.0.1" action: "something"The difference here is that {} is referring to a logstash hash (which other languages call a 'map', 'dictionary', 'object', or 'associative array'), where [] is referring to an array (which other languages call a 'list' or 'vector'). Hashes have a list of keys pointing to values, and arrays are lists of just values.Second, I know that Scott must be correct when he said :'You were putting your match in { instead of [
my question is whats the difference between the two symbols? and why would it bomb out when I use the suggested correction Scott gave me, but work when I used { instead of the ]?
I would read that asAnd third using the following as an example:what does each term in that line do?Code: Select all
result=\"%{WORD:result}
Code: Select all
match the literal characters result="
match according to the 'WORD' pattern, store it in the field 'result'
Code: Select all
exec {
command => "bash /path/to/do/something.sh %{IP}"
}
Code: Select all
grok {
match => { "message" => "patternpatternpattern..."}
}Code: Select all
grok {
match => ["patternpatternpattern1...","patternpatternpattern2..."]
}Code: Select all
result=\"%{WORD:result}Code: Select all
if [host] == '172.30.100.226' {
grok {
match => { "message" => "result=\"%{WORD:result}\" ip=\"%{IP:IP}\" action=\"%{WORD:action}\" params=\"Username: %{USER:params}\" user=\"%{USER:user}\" tenant=\"%{WORD:tenant}\""}
match => { "message" => "result=\"%{WORD:result}\" ip=\"%{IP:IP}\" action=\"%{WORD:action}\" params=\"Username=%{USER:params}\" user=\"%{USER:user}\" tenant=\"%{WORD:tenant}\""}
}
geoip {
database => "/usr/share/GeoIP/GeoLiteCity.dat"
source => "IP"
}
}