Hello, all.
I want to geoip e.g. apache access log. My logstash-forwarder config looks like this:
{
"network": {
"servers": [ "192.168.0.213:5044" ],
"ssl key": "/etc/ssl/private/logstash-forwarder.key",
"ssl ca": "/etc/pki/tls/certs/logstash-forwarder.crt",
"timeout": 150
},
"files": [
{
"paths": [ "/var/log/messages" ],
"fields": { "type": "syslog" }
},
{
"paths": [ "/var/log/secure" ],
"fields": { "type": "syslog" }
},
{
"paths": [ "/var/log/httpd/access_log" ],
"fields": { "type": "apache-access" }
}
]
}
I created a logstash conf file (12-apache.conf) that looks like this:
input {
file {
type => "apache-access"
path => "/var/log/httpd/*"
start_position => "beginning"
}
}
filter {
grok {
# Here you find more on the default patterns logstash ships with:
# https://github.com/logstash-plugins/logstash-patterns-core/tree/master/patterns
match => { "message" => "%{COMBINEDAPACHELOG}" }
}
date {
match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
locale => "en"
}
geoip {
source => "line"
database => "/etc/logstash/GeoLiteCity.dat"
target => "geoip"
add_tag => "geoip"
}
}
output {
elasticsearch { hosts => ["192.168.0.213:9200"] }
stdout { codec => rubydebug }
}
Note that geoip source = [line], because I find that the ip address of the host accessing the apache server is contained in it, as in the following logstash capture:
tline 192.168.0.134 - - [21/Jan/2016:09:08:35 -0500] "GET / HTTP/1.1" 403 4961 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0"
None of the other fields presented in logstash have anything to do with geoip. It seems to me that I'd have to create a regex to pull the ip address out of the line field, but I simply don't have the skill.
Can anyone help me get geoip working?
With thanks,
Diggy