my template is as below
{
"template" : "iisnew",
"settings": { "index.refresh_interval": "5s" },
"mappings" : {
"iisnew" : {
"properties": {
"@timestamp":{"type":"date","format":"dateOptionalTime"},
"@version":{"type":"string", "index" : "not_analyzed"},
"tags":{"type":"string"},
"type":{"type":"string"},
"geoip":{
"properties":{
"city_name":{"type":"string", "index":"not_analyzed"},
"continent_code":{"type":"string"},
"country_code2":{"type":"string"},
"country_code3":{"type":"string"},
"country_name":{"type":"string", "index":"not_analyzed"},
"ip":{"type":"ip"},
"latitude":{"type":"double"},
"location":{"type":"geo_point"},
"longitude":{"type":"double"},
"postal_code":{"type":"string"},
"region_code":{"type":"string", "index":"not_analyzed"},
"region_name":{"type":"string", "index":"not_analyzed"},
"timezone":{"type":"string"}
} },
"response":{"type":"long"},
"sc-status":{"type":"long"},
"sc-substatus":{"type":"long"},
"time-taken":{"type":"long"},
"c-ip":{"type":"ip"},
"cs":{"type":"string"},
"cs-method":{"type":"string"},
"cs-uri-query":{"type":"string"},
"cs-uri-stem":{"type":"string"},
"cs-username":{"type":"string"},
"host":{"type":"string"},
"message":{"type":"string"},
"path":{"type":"string"},
"s-port":{"type":"long"},
"s-sitename":{"type":"ip"},
}
}
}
}
my config file as below
input {
file {
type => "iis-w3c"
path => "C:/ElasticProducts/iis.log"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
if [message] =~ "^#" {
drop {}
}
grok {
match => [
"message", "%{TIMESTAMP_ISO8601:timestamp} %{IPORHOST:s-sitename} %{WORD:cs-method} %{URIPATH:cs-uri-stem} %{NOTSPACE:cs-uri-query} %{NUMBER:s-port} %{NOTSPACE:cs-username} %{IPORHOST:c-ip} %{NOTSPACE:cs(User-Agent)} %{NOTSPACE:cs(Referer)} %{NUMBER:response:int} %{NUMBER:sc-status:int} %{NUMBER:sc-substatus:int} %{NUMBER:time-taken:int}"
]
}
date {
match => [ "timestamp", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Etc/UTC"
}
if [sc-bytes] {
ruby {
code => "event['kilobytesSent'] = event['sc-bytes'].to_i / 1024.0"
}
}
if [cs-bytes] {
ruby {
code => "event['kilobytesReceived'] = event['cs-bytes'].to_i / 1024.0"
}
}
mutate {
convert => ["sc-bytes", "integer"]
convert => ["cs-bytes", "integer"]
convert => ["time-taken", "integer"]
remove_field => [ "timestamp"]
}
geoip {
source => "c-ip"
target => "geoip"
add_tag => [ "iis-geoip" ]
database => "C:/ElasticProducts/geoip/GeoLite2-City.mmdb"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float"]
}
useragent {
source => "cs(User-Agent)"
prefix=> "browser"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
user => "elastic"
password => "changeme"
index => "iisnew"
template => "C:\ElasticProducts\iisnew.json"
document_type => "iis-log"
}
stdout {
codec => rubydebug
}
}