/
logstash.conf
99 lines (86 loc) · 2.06 KB
/
logstash.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
# How-To
#
# Run:
# ./start.sh
#
# Kibana dashboard restore:
# curl -X PUT http://localhost:9200/kibana-int/dashboard/SensorDashboard -T dashboards/SensorDashboard.json
#
# Kibana dashboard backup:
# curl -s -X GET http://localhost:9200/kibana-int/dashboard/SensorDashboard/_source > dashboards/SensorDashboard.json
#
#
# Test (elasticsearch must be running):
# http://localhost:9200/_search?pretty
#
# delete old data:
# apt-get install python-pip
# pip install elasticsearch-curator
#
# Older than one day:
# /usr/local/bin/curator --host localhost delete --older-than 1
#
# Delete all (but hopefully keep the Kibana configuration):
# /usr/local/bin/curator --host localhost delete --disk-space 0.0002
#
# Index all log files:
#
# cat logdata*.txt | nc -q 5 localhost 3333
#
input {
# stdin {
# type => "sensorlog"
# }
tcp {
type => "sensorlog"
port => 3333
}
}
filter {
if [type] == "sensorlog" {
# try the temperature and humidity logs
grok {
match => { "message" => "%{SENSORLOG1}"}
patterns_dir => ["./patterns"]
add_tag => ["sensorlog1"]
}
# ... finally drop all unknown messages
if "_grokparsefailure" in [tags] {
drop { }
}
mutate {
# provided by Sensor Log 1
convert => [ "TEMPERATURE", "float" ]
convert => [ "HUMIDITY", "float" ]
}
date {
match => ["LOGDATE" , "yyyy-MM-dd HH:mm:ss"]
target => "@timestamp"
}
# remove obsolete information
mutate {
remove_field => [ "LOGDATE" ]
remove_field => [ "message" ]
remove_field => [ "host" ]
}
}
}
output {
#we leave this so that when we debug running logstash from the command line we can see the output that will be stored in elasticsearch
#if "_grokparsefailure" in [tags] {
stdout {
codec => rubydebug
}
#}
#again for security purposes our elasticserach installation only runs on localhost.
if "_grokparsefailure" not in [tags] {
elasticsearch {
protocol => "http"
host => "localhost"
# avoid duplicated entries
document_id => "%{md5sum}"
cluster => "sensorcluster"
}
}
}