diff --git a/README.md b/README.md index 184900f41..07e6c3b31 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,12 @@ Cilium + + + Checkly
+ Checkly +
+ CloudWatch
diff --git a/docs/images/checkly-provider_1.png b/docs/images/checkly-provider_1.png new file mode 100644 index 000000000..f797b2e03 Binary files /dev/null and b/docs/images/checkly-provider_1.png differ diff --git a/docs/images/checkly-provider_10.png b/docs/images/checkly-provider_10.png new file mode 100644 index 000000000..0628ccd7b Binary files /dev/null and b/docs/images/checkly-provider_10.png differ diff --git a/docs/images/checkly-provider_11.png b/docs/images/checkly-provider_11.png new file mode 100644 index 000000000..4dfa318c6 Binary files /dev/null and b/docs/images/checkly-provider_11.png differ diff --git a/docs/images/checkly-provider_12.png b/docs/images/checkly-provider_12.png new file mode 100644 index 000000000..2fbe5fa68 Binary files /dev/null and b/docs/images/checkly-provider_12.png differ diff --git a/docs/images/checkly-provider_2.png b/docs/images/checkly-provider_2.png new file mode 100644 index 000000000..0ac91e04e Binary files /dev/null and b/docs/images/checkly-provider_2.png differ diff --git a/docs/images/checkly-provider_3.png b/docs/images/checkly-provider_3.png new file mode 100644 index 000000000..e974e1fbb Binary files /dev/null and b/docs/images/checkly-provider_3.png differ diff --git a/docs/images/checkly-provider_4.png b/docs/images/checkly-provider_4.png new file mode 100644 index 000000000..58ae31ad1 Binary files /dev/null and b/docs/images/checkly-provider_4.png differ diff --git a/docs/images/checkly-provider_5.png b/docs/images/checkly-provider_5.png new file mode 100644 index 000000000..3b3946e92 Binary files /dev/null and b/docs/images/checkly-provider_5.png differ diff --git a/docs/images/checkly-provider_6.png b/docs/images/checkly-provider_6.png new file mode 100644 index 000000000..71cc7483a Binary files /dev/null and b/docs/images/checkly-provider_6.png differ diff --git a/docs/images/checkly-provider_7.png b/docs/images/checkly-provider_7.png new file mode 100644 index 000000000..894a5f3c3 Binary files /dev/null and b/docs/images/checkly-provider_7.png differ diff --git a/docs/images/checkly-provider_8.png b/docs/images/checkly-provider_8.png new file mode 100644 index 000000000..1f46abf61 Binary files /dev/null and b/docs/images/checkly-provider_8.png differ diff --git a/docs/images/checkly-provider_9.png b/docs/images/checkly-provider_9.png new file mode 100644 index 000000000..c9205b53f Binary files /dev/null and b/docs/images/checkly-provider_9.png differ diff --git a/docs/mint.json b/docs/mint.json index 53b41543e..f90c61e29 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -137,6 +137,7 @@ "providers/documentation/bigquery-provider", "providers/documentation/centreon-provider", "providers/documentation/checkmk-provider", + "providers/documentation/checkly-provider", "providers/documentation/cilium-provider", "providers/documentation/clickhouse-provider", "providers/documentation/cloudwatch-provider", diff --git a/docs/providers/documentation/checkly-provider.mdx b/docs/providers/documentation/checkly-provider.mdx new file mode 100644 index 000000000..19a502f3c --- /dev/null +++ b/docs/providers/documentation/checkly-provider.mdx @@ -0,0 +1,124 @@ +--- +title: 'Checkly' +sidebarTitle: 'Checkly Provider' +description: 'StatusCake allows you to receive alerts from Checkly using API endpoints as well as webhooks' +--- + +## Authentication Parameters + +The Checkly provider offers two ways to authenticate: + +- `Checkly API Key` - This is the API key created in the User Settings of your Checkly account and is used to authenticate requests to the Checkly API. +- `Checkly Account ID` - This is the account ID of your Checkly account. + +## Connecting Checkly to Keep + +1. Open Checkly dashboard and click on your profile picture in the top right corner. + +2. Click on `User Settings`. + + + + + +3. Open the `API Keys` tab and click on `Create API Key` to generate a new API key. + + + + + +4. Copy the API key. + +5. Open `General` tab under Account Settings and copy the `Account ID`. + + + + + +6. Go to Keep, add Checkly as a provider and enter the API key and Account ID in the respective fields and click on `Connect`. + +## Webhooks Integration + +1. Open Checkly dashboard and open `Alerts` tab in the left sidebar. + + + + + +2. Click on `Add more channels` + + + + + +3. Select `Webhook` from the list of available channels. + + + + + +4. Enter a name for the webhook, select the method as `POST` + +5. Enter [https://api.keephq.dev/alerts/event/checkly](https://api.keephq.dev/alerts/event/checkly) as the URL. + +6. Copy the below snippet and paste in the `Body` of Webhook. Refer the screenshot below for reference. + +```json +{ + "event": "{{ALERT_TITLE}}", + "alert_type": "{{ALERT_TYPE}}", + "check_name": "{{CHECK_NAME}}", + "group_name": "{{GROUP_NAME}}", + "check_id": "{{CHECK_ID}}", + "check_type": "{{CHECK_TYPE}}", + "check_result_id": "{{CHECK_RESULT_ID}}", + "check_error_message": "{{CHECK_ERROR_MESSAGE}}", + "response_time": "{{RESPONSE_TIME}}", + "api_check_response_status_code": "{{API_CHECK_RESPONSE_STATUS_CODE}}", + "api_check_response_status_text": "{{API_CHECK_RESPONSE_STATUS_TEXT}}", + "run_location": "{{RUN_LOCATION}}", + "ssl_days_remaining": "{{SSL_DAYS_REMAINING}}", + "ssl_check_domain": "{{SSL_CHECK_DOMAIN}}", + "started_at": "{{STARTED_AT}}", + "tags": "{{TAGS}}", + "link": "{{RESULT_LINK}}", + "region": "{{REGION}}", + "uuid": "{{$UUID}}" +} +``` + + + + + +8. Go to Headers tab and add a new header with key as `X-API-KEY` and create a new API key in Keep and paste it as the value and save the webhook. + + + + + +9. Follow the below steps to create a new API key in Keep. + +7. Go to Keep dashboard and click on the profile icon in the botton left corner and click `Settings`. + + + + + +8. Select `Users and Access` tab and then select `API Keys` tab and create a new API key. + + + + + +9. Give name and select the role as `webhook` and click on `Create API Key`. + + + + + +10. Use the generated API key in the `X-API-KEY` header of the webhook created in Checkly. + +## Useful Links + +- [Checkly Website](https://www.checklyhq.com/) diff --git a/docs/providers/overview.mdx b/docs/providers/overview.mdx index 5f8b47146..53a16c3c7 100644 --- a/docs/providers/overview.mdx +++ b/docs/providers/overview.mdx @@ -84,6 +84,12 @@ By leveraging Keep Providers, users are able to deeply integrate Keep with the t icon={ } > + } +> + list[AlertDto]: + """ + Get alerts from Checkly. + """ + self.logger.info("Getting alerts from Checkly") + alerts = self.__get_paginated_data() + return [ + AlertDto( + id=alert["id"], + name=alert["name"], + status=ChecklyProvider.STATUS_MAP[alert["alertType"]], + severity=ChecklyProvider.SEVERITY_MAP[alert["alertType"]], + lastReceivedAt=alert["created_at"], + alertType=alert["alertType"], + checkId=alert["checkId"], + checkType=alert["checkType"], + runLocation=alert["runLocation"], + responseTime=alert["responseTime"], + error=alert["error"], + statusCode=alert["statusCode"], + created_at=alert["created_at"], + startedAt=alert["startedAt"], + source=["checkly"] + ) for alert in alerts + ] + + @staticmethod + def _format_alert( + event: dict, provider_instance: "BaseProvider" = None + ) -> AlertDto | list[AlertDto]: + alert = AlertDto( + id=event["uuid"], + name=event["check_name"], + description=event["event"], + status=ChecklyProvider.STATUS_MAP[event["alert_type"]], + severity=ChecklyProvider.SEVERITY_MAP[event["alert_type"]], + lastReceived=event["started_at"], + alertType=event["alert_type"], + groupName=event["group_name"], + checkId=event["check_id"], + checkType=event["check_type"], + checkResultId=event["check_result_id"], + checkErrorMessage=event["check_error_message"], + responseTime=event["response_time"], + apiCheckResponseStatus=event["api_check_response_status_code"], + apiCheckResponseStatusText=event["api_check_response_status_text"], + runLocation=event["run_location"], + sslDaysRemaining=event["ssl_days_remaining"], + sslCheckDomain=event["ssl_check_domain"], + startedAt=event["started_at"], + tags=event["tags"], + url=event["link"], + region=event["region"], + source=["checkly"] + ) + + return alert + + + def __get_auth_headers(self): + return { + "Authorization": f"Bearer {self.authentication_config.checklyApiKey}", + "X-Checkly-Account": self.authentication_config.accountId, + "accept": "application/json" + } + + def __get_paginated_data(self, query_params: dict = {}) -> list: + data = [] + page = 1 + + while True: + self.logger.info(f"Getting data from page {page}") + query_params["page"] = page + try: + url = self.__get_url(query_params) + headers = self.__get_auth_headers() + response = requests.get(url, headers=headers) + response.raise_for_status() + page_data = response.json() + if not page_data: + break + self.logger.info(f"Got {len(page_data)} data from page {page}") + data.extend(page_data) + page += 1 + except Exception as e: + self.logger.error(f"Error getting data from page {page}: {e}") + break + return data + + def __get_url(self, query_params: dict = {}): + url = "https://api.checklyhq.com/v1/check-alerts" + if query_params: + url += "?" + for key, value in query_params.items(): + url += f"{key}={value}&" + url = url[:-1] + return url + +if __name__ == "__main__": + import logging + + logging.basicConfig(level=logging.DEBUG, handlers=[logging.StreamHandler()]) + context_manager = ContextManager( + tenant_id="singletenant", + workflow_id="test", + ) + + import os + + checkly_api_key = os.getenv("CHECKLY_API_KEY") + checkly_account_id = os.getenv("CHECKLY_ACCOUNT_ID") + + config = ProviderConfig( + description="Checkly Provider", + authentication={ + "checklyApiKey": checkly_api_key, + "accountId": checkly_account_id, + } + ) + + provider = ChecklyProvider(context_manager, "checkly", config) + + alerts = provider.get_alerts() + print(alerts)