Skip to content

Commit baaf259

Browse files
shaharglKiryous
andauthored
feat(api): add grafana legacy (#2797)
Signed-off-by: Shahar Glazner <[email protected]> Co-authored-by: Kirill Chernakov <[email protected]>
1 parent b56a126 commit baaf259

File tree

29 files changed

+1509
-264
lines changed

29 files changed

+1509
-264
lines changed

docs/providers/documentation/grafana-provider.mdx

+22
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ description: "Grafana Provider allows either pull/push alerts from Grafana to Ke
44
---
55
<Tip>Grafana currently supports pulling/pushing alerts. We will add querying and notifying soon.</Tip>
66

7+
## Legacy vs Unified Alerting
8+
9+
Keep supports both Grafana's legacy alerting system and the newer Unified Alerting system. Here are the key differences:
10+
11+
### Legacy Alerting
12+
- Uses notification channels for alert delivery
13+
- Configured at the dashboard level
14+
- Uses a different API endpoint (`/api/alerts` and `/api/alert-notifications`)
15+
- Simpler setup but fewer features
16+
- Alerts are tightly coupled with dashboard panels
17+
18+
### Unified Alerting (Default from Grafana 9.0)
19+
- Uses alert rules and contact points
20+
- Configured centrally in the Alerting section
21+
- Uses the newer `/api/v1/alerts` endpoint
22+
- More powerful features including label-based routing
23+
- Supports multiple data sources in a single alert rule
24+
25+
<Note>
26+
If you're using Grafana 8.x or earlier, or have explicitly enabled legacy alerting in newer versions, make sure to configure Keep accordingly using the legacy alerting configuration.
27+
</Note>
28+
729
## Inputs
830

931
Grafana Provider does not currently support the `notify` function.

ee/identitymanager/identity_managers/keycloak/keycloak_authverifier.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def __init__(self, scopes: list[str] = []) -> None:
2121
self.keycloak_realm = os.environ.get("KEYCLOAK_REALM")
2222
self.keycloak_client_id = os.environ.get("KEYCLOAK_CLIENT_ID")
2323
self.keycloak_audience = os.environ.get("KEYCLOAK_AUDIENCE")
24+
self.keycloak_verify_cert = (
25+
os.environ.get("KEYCLOAK_VERIFY_CERT", "true").lower() == "true"
26+
)
2427
if (
2528
not self.keycloak_url
2629
or not self.keycloak_realm
@@ -35,12 +38,14 @@ def __init__(self, scopes: list[str] = []) -> None:
3538
realm_name=self.keycloak_realm,
3639
client_id=self.keycloak_client_id,
3740
client_secret_key=os.environ.get("KEYCLOAK_CLIENT_SECRET"),
41+
verify=self.keycloak_verify_cert,
3842
)
3943
self.keycloak_openid_connection = KeycloakOpenIDConnection(
4044
server_url=self.keycloak_url,
4145
realm_name=self.keycloak_realm,
4246
client_id=self.keycloak_client_id,
4347
client_secret_key=os.environ.get("KEYCLOAK_CLIENT_SECRET"),
48+
verify=self.keycloak_verify_cert,
4449
)
4550
self.keycloak_uma = KeycloakUMA(connection=self.keycloak_openid_connection)
4651
# will be populated in on_start of the identity manager

ee/identitymanager/identity_managers/keycloak/keycloak_identitymanager.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ class KeycloakIdentityManager(BaseIdentityManager):
4545
def __init__(self, tenant_id, context_manager: ContextManager, **kwargs):
4646
super().__init__(tenant_id, context_manager, **kwargs)
4747
self.server_url = os.environ.get("KEYCLOAK_URL")
48+
self.keycloak_verify_cert = (
49+
os.environ.get("KEYCLOAK_VERIFY_CERT", "true").lower() == "true"
50+
)
4851
try:
4952
self.keycloak_admin = KeycloakAdmin(
5053
server_url=os.environ["KEYCLOAK_URL"] + "/admin",
5154
username=os.environ.get("KEYCLOAK_ADMIN_USER"),
5255
password=os.environ.get("KEYCLOAK_ADMIN_PASSWORD"),
5356
realm_name=os.environ["KEYCLOAK_REALM"],
54-
verify=True,
57+
verify=self.keycloak_verify_cert,
5558
)
5659
self.client_id = self.keycloak_admin.get_client_id(
5760
os.environ["KEYCLOAK_CLIENT_ID"]
@@ -61,6 +64,7 @@ def __init__(self, tenant_id, context_manager: ContextManager, **kwargs):
6164
client_id=os.environ["KEYCLOAK_CLIENT_ID"],
6265
realm_name=os.environ["KEYCLOAK_REALM"],
6366
client_secret_key=os.environ["KEYCLOAK_CLIENT_SECRET"],
67+
verify=self.keycloak_verify_cert,
6468
)
6569

6670
self.admin_url = f'{os.environ["KEYCLOAK_URL"]}/admin/realms/{os.environ["KEYCLOAK_REALM"]}/clients/{self.client_id}'

0 commit comments

Comments
 (0)