-
Notifications
You must be signed in to change notification settings - Fork 0
/
condor.logstash.conf
145 lines (145 loc) · 5.64 KB
/
condor.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# This processes an HTCondor EventLog and sends the events to Elasticsearch.
# It requires that a Job ad information event (028) be triggered with
# supplemental classad information via the JobAdInformationAttrs config val.
# see http://research.cs.wisc.edu/htcondor/manual/current/12_Appendix_A.html#JobAdInformationAttrs-job-attribute
#
# Requires aggregate plugin https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html
input {
file {
path => "/var/log/condor/EventLog"
type => "condor_eventlog"
start_position => beginning
delimiter => "
...
"
codec => multiline {
pattern => "^[^\d]"
what => "previous"
}
add_field => { "pool" => "fifebatch" }
}
}
filter {
if [type] == "condor_eventlog" {
grok {
patterns_dir => "/etc/landscape/patterns"
match => {
"message" => [
"%{CONDOR_EVENT:event} %{DATA:event_message}\n%{GREEDYDATA:event_body}\n\.\.\.",
"%{CONDOR_EVENT:event} %{DATA:event_message}\n\.\.\."
]
}
}
date {
match => [ "condor_timestamp", "MM/dd HH:mm:ss" ]
remove_field => [ "condor_timestamp" ]
}
mutate {
add_field => { "jobid" => "%{cluster}.%{process}@%{host}" }
}
truncate {
fields => [ "ErrorMsg" ]
length_bytes => 16384
}
if [event_code] == "028" {
aggregate {
task_id => "%{cluster}.%{process}.%{subprocess}@%{host}"
code => "event.set('trigger_event_message',map['trigger_event_message'])"
map_action => "update"
end_of_task => true
timeout => "60"
}
kv {
source => "event_body"
value_split => " = "
field_split => "\n"
remove_field => [ "event_body" ]
}
mutate {
convert => {
"MemoryUsage" => "integer"
"ResidentSetSize" => "integer"
"ReceivedBytes" => "float"
"SentBytes" => "float"
"TotalReceivedBytes" => "float"
"TotalSentBytes" => "float"
"Size" => "integer"
}
}
ruby {
code => '
# convert to bytes
if event.include?("MemoryUsage")
event.set("MemoryUsage",event.get("MemoryUsage").to_i*1024*1024)
end
if event.include?("ResidentSetSize")
event.set("ResidentSetSize", event.get("ResidentSetSize").to_i*1024)
end'
}
mutate {
gsub => [
"trigger_event_message", "\n", " ",
"trigger_event_message", "\t", " "
]
}
grok {
patterns_dir => "/etc/landscape/patterns"
match => {
"trigger_event_message" => [
"%{CONDOR_EVENT_001}",
"%{CONDOR_EVENT_006}",
"%{CONDOR_EVENT_012}",
"%{CONDOR_EVENT_005_RESOURCES}",
"%{CONDOR_EVENT_005}",
"%{CONDOR_EVENT:event} %{DATA:event_message}\n%{GREEDYDATA:_trigger_event_body}",
"%{CONDOR_EVENT:event} %{DATA:event_message}"
]
}
overwrite => [ "event", "event_message", "event_code", "cluster", "process", "subprocess" ]
remove_field => [ "trigger_event_message" ]
}
# combine durations
if [event_code] == "005" {
ruby {
code => '
for metric in ["local_sys_time","local_user_time","remote_sys_time","remote_user_time"] do
for group in ["run","total"] do
name = group+"_"+metric
time = event.get(name+"_seconds") || 0
event.remove(name+"_seconds")
time += (event.get(name+"_minutes") || 0) * 60
event.remove(name+"_minutes")
time += (event.get(name+"_hours") || 0) * 3600
event.remove(name+"_hours")
time += (event.get(name+"_days") || 0) * 3600 * 24
event.remove(name+"_days")
event.set(name,time)
end
end'
}
}
} else {
aggregate {
task_id => "%{cluster}.%{process}.%{subprocess}@%{host}"
code => "map['trigger_event_message']=event.get('message')"
map_action => "create"
}
drop {}
}
}
}
output {
elasticsearch {
hosts => [ "fifemon-es.fnal.gov" ]
ssl => true
cacert => "/etc/grid-security/certificates/cilogon-osg.pem"
keystore => "/fife/local/home/rexbatch/fifemon-logstash/logstash_fifebatch_fnal_gov.p12"
keystore_password => ""
index => "fifebatch-logs-%{+YYYY.MM.dd}"
template_name => "fifebatch-logs"
template => "/fife/local/home/rexbatch/fifemon-logstash/fifebatch-logs.json"
manage_template => true
template_overwrite => true
}
#stdout {codec => "rubydebug"}
}