Skip to content

Commit c8f2b65

Browse files
authored
send attributes for epmon heartbeats (#17)
Heartbeat attributes in epmon Reviewed-by: None <None> Reviewed-by: None <None>
1 parent 4a827ca commit c8f2b65

2 files changed

Lines changed: 12 additions & 20 deletions

File tree

apimon/ansible/callback/apimon_profiler.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def v2_runner_on_failed(self, result, ignore_errors=False):
446446
rc = 3 if not ignore_errors else 2
447447
self._update_task_stats(result, rc)
448448

449-
def _emit_message(self, data: dict) -> None:
449+
def _emit_message(self, data):
450450
if self.message_socket_address:
451451
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as _socket:
452452
try:
@@ -539,23 +539,11 @@ def v2_playbook_on_stats(self, stats):
539539
'Overall duration of APImon tasks in playbook %s is: %s s' %
540540
(self.playbook_name, str(overall_apimon_duration / 1000)))
541541

542-
def _get_metric_data(self, name: str,
543-
vals: dict, **kwargs) -> dict:
542+
def _get_metric_data(
543+
self, name, vals, **kwargs
544+
):
544545
rc = int(vals.get('rc', -1))
545546
dt = []
546-
# message.Metric(
547-
# '%s.attempted' % (name),
548-
# value=1,
549-
# metric_type='c',
550-
# **kwargs
551-
# ),
552-
# message.Metric(
553-
# '%s.rc_%s' % (name, str(rc)),
554-
# value=1,
555-
# metric_type='c',
556-
# **kwargs
557-
# )
558-
# ]
559547
if rc == 0:
560548
kwargs['name_suffix'] = 'passed'
561549
elif rc == 1:
@@ -572,7 +560,7 @@ def _get_metric_data(self, name: str,
572560
))
573561
return dt
574562

575-
def _anonymize_message(self, msg: str) -> str:
563+
def _anonymize_message(self, msg):
576564
# Anonymize remaining part
577565
# Project_id
578566
result = msg

apimon/epmon/server.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ def run(self) -> None:
142142
if self.alerta:
143143
try:
144144
self.alerta.heartbeat(
145-
origin='apimon.epmon.%s.%s' % (
146-
self.zone, self.target_cloud),
147-
tags=['apimon', 'epmon']
145+
origin='apimon.epmon',
146+
tags=['apimon', 'epmon'],
147+
attributes={
148+
'zone': self.zone,
149+
'cloud': self.target_cloud,
150+
'service': ['apimon', 'epmon'],
151+
}
148152
)
149153
except Exception:
150154
self.log.exception('Error sending heartbeat')

0 commit comments

Comments
 (0)