Skip to content

Commit

Permalink
Merge branch 'main' into feat-2538-refactor-builder-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rajesh-jonnalagadda committed Dec 10, 2024
2 parents 8182ae8 + aa11b5d commit 9eef346
Show file tree
Hide file tree
Showing 333 changed files with 10,524 additions and 8,313 deletions.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blank_issues_enabled: true

contact_links:
- name: Support
url: https://github.com/keephq/keep/discussions
about: Get help! Ask questions, get support, and share ideas.

- name: Chat
url: https://slack.keephq.dev
about: Engage with the Keep team and other community members over Slack.

- name: Twitter
url: https://twitter.com/keepalerting
about: Follow us and stay up to date with Keep.
53 changes: 53 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Auto Release on Version Change

on:
push:
branches:
- main
paths:
- "pyproject.toml"

jobs:
check-and-release:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if release exists
id: check_release
run: |
TAG_EXISTS=$(git tag -l "v${{ steps.get_version.outputs.version }}")
if [ -z "$TAG_EXISTS" ]; then
echo "exists=false" >> $GITHUB_OUTPUT
else
echo "exists=true" >> $GITHUB_OUTPUT
fi
- name: Create Release
if: steps.check_release.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ jobs:
run: poetry install --no-interaction --no-root --with dev

- name: Run unit tests and report coverage
run: |
poetry run coverage run --branch -m pytest -n auto --non-integration --ignore=tests/e2e_tests/
- name: Run integration tests and report coverage
run: |
# Add a step to wait for MySQL to be fully up and running
until nc -z 127.0.0.1 3306; do
echo "waiting for MySQL..."
sleep 1
done
echo "MySQL is up and running!"
poetry run coverage run --branch -m pytest --ignore=tests/e2e_tests/
poetry run coverage run --branch -m pytest --integration --ignore=tests/e2e_tests/
- name: Convert coverage results to JSON (for CodeCov support)
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,4 @@ ee/experimental/ai_temp/*
oauth2.cfg
scripts/keep_slack_bot.py
keepnew.db
providers_cache.json
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@
</td>
<td align="center" width="150">
<a href="https://docs.keephq.dev/providers/documentation/uptimekuma-provider" target="_blank">
<img width="40" src="keep-ui/public/icons/uptimekuma-icon.png" alt="UptimeKume"/><br/>
UptimeKume
<img width="40" src="keep-ui/public/icons/uptimekuma-icon.png" alt="UptimeKuma"/><br/>
UptimeKuma
</a>
</td>
<td align="center" width="150">
Expand Down Expand Up @@ -627,7 +627,7 @@ A Keep Workflow is a declarative YAML file that automates your alert and inciden

Here's a simple workflow that creates a Jira ticket for every `critical` alert from `sentry` for `payments` and `api` services.

For more worfklows, see [here](https://github.com/keephq/keep/tree/main/examples/workflows).
For more workflows, see [here](https://github.com/keephq/keep/tree/main/examples/workflows).

```yaml
workflow:
Expand Down
20 changes: 12 additions & 8 deletions docker/Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.6-slim as base
FROM python:3.11.10-slim-bullseye as base

ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
Expand All @@ -17,12 +17,16 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes && /venv/bin/python -m pip install --upgrade -r requirements.txt
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes --only main && \
/venv/bin/python -m pip install --upgrade -r requirements.txt && \
pip uninstall -y poetry
COPY keep keep
COPY ee keep/ee
COPY examples examples
COPY README.md README.md
RUN poetry build && /venv/bin/pip install --use-deprecated=legacy-resolver dist/*.whl
RUN /venv/bin/pip install --use-deprecated=legacy-resolver . && \
rm -rf /root/.cache/pip && \
find /venv -type d -name "__pycache__" -exec rm -r {} + && \
find /venv -type f -name "*.pyc" -delete

FROM base as final
ENV PATH="/venv/bin:${PATH}"
Expand All @@ -31,11 +35,11 @@ ENV EE_PATH="ee"
COPY --from=builder /venv /venv
COPY --from=builder /app/examples /examples
# as per Openshift guidelines, https://docs.openshift.com/container-platform/4.11/openshift_images/create-images.html#use-uid_create-images
RUN chgrp -R 0 /app && chmod -R g=u /app
RUN chown -R keep:keep /app
RUN chown -R keep:keep /venv
RUN chgrp -R 0 /app && chmod -R g=u /app && \
chown -R keep:keep /app && \
chown -R keep:keep /venv
USER keep

ENTRYPOINT ["/venv/lib/python3.11/site-packages/keep/entrypoint.sh"]

CMD ["gunicorn", "keep.api.api:get_app", "--bind" , "0.0.0.0:8080" , "--workers", "4" , "-k" , "uvicorn.workers.UvicornWorker", "-c", "/venv/lib/python3.11/site-packages/keep/api/config.py"]
CMD ["gunicorn", "keep.api.api:get_app", "--bind" , "0.0.0.0:8080" , "--workers", "4" , "-k" , "uvicorn.workers.UvicornWorker", "-c", "/venv/lib/python3.11/site-packages/keep/api/config.py", "--preload"]
12 changes: 6 additions & 6 deletions docs/development/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ code .
{
"version": "2.0.0",
"tasks": [
# The API and UI containers needs to be in the same docker network
// The API and UI containers needs to be in the same docker network
{
"label": "docker-create-network",
"type": "shell",
"command": "docker network create keep-network || true",
"problemMatcher": []
},
# Build the api container
// Build the api container
{
"label": "docker-build-api-dev",
"type": "docker-build",
Expand All @@ -202,7 +202,7 @@ code .
"tag": "keep-api-dev:latest"
}
},
# Run the api container
// Run the api container
{
"label": "docker-run-api-dev",
"type": "docker-run",
Expand Down Expand Up @@ -239,7 +239,7 @@ code .
]
}
},
# Build the UI container
// Build the UI container
{
"label": "docker-build-ui",
"type": "docker-build",
Expand All @@ -249,7 +249,7 @@ code .
"tag": "keep-ui-dev:latest"
}
},
# Run the UI container
// Run the UI container
{
"type": "docker-run",
"label": "docker-run-ui",
Expand All @@ -264,7 +264,7 @@ code .
// Uncomment for fully debug
// "DEBUG": "*",
"NODE_ENV": "development",
"API_URL": "http://keep-api:8080"
"API_URL": "http://keep-api:8080",
"AUTH_TYPE": "SINGLE_TENANT",
},
"volumes": [
Expand Down
90 changes: 23 additions & 67 deletions docs/providers/documentation/grafana_oncall-provider.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
---
title: "Grafana OnCall Provider"
description: "Grafana Oncall Provider is a class that allows to ingest/digest data from Grafana OnCall."
description: "Grafana Oncall Provider is a class that allows to ingest data to the Grafana OnCall."
---

## Inputs

- **title** (required): The title of the incident.
- **roomPrefix** (optional): Prefix for the incident room (default: "incident").
- **labels** (optional): List of labels to associate with the incident (default: ["keep-generated"]).
- **isDrill** (optional): Whether the incident is a drill or not (default: False).
- **severity** (optional): Severity of the incident (default: "minor").
- **status** (optional): Status of the incident (default: "active").
- **attachCaption** (optional): Caption for any attachment.
- **attachURL** (optional): URL for any attachment.
- **incidentID** (optional): ID of an existing incident to update.
- **title** (required): The title of the alert
- **message**: The alert description
- **alert_uid**: Grouping ID which will be used on the OnCall side
- **image_url**: Image URL
- **state**: Either "alerting" or "resolved"
- **link_to_upstream_details**: Link assigned to the alert

## Outputs

Expand All @@ -24,78 +21,37 @@ Grafana Oncall Provider does not currently support the `query` function.
The Grafana Oncall Provider uses API token authentication. You need to provide the following authentication parameters to connect to Grafana OnCall:

- **token** (required): Your Grafana OnCall API Token.
- **host** (required): The URL of your Grafana OnCall host (e.g., https://keephq.grafana.net).
- **host** (required): The URL of your Grafana OnCall host (e.g., https://oncall-prod-us-central-0.grafana.net/oncall/ or http://localhost:8000/) please note that in the Grafana Сloud, oncall's API is under `../oncall/`

## Connecting with the Provider

To connect to Grafana OnCall, you need to create an API Token:

1. Log in to your Grafana OnCall account.
2. Go to the **API Tokens** page.
3. Click the **Generate Token** button and provide a name for your token.
4. Copy the token value and keep it secure.
5. Add the token value to the `authentication` section in the Grafana Oncall Provider configuration.
1. Log in to your Grafana account.
2. Go To "Alerts & IRM" -> OnCall.
3. Go to the **Settings** page.
4. Click the **Create** button and provide a name for your token.
5. Copy the token value and keep it secure.
6. Add the token value to the `authentication` section in the Grafana Oncall Provider configuration.

## Notes

- This provider allows you to interact with Grafana OnCall to create or update incidents.
- The `random_color` function generates a random color for incident labels.
- The `startTime` and `endTime` parameters use ISO-8601 format.
- The `notify` function returns information about the incident created or updated.
- This provider allows you to interact with Grafana OnCall to create alerts.
- Keep will create "Webhook" type integration called "Keep Integration" inside Grafana OnCall.

Payload example:

```json
{
"incident": {
"incidentID": "4",
"severity": "minor",
"labels": [
{
"label": "keep-generated",
"description": "keep-generated",
"colorHex": "#9E0847"
}
],
"isDrill": false,
"createdTime": "2023-09-10T10:31:58.030369Z",
"modifiedTime": "2023-09-10T10:31:58.030369Z",
"createdByUser": {
"userID": "grafana-incident:user-64fd801847a9191105b3c2df",
"name": "Service Account: keep-tests",
"photoURL": "https://www.gravatar.com/avatar/dbb34057685b3bc2bdc2a2808ec80772?s=512&d=retro"
},
"closedTime": "",
"durationSeconds": 0,
"status": "active",
"title": "Test Incident",
"overviewURL": "/a/grafana-incident-app/incidents/4/test-incident",
"roles": [],
"taskList": {
"tasks": [
{
"taskID": "must-choose-severity",
"immutable": true,
"createdTime": "2023-09-10T10:31:58.005917795Z",
"modifiedTime": "2023-09-10T10:31:58.005922353Z",
"text": "Specify incident severity",
"status": "done",
"authorUser": null,
"assignedUser": null
}
],
"todoCount": 0,
"doneCount": 1
},
"summary": "",
"heroImagePath": "/api/hero-images/548564/uoKQrUg5gxteZJ6SdFrMOEhBiN6JtLHLmCSqDzDD0SX93NAhe6ChvhLORmTrSqbC2SEzde7YSKa94UcRsoizm45y3nCGv7eq7Zolk0Y5MzDJrhZRkwrksitQm2eR4iEV/v3/4.png",
"incidentStart": "2023-09-10T10:31:58.030369Z",
"incidentEnd": ""
}
"alert_uid": "08d6891a-835c-e661-39fa-96b6a9e26552",
"title": "The whole system is down",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ee/Grumpy_Cat_by_Gage_Skidmore.jpg",
"state": "alerting",
"link_to_upstream_details": "https://en.wikipedia.org/wiki/Downtime",
"message": "Smth happened. Oh no!"
}
```

## Useful Links

- [Grafana OnCall](https://keephq.grafana.net)
- [Grafana OnCall API Documentation](https://keephq.grafana.net/docs/api)
- [Grafana OnCall Inbound Webhook Integration](https://grafana.com/docs/oncall/latest/configure/integrations/references/webhook/)
23 changes: 14 additions & 9 deletions docs/providers/documentation/pagerduty-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The Pagerduty Provider enables integration with PagerDuty to create, manage, and
- `body`: dict: Body of the incident.
- `requester`: str: Requester of the incident.
- `incident_key`: str | None: Key to identify the incident. If not given, a UUID will be generated.
- `priority`: str | None: Priority of the incident. Only used when creating an incident and when the priority is set. This should be the priority reference ID.

## Authentication Parameters

Expand All @@ -30,6 +31,7 @@ To connect Keep to PagerDuty:

- **Routing Key**: Use for event posting via the PagerDuty Events API.
- **API Key**: Use for incident creation and management through the PagerDuty Incidents API.
- **Service Id** (Optional): If provided, keep operates within the service's scope.
- **OAuth2**: Token management handled automatically by Keep.

<Frame>
Expand All @@ -48,28 +50,31 @@ The api_key is used to create incidents using the incidents API.
### Enabling OAuth in the open-source version

If you would like to use OAuth in the open-source, where you self-host Keep, you can do so by following these step:

1. Create a PagerDuty account
2. In the account page, go to **Integrations** > **App Registration**
<Frame>
<img src="/images/pagerduty-app-registration.png" />
</Frame>
<Frame>
<img src="/images/pagerduty-app-registration.png" />
</Frame>
3. Click on **New App** blue button on the top right
4. Fill in the required fields
5. Select "OAuth 2.0" in the Functionality section and click **Next**
6. In the Redirect URL, you need to add Keep's PagerDuty OAuth2 redirect URL, which is based on your deployments URL. For example, if Keep is deployed at http://localhost:3000, the redirect URL is http://localhost:3000/providers/oauth2/pagerduty
<Frame>
<img src="/images/pagerduty-redirect-url.png" />
</Frame>
<Frame>
<img src="/images/pagerduty-redirect-url.png" />
</Frame>
7. In the Authorization section, select **Scoped OAuth** and select the following scopes:

- Abilities: Read Access
- Incidents: Read/Write Access
- Services: Read/Write Access
- Webhook Subscriptions: Read/Write Access

8. Click on **Register App** blue button on the bottom right
9. Copy the **Client ID** and **Client Secret** from the OAuth 2.0 Client Information modal and set the `PAGERDUTY_CLIENT_ID` and `PAGERDUTY_CLIENT_SECRET` environment variables in your Keep backend deployment.
<Frame>
<img src="/images/pagerduty-oauth2-credentials.png" />
</Frame>
<Frame>
<img src="/images/pagerduty-oauth2-credentials.png" />
</Frame>

## PagerDuty Webhook Integration

Expand Down
Loading

0 comments on commit 9eef346

Please sign in to comment.