Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default promethues generator url to simulation #1651

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion playbooks/robusta_playbooks/alerts_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def default_enricher(alert: PrometheusKubernetesAlert, params: DefaultEnricherPa

By default, this enricher is last in the processing order, so it will be added to all alerts, that aren't silenced.
"""
alert.add_link(Link(url=alert.alert.generatorURL, name="View Graph", type=LinkType.PROMETHEUS_GENERATOR_URL))
if alert.alert.generatorURL:
alert.add_link(Link(url=alert.alert.generatorURL, name="View Graph", type=LinkType.PROMETHEUS_GENERATOR_URL))

labels = alert.alert.labels
alert.add_enrichment(
Expand Down
4 changes: 3 additions & 1 deletion playbooks/robusta_playbooks/prometheus_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from robusta.utils.error_codes import ActionException, ErrorCodes
from robusta.utils.silence_utils import AlertManagerParams, gen_alertmanager_headers, get_alertmanager_url

FALLBACK_PROMETHUES_GENERATOR_URL = "http://localhost:9090/graph?g0.expr=up%7Bjob%3D%22apiserver%22%7D&g0.tab=0&g0.stacked=0&g0.show_exemplars=0&g0.range_input=1h"


def parse_by_operator(pairs: str, operator: str) -> Dict[str, str]:
if not pairs:
Expand Down Expand Up @@ -61,7 +63,7 @@ class PrometheusAlertParams(ActionParams):
severity: str = "error"
description: str = "simulated prometheus alert"
summary: Optional[str]
generator_url = ""
generator_url = FALLBACK_PROMETHUES_GENERATOR_URL
runbook_url: Optional[str] = ""
fingerprint: Optional[str] = ""
labels: Optional[str] = None
Expand Down
Loading