refactor(formatter/pingdom): build message content line-by-line
feat(formatter/pingdom): add tags to output (if set)
This commit is contained in:
parent
8c18c2054e
commit
f4808719b0
1 changed files with 8 additions and 5 deletions
|
@ -8,17 +8,20 @@ def formatter(data, headers):
|
||||||
check_id = data["check_id"]
|
check_id = data["check_id"]
|
||||||
check_name = data["check_name"]
|
check_name = data["check_name"]
|
||||||
current_state = data["current_state"]
|
current_state = data["current_state"]
|
||||||
|
tags = data["tags"]
|
||||||
local_time = datetime.fromtimestamp(data["state_changed_timestamp"])
|
local_time = datetime.fromtimestamp(data["state_changed_timestamp"])
|
||||||
|
|
||||||
if data["check_type"].lower() == "http":
|
if data["check_type"].lower() == "http":
|
||||||
# http https or http_custom check types
|
# http https or http_custom check types
|
||||||
try:
|
try:
|
||||||
check_url = data["check_params"]["full_url"]
|
check_url = data["check_params"]["full_url"]
|
||||||
data["body"] = (
|
message = ""
|
||||||
f"###{check_name} is {current_state}\n\n{check_url}"
|
message += f"###{check_name} is {current_state}\n\n{check_url}"
|
||||||
f" marked {current_state} at {local_time} ⚬ "
|
message += f" marked {current_state} at {local_time} ⚬ "
|
||||||
f"[view details](https://my.pingdom.com/reports/responsetime#check={check_id})"
|
message += f"[view details](https://my.pingdom.com/reports/responsetime#check={check_id})"
|
||||||
)
|
if tags:
|
||||||
|
message += f"\n\nTags: {tags}"
|
||||||
|
data["body"] = message
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
data["body"] = (
|
data["body"] = (
|
||||||
f"Error: An attempt to post from pingdom was malformed "
|
f"Error: An attempt to post from pingdom was malformed "
|
||||||
|
|
Loading…
Reference in a new issue