|
| 1 | +--- |
| 2 | +title: "GitHub Application" |
| 3 | +sidebarTitle: "GitHub" |
| 4 | +description: "The Keep GitHub Application is a powerful tool that enhances your workflow by monitoring file changes under the parent `.keep/` directory in your repositories' pull requests. It automates the process of generating AI-generated alerts from plain English and allows you to seamlessly deploy these alerts to your provider using comments." |
| 5 | +--- |
| 6 | + |
| 7 | +## Getting Started |
| 8 | + |
| 9 | +To start using the Keep GitHub Application, follow these simple steps: |
| 10 | + |
| 11 | +1. Sign up and log in to the **[Keep's platform](https://platform.keephq.dev)**. |
| 12 | +2. Install the **Keep GitHub Application** either through the onboarding screen or by visiting **[this link](https://github.com/apps/keephq)**. The installation process is straightforward and user-friendly. |
| 13 | + |
| 14 | + <Frame> |
| 15 | + <img src="/images/github-app-install.png" /> |
| 16 | + </Frame> |
| 17 | + |
| 18 | +3. Connect your preferred provider, such as Datadog, by linking it to Keep's platform. This step allows Keep to seamlessly generate and deploy alerts to your chosen provider. |
| 19 | + |
| 20 | + <Frame> |
| 21 | + <img src="/images/connect-provider.png" /> |
| 22 | + </Frame> |
| 23 | + |
| 24 | +4. You are now ready to go! The Keep GitHub Application is successfully integrated into your GitHub workflow. |
| 25 | + |
| 26 | +## How does it work? |
| 27 | + |
| 28 | +The Keep GitHub Application operates seamlessly in the background, ensuring that you stay informed about relevant changes in your repositories. Whenever a pull request is opened or updated, the application monitors the files under the .keep/ directory. |
| 29 | + |
| 30 | +Once a change is detected, the GitHub application sends an HTTP request to Keep's API smart AI layer. The AI layer analyzes the content of the changed files and together with context from the provider (existing alerts, sample logs, etc.) generates an alert based on the user provided plain English description. The AI-powered alert generation ensures accuracy and relevance. |
| 31 | + |
| 32 | +After the alert is generated, the Keep GitHub Application automatically comments the alert on the respective file within the pull request. This allows you, as the user, to conveniently review and verify the generated alert. |
| 33 | + |
| 34 | +If the generated alert meets your requirements and is ready to be deployed, you can simply leave a comment on the file. The comment should include one of the predefined emojis, such as 🚀 or 🆗 (refer to the ["Deploying Alerts with Emojis"](#deploying-alerts-with-emojis) section). The Keep GitHub Application recognizes these emojis as commands to proceed with the deployment process. |
| 35 | + |
| 36 | +This intuitive workflow streamlines the alert generation and deployment process, providing you with a seamless experience and allowing you to focus on the core aspects of your project. |
| 37 | + |
| 38 | +## Monitoring Files Under .keep/ Directory |
| 39 | + |
| 40 | +The Keep GitHub Application actively monitors the files residing within the `.keep/` directory located at the parent level of your repository. Any changes or updates made to these files will trigger the alert generation process. This allows you to focus on the essential aspects of your project while ensuring that relevant changes are promptly identified and acted upon. |
| 41 | + |
| 42 | +## Alert File Structure |
| 43 | + |
| 44 | +Each file under the `.keep/` directory represents a single alert. The structure of an alert file follows the YAML format. Below is an example of an alert file: |
| 45 | + |
| 46 | +```yaml title=alert-example.yaml |
| 47 | +# The alert text in plain English |
| 48 | +alert: | |
| 49 | + Count the error rate (4xx-5xx) this service has in the last 10 minutes. |
| 50 | + Alert when the threshold is above 5% out of total requests. |
| 51 | + Send a Slack message to the #alerts-playground channel and include all the context you have" |
| 52 | +
|
| 53 | +# The provider you've previously connected and want this alert to be generated for |
| 54 | +provider: datadog |
| 55 | +# You can use this to override Keep's managed API and have the GitHub application |
| 56 | +# use the API that you run locally (using the NGROK URL) |
| 57 | +# api_url: https://OVERRIDE-KEEP-MANAGED-API |
| 58 | +``` |
| 59 | + |
| 60 | +The alert file consists of the following components: |
| 61 | + |
| 62 | +1. **Alert Text**: This section contains the plain English description of the alert. Write a clear and concise explanation of the conditions or criteria that should trigger the alert. You can include any relevant context to facilitate understanding and resolution. |
| 63 | + |
| 64 | +2. **Provider**: Specify the provider to which you want the alert to be generated. This ensures that the alert seamlessly integrates with your existing monitoring and notification infrastructure. In the example above, the alert is configured to be generated for Datadog. |
| 65 | + |
| 66 | +3. **API Override**: Optionally, you can include the api_url field to override Keep's managed API. This allows you to use your locally hosted API for advanced customization and integration purposes. |
| 67 | + |
| 68 | +<Accordion title="ngrok"> |
| 69 | + **ngrok?** |
| 70 | + |
| 71 | +Imagine you have a secret hideout in your backyard, but you don't want anyone to know where it is. So, you build a tunnel from your hideout to a tree in your friend's backyard. This way, you can go into the tunnel in your yard and magically come out at the tree in your friend's yard. |
| 72 | + |
| 73 | +Now, let's say you have a cool website or a game that you want to show your friend, but it's running on your computer at home. Your friend is far away and can't come to your house. So, you need a way to show them your website or game over the internet. |
| 74 | + |
| 75 | +This is where ngrok comes in! Ngrok is like a magical tunnel, just like the one you built in your backyard. It creates a secure connection between your computer and the internet. It gives your computer a special address that people can use to reach your website or game, even though it's on your computer at home. |
| 76 | + |
| 77 | +When you start ngrok, it opens up a tunnel between your computer and the internet. It assigns a special address to your computer, like a secret door to your website or game. When your friend enters that address in their web browser, it's as if they're walking through the tunnel and reaching your website or game on your computer. |
| 78 | + |
| 79 | +So, ngrok is like a magical tunnel that helps you share your website or game with others over the internet, just like the secret tunnel you built to reach your friend's backyard! |
| 80 | + |
| 81 | +**How to start Keep with ngrok** |
| 82 | + |
| 83 | +ngrok is Controlled with the `USE_NGROK` environment variable.<br /> |
| 84 | +Simply run Keep's API using the following command to start with ngrok: `USE_NGROK=true keep api` |
| 85 | + |
| 86 | +{" "} |
| 87 | +<Note> |
| 88 | + `USE_NGROK` is enabled by default when running with `docker-compose` |
| 89 | +</Note> |
| 90 | + |
| 91 | +**How to obtain ngrok URL?** |
| 92 | + |
| 93 | +When `USE_NGROK` is set, Keep will start with ngrok in the background. <br /> |
| 94 | +You can find your private ngrok URL looking for this log line "`ngrok tunnel`": |
| 95 | + |
| 96 | + ```json |
| 97 | + { |
| 98 | + "asctime": "0000-00-00 00:00:00,000", |
| 99 | + "message": "ngrok tunnel: https://fab5-213-57-123-130.ngrok.io", |
| 100 | + ... |
| 101 | + } |
| 102 | + ``` |
| 103 | + |
| 104 | +The URL (https://fab5-213-57-123-130.ngrok.io in the example above) is a publicly accessible URL to your Keep API service running locally. <br /> |
| 105 | + |
| 106 | +{" "} |
| 107 | +<Note> |
| 108 | + You can check that the ngrok tunnel is working properly by sending a simple |
| 109 | + HTTP GET request to `/healthcheck` Try: `curl -v |
| 110 | + https://fab5-213-57-123-130.ngrok.io/healthcheck` in our example. |
| 111 | +</Note> |
| 112 | + |
| 113 | +</Accordion> |
| 114 | + |
| 115 | +## Deploying Alerts with Emojis |
| 116 | + |
| 117 | +To deploy an alert to the specified provider, you can simply leave a comment on the respective file using the 🚀 or 🆗 emojis. The Keep GitHub Application recognizes these emojis as commands and will initiate the deployment process accordingly. This streamlined approach ensures a smooth and intuitive experience when deploying alerts. |
| 118 | + |
| 119 | +For example, by leaving a comment with the 🚀 emoji, you can signal the Keep GitHub Application to deploy the alert to the specified provider (Datadog in our example above). |
| 120 | + |
| 121 | +<Frame> |
| 122 | + <img src="/images/first-alert.yaml.png" /> |
| 123 | +</Frame> |
| 124 | + |
| 125 | +The Keep GitHub Application will either mark the comment with 👍 meaning the alert was successfully deployed or 👎 and another comment with the failure reason in case the alert was not deployed. |
| 126 | + |
| 127 | +<Info> |
| 128 | + Keep GitHub Application has a retry mechanism that automatically tries to fix |
| 129 | + the alert in case it was not successfully deployed to the provider. If the |
| 130 | + alert that is deployed is different from the originally generated one, Keep |
| 131 | + Github Application will comment the updated one once again. |
| 132 | +</Info> |
0 commit comments