Skip to content

Commit

Permalink
Generate Prometheus metrics for DDOS_PROTOCOL_VIOLATION_SET notificat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
mirceaulinic committed Nov 12, 2020
1 parent ff850b2 commit ba1acd8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions napalm_logs/transport/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,26 @@ def _parse_nat_session_closed(self, msg):
'''
self.__parse_nat_session(msg)

def _parse_ddos_protocol_violation_set(self, msg):
'''
Build metrics for DDOS_PROTOCOL_VIOLATION_SET messages.
'''
error = msg['error']
if error not in self.metrics:
self.metrics[error] = Counter(
'napalm_logs_{error}'.format(error=error.lower()),
'Counter for {error} notifications'.format(error=error),
['host', 'event_type', 'entity_type', 'additional_text']
)
alarm_dict = msg['yang_message']['alarms']['alarm']
labels = {
'host': msg['host'],
'event_type': alarm_dict['event-type'],
'entity_type': alarm_dict['entity-type'],
'additional_text': alarm_dict['additional-text']
}
self.metrics[error].labels(**labels).inc()

def start(self):
log.debug('Starting the Prometheus publisher')

Expand Down

0 comments on commit ba1acd8

Please sign in to comment.