Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Nov 24, 2024
1 parent 692297f commit 31ceb23
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 246 deletions.
13 changes: 8 additions & 5 deletions keep/providers/grafana_provider/grafana_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pydantic
import requests
from grafana_api.model import APIEndpoints
from packaging.version import Version

from keep.api.models.alert import AlertDto, AlertSeverity, AlertStatus
Expand Down Expand Up @@ -154,7 +153,7 @@ def validate_scopes(self) -> dict[str, bool | str]:
return validated_scopes

def get_alerts_configuration(self, alert_id: str | None = None):
api = f"{self.authentication_config.host}{APIEndpoints.ALERTING_PROVISIONING.value}/alert-rules"
api = f"{self.authentication_config.host}/api/v1/provisioning/alert-rules"
headers = {"Authorization": f"Bearer {self.authentication_config.token}"}
response = requests.get(api, verify=False, headers=headers)
if not response.ok:
Expand All @@ -171,7 +170,7 @@ def get_alerts_configuration(self, alert_id: str | None = None):

def deploy_alert(self, alert: dict, alert_id: str | None = None):
self.logger.info("Deploying alert")
api = f"{self.authentication_config.host}{APIEndpoints.ALERTING_PROVISIONING.value}/alert-rules"
api = f"{self.authentication_config.host}/api/v1/provisioning/alert-rules"
headers = {"Authorization": f"Bearer {self.authentication_config.token}"}
response = requests.post(api, verify=False, json=alert, headers=headers)

Expand Down Expand Up @@ -243,7 +242,9 @@ def setup_webhook(
f"{GrafanaProvider.KEEP_GRAFANA_WEBHOOK_INTEGRATION_NAME}-{tenant_id}"
)
headers = {"Authorization": f"Bearer {self.authentication_config.token}"}
contacts_api = f"{self.authentication_config.host}{APIEndpoints.ALERTING_PROVISIONING.value}/contact-points"
contacts_api = (
f"{self.authentication_config.host}/api/v1/provisioning/contact-points"
)
try:
self.logger.info("Getting contact points")
all_contact_points = requests.get(
Expand Down Expand Up @@ -345,7 +346,9 @@ def setup_webhook(
# Finally, we need to update the policies to match the webhook
if setup_alerts:
self.logger.info("Setting up alerts")
policies_api = f"{self.authentication_config.host}{APIEndpoints.ALERTING_PROVISIONING.value}/policies"
policies_api = (
f"{self.authentication_config.host}/api/v1/provisioning/policies"
)
all_policies = requests.get(
policies_api, verify=False, headers=headers
).json()
Expand Down
Loading

0 comments on commit 31ceb23

Please sign in to comment.