Skip to content

Commit

Permalink
Merge pull request #6 from ChorusOne/metric-fix
Browse files Browse the repository at this point in the history
Fix timestamp parsing for gauge value
  • Loading branch information
mksh authored Oct 7, 2024
2 parents 3033aba + 7dc56ea commit 730ef5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions scripts/send_test_alert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import copy
import time

import requests

Expand All @@ -10,7 +9,7 @@
parser.add_argument(
"--watchtower-id", default="0x0e71247b49013664006D8472107f9e127695d9d7"
)
parser.add_argument("--timestamp", default=lambda: str(int(time.time())))
parser.add_argument("--timestamp", default="Oct 7 14:26:18 2024")
parser.add_argument("--file", default="emulator.py")
parser.add_argument("--line", default="9393")
parser.add_argument("--message", default="This is a test alert message")
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_integration() -> None:
% (
"0x0e71247b49013664006D8472107f9e127695d9d7",
"200",
"1728038914",
"Oct 7 14:26:18 2024",
"example.go",
"500",
"Test alert message",
Expand Down
4 changes: 2 additions & 2 deletions witnesschain_alertmanager_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ def alert(proxy: ProxySettings, body: WitnessChainErrorLog, response: Response)
body.text
), "Text received from WitnessChain Watchtower should not be empty"
alert = proxy.incoming(body)
ts = int(alert.labels["timestamp"])
ts = datetime.strptime(alert.labels["timestamp"], "%b %d %H:%M:%S %Y")
witnesschain_alert.labels(
alert.labels["file"], alert.labels["line"], alert.labels["watchtower_id"]
).set(ts)
).set(ts.timestamp())
rendered = proxy.render(alert)
proxy.send_alert(rendered)
response.status_code = 204
Expand Down

0 comments on commit 730ef5b

Please sign in to comment.