Skip to content

Commit ca1d70f

Browse files
committed
Update alert script examples
1 parent 177b256 commit ca1d70f

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

examples/alerta.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
timezone = Europe/London
33
;timezone = Australia/Sydney
44
colour = yes
5-
output = text
5+
output = psql ; Postgres-style table format
66

77
[profile production]
88
endpoint = https://uk.alerta.io

examples/send.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
#!/usr/bin/env python
22

3-
from alertaclient.api import AlertaClient
4-
from alertaclient.models.alert import Alert
3+
from alertaclient.api import Client
54

6-
client = AlertaClient()
7-
8-
alert = Alert(
9-
resource='web-server-01',
10-
event='HttpError',
11-
correlate=['HttpOK'],
12-
group='Web',
13-
environment='Production',
14-
service=['theguardian.com'],
15-
severity='major',
16-
value='Bad Gateway (502)',
17-
text='Web server error.',
18-
tags=['web', 'dc1', 'london'],
19-
attributes={'customer': 'The Guardian'}
20-
)
21-
print(alert)
5+
client = Client()
226

237
try:
24-
print(client.send(alert))
8+
alert = client.send_alert(
9+
resource='web-server-01',
10+
event='HttpError',
11+
correlate=['HttpOK'],
12+
group='Web',
13+
environment='Production',
14+
service=['theguardian.com'],
15+
severity='major',
16+
value='Bad Gateway (502)',
17+
text='Web server error.',
18+
tags=['web', 'dc1', 'london'],
19+
attributes={'customer': 'The Guardian'}
20+
)
21+
print(alert)
2522
except Exception as e:
2623
print(e)

0 commit comments

Comments
 (0)