GithubHelp home page GithubHelp logo

Comments (1)

satterly avatar satterly commented on June 4, 2024

This is already possible ... https://github.com/alerta/python-alerta-client/blob/master/alertaclient/commands/cmd_heartbeats.py

if alert:
with click.progressbar(heartbeats, label='Alerting {} heartbeats'.format(len(heartbeats))) as bar:
for b in bar:
params = dict(filter(lambda a: len(a) == 2, map(lambda a: a.split(':'), b.tags)))
environment = params.get('environment', 'Production')
group = params.get('group', 'System')
tags = list(filter(lambda a: not a.startswith('environment:') and
not a.startswith('group:'), b.tags))
if b.status == 'expired': # aka. "stale"
client.send_alert(
resource=b.origin,
event='HeartbeatFail',
correlate=['HeartbeatFail', 'HeartbeatSlow', 'HeartbeatOK'],
group=group,
environment=environment,
service=['Alerta'],
severity=severity,
value='{}'.format(b.since),
text='Heartbeat not received in {} seconds'.format(b.timeout),
tags=tags,
type='heartbeatAlert',
timeout=timeout,
customer=b.customer
)
elif b.status == 'slow':
client.send_alert(
resource=b.origin,
event='HeartbeatSlow',
correlate=['HeartbeatFail', 'HeartbeatSlow', 'HeartbeatOK'],
group=group,
environment=environment,
service=['Alerta'],
severity=severity,
value='{}ms'.format(b.latency),
text='Heartbeat took more than {}ms to be processed'.format(MAX_LATENCY),
tags=tags,
type='heartbeatAlert',
timeout=timeout,
customer=b.customer
)
else:
client.send_alert(
resource=b.origin,
event='HeartbeatOK',
correlate=['HeartbeatFail', 'HeartbeatSlow', 'HeartbeatOK'],
group=group,
environment=environment,
service=['Alerta'],
severity=default_normal_severity,
value='',
text='Heartbeat OK',
tags=tags,
type='heartbeatAlert',
customer=b.customer

from python-alerta-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.