Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Last active December 19, 2015 16:52
Show Gist options
  • Save IanVaughan/14cf7930e0cde4c30d37 to your computer and use it in GitHub Desktop.
Save IanVaughan/14cf7930e0cde4c30d37 to your computer and use it in GitHub Desktop.
/opt/logstash/bin/logstash -w 4 -f /etc/logstash/conf.d/logstash.conf
tail -f /var/log/logstash/logstash.log/.stdout
sudo /usr/bin/filebeat -e -v
# /etc/filebeat/filebeat.yml
filebeat:
prospectors:
-
paths:
- /var/log/*.log
document_type: syslog
-
paths:
- /srv/www/app/shared/production.log
- /srv/www/app/shared/requests.log
document_type: rails_log
-
paths:
- /srv/www/app/shared/access
document_type: nginx_access
registry_file: /var/lib/filebeat/registry
output:
logstash:
hosts: ["my.ip.add:5044"]
tls:
certificate_authorities: ["/etc/pki/tls/certs/logstash-forwarder.crt"]
logging:
#to_syslog: true
# match => { "message" => "%{WORD:debuglevel}, .%{TIMESTAMP_ISO8601}.*%{LOGLEVEL} -- : %{NUMBER:time} %{INT:status} %{WORD:method} %{URIPATHPARAM:path} %{GREEDYDATA:params}" }
# /etc/logstash/conf.d/logstash.conf
input {
beats {
port => 5044
type => "logs"
ssl => true
ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"
ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"
}
}
filter {
if [type] == "rails_log" {
grok {
match => { "message" => "<%{POSINT:syslog_pri}>%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST:logsource} %{SYSLOGPROG}: %{GREEDYDATA:clean_message}" }
}
}
}
filter {
if [type] == "syslog" {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
}
syslog_pri { }
date {
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
}
output {
elasticsearch { hosts => ["localhost:9200"] }
stdout { codec => rubydebug }
}
@IanVaughan
Copy link
Author

TODO

  • Multiline rails error logs
  • "fields" field in kibana
  • tag messages from server
  • all from one server1?

rsyslog
/etc/elasticsearch$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment