Skip to content

Commit

Permalink
chore(provider): zabbix from mediatype to script (keephq#2397)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Nov 5, 2024
1 parent f926c9d commit 8ef0d80
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 203 deletions.
Binary file added docs/images/pulling-enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/pushing-enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 48 additions & 11 deletions docs/overview/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
---
title: "Introduction"
description: "Keep is an open-source alert management and automation tool that provides everything you need to collect, enrich and manage alerts effectively."
description: "Keep is an open-source alert management and AIOps platform that is a swiss-knife for alerting, automation, and noise reduction."
---
<Note> You can start using Keep by logging in to the [platform](https://platform.keephq.dev).</Note>

<Note>
{" "}
You can start exploring Keep by simply logging in to the [platform](https://platform.keephq.dev).
Make sure to also join our [Slack community](https://slack.keephq.dev) to get help
and share your feedback.
</Note>

## What's an alert?

An alert is an event that is triggered when something undesirable occurs or is about to occur.
It is usually triggered by monitoring tools such as Prometheus, Grafana, or CloudWatch, and some proprietary tools.
It is usually triggered by monitoring tools. Example could include: Prometheus, Grafana, Datadog or CloudWatch, and your own proprietary tools.

Alerts are usually categorized into three different groups:

- Infrastructure-related alerts - e.g., a virtual machine consumes more than 99% CPU.
- Application-related alerts - e.g., an endpoint starts returning 5XX status codes.
- Business-related alerts - e.g., a drop in the number of sign-ins or purchases.

## What problem does Keep solve?

Keep helps with every step of the alert lifecycle:
1. Maintenance - Keep integrates with all of your monitoring tools, allowing you to manage all of your alerts within a single interface.
2. Noise reduction - By integrating with monitoring tools, Keep can deduplicate and correlate alerts to reduce noise in your organization. There are 2 types of deduplication: Rule-based (all distributions), and AI-based (Keep Enterprise only).
3. Automation - [Keep Workflows](/workflows) enables automated alert enrichment and response.
4. Incident Correlation - Automatically assigns alerts to incidents, performs triage, and conducts root cause analysis (Keep Enterprise only).
5. Summarization - Keep summarizes incidents based on past incidents and a knowledge base (Keep Enterprise only).

## How does Keep integrate with alerts?
Alerts can either be [pulled](/platform/alerts#pulled-alerts) by Keep or [pushed](/platform/alerts#pushed-alerts) into it. Keep also offers zero-click alert instrumentation through [webhook installation](/providers/overview).

1. Maintenance - Keep integrates with all of your monitoring tools, allowing you to manage all of your alerts within a single pane of glass.
2. Noise reduction - By integrating with monitoring tools, Keep can deduplicate and correlate alerts to reduce noise in your organization. There are 2 types of deduplication: Rule-based (semi-manual) and AI-based (fully automated).
3. Automation - [Keep Workflows](/workflows) is a GitHub Actions-like experience for automating anything that is triggered by things in Keep: alerts, events, incidents, manually and based on time intervals. It can help with: alert enrichment, ticket creation, self-healing, root cause analysis, and more.
4. Incident Correlation - Correlate alerts to incidents, performs triage, and conducts root cause analysis.

## How does Keep get my alerts?

There are primarily two ways to get alerts into Keep:

### Push

When you connect a [Provider](/providers), Keep automatically instruments the tools to send alerts to Keep via webhook.
As an example, when you connect Grafana, Keep will automatically create a new Webhook contact point in Grafana, and a new Notification Policy to send all alerts to Keep.

You can configure which providers you want to push from by checking the `Install Webhook` checkbox in the provider settings.

<Frame>
<img src="/images/pushing-enabled.png" />
</Frame>

### Pull

When you connect a [Provider](/providers), Keep will start pulling alerts from the tool automatically.
Pulling interval is defined by the `KEEP_PULL_INTERVAL` environment variable and defaults to 7 days and can be completely turned off by using the `KEEP_PULL_DATA_ENABLED` environment variable.

You can also configure which providers you want to pull from by checking the `Pulling Enabled` checkbox in the provider settings.

<Frame>
<img src="/images/pulling-enabled.png" />
</Frame>

<Tip>
We strongly recommend using the push method for alerting, as pulling does not
include a lot of the features, like workflow automation. It is mainly used for
a quick way to get alerts into Keep and start exploring the value.
</Tip>
2 changes: 1 addition & 1 deletion docs/providers/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ By leveraging Keep Providers, users are able to deeply integrate Keep with the t
title="Service Now"
href="/providers/documentation/service-now-provider"
icon={
<img src="https://img.logo.dev/service-now.com?token=pk_dfXfZBoKQMGDTIgqu7LvYg" />
<img src="https://img.logo.dev/servicenow.com?token=pk_dfXfZBoKQMGDTIgqu7LvYg" />
}
/>

Expand Down
2 changes: 1 addition & 1 deletion keep-ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const nextConfig = {
? {
exclude: ["error"],
}
: false,
: process.env.REMOVE_CONSOLE === "true",
},
output: "standalone",
productionBrowserSourceMaps: process.env.ENV === "development",
Expand Down
48 changes: 4 additions & 44 deletions keep/api/routes/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from keep.contextmanager.contextmanager import ContextManager
from keep.identitymanager.authenticatedentity import AuthenticatedEntity
from keep.identitymanager.identitymanagerfactory import IdentityManagerFactory
from keep.providers.base.base_provider import BaseProvider
from keep.providers.base.provider_exceptions import (
GetAlertException,
ProviderMethodException,
Expand Down Expand Up @@ -345,45 +344,6 @@ def delete_provider(
return JSONResponse(status_code=400, content={"message": str(e)})


def validate_scopes(
provider: BaseProvider, validate_mandatory=True
) -> dict[str, bool | str]:
logger.info("Validating provider scopes")
try:
validated_scopes = provider.validate_scopes()
except Exception as e:
logger.exception("Failed to validate provider scopes")
raise HTTPException(
status_code=412,
detail=str(e),
)
if validate_mandatory:
mandatory_scopes_validated = True
if provider.PROVIDER_SCOPES and validated_scopes:
# All of the mandatory scopes must be validated
for scope in provider.PROVIDER_SCOPES:
if scope.mandatory and (
scope.name not in validated_scopes
or validated_scopes[scope.name] is not True
):
mandatory_scopes_validated = False
break
# Otherwise we fail the installation
if not mandatory_scopes_validated:
logger.warning(
"Failed to validate mandatory provider scopes",
extra={"validated_scopes": validated_scopes},
)
raise HTTPException(
status_code=412,
detail=validated_scopes,
)
logger.info(
"Validated provider scopes", extra={"validated_scopes": validated_scopes}
)
return validated_scopes


@router.post(
"/{provider_id}/scopes",
description="Validate provider scopes",
Expand Down Expand Up @@ -422,7 +382,7 @@ def validate_provider_scopes(
session.commit()
logger.info(
"Validated provider scopes",
extra={"provider_id": provider_id, "validated_scopes": validate_scopes},
extra={"provider_id": provider_id, "validated_scopes": validated_scopes},
)
return validated_scopes

Expand Down Expand Up @@ -511,8 +471,8 @@ async def install_provider(
pulling_enabled=pulling_enabled,
)
return JSONResponse(status_code=200, content=result)
except HTTPException as e:
return JSONResponse(status_code=e.status_code, content={"message": e.detail})
except HTTPException:
raise
except Exception as e:
logger.exception("Failed to install provider")
return JSONResponse(status_code=400, content={"message": str(e)})
Expand Down Expand Up @@ -555,7 +515,7 @@ async def install_provider_oauth2(
context_manager, provider_unique_id, provider_type, provider_config
)

validated_scopes = validate_scopes(provider)
validated_scopes = ProvidersService.validate_scopes(provider)

secret_manager = SecretManagerFactory.get_secret_manager(context_manager)
secret_name = f"{tenant_id}_{provider_type}_{provider_unique_id}"
Expand Down
42 changes: 41 additions & 1 deletion keep/providers/providers_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from keep.api.models.provider import Provider as ProviderModel
from keep.contextmanager.contextmanager import ContextManager
from keep.event_subscriber.event_subscriber import EventSubscriber
from keep.providers.base.base_provider import BaseProvider
from keep.providers.providers_factory import ProvidersFactory
from keep.secretmanager.secretmanagerfactory import SecretManagerFactory

Expand All @@ -37,6 +38,45 @@ def get_installed_providers(
def get_linked_providers(tenant_id: str) -> List[ProviderModel]:
return ProvidersFactory.get_linked_providers(tenant_id)

@staticmethod
def validate_scopes(
provider: BaseProvider, validate_mandatory=True
) -> dict[str, bool | str]:
logger.info("Validating provider scopes")
try:
validated_scopes = provider.validate_scopes()
except Exception as e:
logger.exception("Failed to validate provider scopes")
raise HTTPException(
status_code=412,
detail=str(e),
)
if validate_mandatory:
mandatory_scopes_validated = True
if provider.PROVIDER_SCOPES and validated_scopes:
# All of the mandatory scopes must be validated
for scope in provider.PROVIDER_SCOPES:
if scope.mandatory and (
scope.name not in validated_scopes
or validated_scopes[scope.name] is not True
):
mandatory_scopes_validated = False
break
# Otherwise we fail the installation
if not mandatory_scopes_validated:
logger.warning(
"Failed to validate mandatory provider scopes",
extra={"validated_scopes": validated_scopes},
)
raise HTTPException(
status_code=412,
detail=validated_scopes,
)
logger.info(
"Validated provider scopes", extra={"validated_scopes": validated_scopes}
)
return validated_scopes

@staticmethod
def install_provider(
tenant_id: str,
Expand Down Expand Up @@ -73,7 +113,7 @@ def install_provider(
raise HTTPException(status_code=400, detail=str(e))

if validate_scopes:
validated_scopes = provider.validate_scopes()
validated_scopes = ProvidersService.validate_scopes(provider)
else:
validated_scopes = {}

Expand Down
Loading

0 comments on commit 8ef0d80

Please sign in to comment.