create silence matchers from alert labels

This commit is contained in:
HgO 2022-07-10 02:54:35 +02:00
parent 3ca45fccb1
commit 2e2db345da
2 changed files with 3 additions and 3 deletions

View file

@ -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,

View file

@ -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__)