Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Matvey-Kuk authored Dec 3, 2024
2 parents deb0cf4 + f810f54 commit 32468ea
Show file tree
Hide file tree
Showing 95 changed files with 3,327 additions and 1,582 deletions.
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 }}
2 changes: 0 additions & 2 deletions docker/Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ ENV VIRTUAL_ENV="/venv"
ENV EE_PATH="ee"
COPY --from=builder /venv /venv
COPY --from=builder /app/examples /examples
# Build the providers cache
RUN keep provider build_cache
# 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 && \
chown -R keep:keep /app && \
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/)
22 changes: 13 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 Down Expand Up @@ -49,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 32468ea

Please sign in to comment.