Skip to content

Commit

Permalink
avoid namespace service and kind labels on node alerts (#982)
Browse files Browse the repository at this point in the history
* avoid namespace service and kind labels on node alerts
  • Loading branch information
RoiGlinik authored Jul 12, 2023
1 parent bdf50c4 commit 924ab20
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/robusta/core/reporting/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,21 @@ def __str__(self):

def get_prometheus_silence_url(self, account_id: str, cluster_name: str) -> str:
labels: Dict[str, str] = {"alertname": self.aggregation_key, "cluster": cluster_name, "account": account_id}
if self.subject.namespace:
labels["namespace"] = self.subject.namespace
kind: Optional[str] = self.subject.subject_type.value
if kind == "node":
pass
else:
if self.subject.namespace:
labels["namespace"] = self.subject.namespace

if self.silence_labels and self.silence_labels.get("service"):
labels["service"] = self.silence_labels["service"]
if self.silence_labels and self.silence_labels.get("service"):
labels["service"] = self.silence_labels["service"]

# In prometheus job is related to the scrape target.
# Kubernetes jobs are stored in job_name.
kind: Optional[str] = self.subject.subject_type.value
if kind and self.subject.name:
kind = "job_name" if kind == "job" else kind
labels[kind] = self.subject.name
# In prometheus, job is related to the scrape target.
# Kubernetes jobs are stored in job_name.
if kind and self.subject.name:
kind = "job_name" if kind == "job" else kind
labels[kind] = self.subject.name

labels["referer"] = "sink"
# New label added here should be added to the UI silence create whitelist as well.
Expand Down

0 comments on commit 924ab20

Please sign in to comment.