create silence matchers from alert labels
This commit is contained in:
parent
3ca45fccb1
commit
2e2db345da
2 changed files with 3 additions and 3 deletions
|
@ -51,15 +51,15 @@ class AlertmanagerClient:
|
|||
alert = await self.get_alert(fingerprint)
|
||||
|
||||
self._match_alert(alert, matchers)
|
||||
matchers_json = {m.label: m.value for m in matchers}
|
||||
|
||||
labels = alert["labels"]
|
||||
start_time = datetime.now()
|
||||
duration_seconds = pytimeparse2.parse(duration)
|
||||
duration_delta = timedelta(seconds=duration_seconds)
|
||||
end_time = start_time + duration_delta
|
||||
|
||||
silence = {
|
||||
"matchers": matchers_json,
|
||||
"matchers": labels,
|
||||
"startsAt": start_time.isoformat(),
|
||||
"endsAt": end_time.isoformat(),
|
||||
"createdBy": user,
|
||||
|
|
|
@ -9,9 +9,9 @@ from aiohttp_prometheus_exporter.middleware import prometheus_middleware_factory
|
|||
from diskcache import Cache
|
||||
from nio import AsyncClient, SendRetryError
|
||||
|
||||
from matrix_alertbot.alert import Alert
|
||||
from matrix_alertbot.chat_functions import send_text_to_room
|
||||
from matrix_alertbot.config import Config
|
||||
from matrix_alertbot.alert import Alert
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
Loading…
Reference in a new issue