@@ -129,8 +129,8 @@ def _process_data(
129
129
)
130
130
# Send the list of data to the metric and event callbacks
131
131
self ._process_metrics (data_dict , url )
132
- if process_events :
133
- self ._process_event (data_dict , url )
132
+ if process_events :
133
+ self ._process_event (data_dict , url )
134
134
135
135
if collect_status_metrics :
136
136
self ._process_status_metric (hosts_statuses , collect_status_metrics_by_host )
@@ -263,32 +263,39 @@ def _process_event(self, data, url):
263
263
lastchg = 0
264
264
265
265
# Create the event object
266
- ev = self ._create_event (data ['status' ], hostname , lastchg , service_name )
266
+ ev = self ._create_event (
267
+ data ['status' ], hostname , lastchg , service_name ,
268
+ data ['back_or_front' ]
269
+ )
267
270
self .event (ev )
268
271
269
272
# Store this host status so we can check against it later
270
273
self .host_status [url ][key ] = data ['status' ]
271
274
272
- def _create_event (self , status , hostname , lastchg , service_name ):
275
+ def _create_event (self , status , hostname , lastchg , service_name , back_or_front ):
276
+ HAProxy_agent = self .hostname .decode ('utf-8' )
273
277
if status == "DOWN" :
274
278
alert_type = "error"
275
- title = "%s reported %s %s" % (service_name , hostname , status )
279
+ title = "%s reported %s:%s %s" % (HAProxy_agent , service_name , hostname , status )
276
280
else :
277
281
if status == "UP" :
278
282
alert_type = "success"
279
283
else :
280
284
alert_type = "info"
281
- title = "%s reported %s back and %s" % (service_name , hostname , status )
285
+ title = "%s reported %s:%s back and %s" % (HAProxy_agent , service_name , hostname , status )
282
286
287
+ tags = ["service:%s" % service_name ]
288
+ if back_or_front == Services .BACKEND :
289
+ tags .append ('backend:%s' % hostname )
283
290
return {
284
291
'timestamp' : int (time .time () - lastchg ),
285
292
'event_type' : EVENT_TYPE ,
286
- 'host' : hostname ,
293
+ 'host' : HAProxy_agent ,
287
294
'msg_title' : title ,
288
295
'alert_type' : alert_type ,
289
296
"source_type_name" : SOURCE_TYPE_NAME ,
290
297
"event_object" : hostname ,
291
- "tags" : [ "frontend:%s" % service_name , "host:%s" % hostname ]
298
+ "tags" : tags
292
299
}
293
300
294
301
@staticmethod
0 commit comments