Last active
August 29, 2015 14:16
-
-
Save ShawInnes/16a8c67548ebc1e0a400 to your computer and use it in GitHub Desktop.
logstash api importer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store | |
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
file { | |
path => "/Users/shaw/apilogs/data/API-*/*.log" | |
tags => [ "api" ] | |
start_position => "beginning" | |
} | |
} | |
filter{ | |
if [message] =~ "^#" { | |
drop {} | |
} | |
grok { | |
match => ["path", "data/(?<log_host>[^/]+)/(?<log_file>.*).log"] | |
} | |
grok { | |
match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} %{IPORHOST:ip} %{WORD:method} %{URIPATH:uri} %{NOTSPACE:username} %{IPORHOST:cip} %{NOTSPACE:httpversion} %{NOTSPACE:useragent} %{NOTSPACE:cookie} %{NOTSPACE:referer} (%{URIHOST:chost}|%{NOTSPACE:chost}) %{INT:scstatus} %{INT:scsubstatus} %{INT:scbytes} %{INT:csbytes} %{INT:timetaken}"] | |
} | |
date { | |
match => [ "log_timestamp", "YYYY-MM-dd HH:mm:ss" ] | |
timezone => "Etc/UTC" | |
} | |
useragent { | |
source => "useragent" | |
prefix => "browser" | |
} | |
mutate { | |
remove_field => ["log_timestamp"] | |
gsub => [ "log_host", "-", "" ] | |
} | |
if [uri] =~ /v(2.7|2.8|2.9|3.0|max)/ { | |
ruby { | |
code => "event['api_version'] = /v(2.7|2.8|2.9|3.0|max)/.match(event['uri'])[1]" | |
} | |
} | |
} | |
output { | |
elasticsearch { | |
host => localhost | |
protocol => http | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
curl -XDELETE 'http://127.0.0.1:9200/metrics/' | |
curl -XDELETE 'http://127.0.0.1:9200/logstash-*/' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
logstash agent -f iis.config --verbose | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment