Skip to content

Commit 790cee8

Browse files
committed
fix(alerting): Update ClickUp alert configuration and default values
1 parent 175de7f commit 790cee8

File tree

3 files changed

+59
-60
lines changed

3 files changed

+59
-60
lines changed

README.md

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -896,63 +896,65 @@ Make sure you have the ability to use `ses:SendEmail`.
896896

897897

898898
#### Configuring ClickUp alerts
899-
| Parameter | Description | Default |
900-
|:-------------------------------------|:-------------------------------------------------------------------------------------------|:--------------|
901-
| `alerting.clickup` | Configuration for alerts of type `clickup` | `{}` |
902-
| `alerting.clickup.list-id` | ClickUp List ID where tasks will be created | Required `""` |
903-
| `alerting.clickup.token` | ClickUp API token | Required `""` |
904-
| `alerting.clickup.api-url` | Custom API URL (optional, defaults to `https://api.clickup.com/api/v2/list/{list-id}/task`) | `""` |
905-
| `alerting.clickup.assignees` | List of user IDs to assign tasks to | `[]` |
906-
| `alerting.clickup.status` | Initial status for created tasks | `""` |
907-
| `alerting.clickup.priority` | Priority level for created tasks (1-4) | `0` |
908-
| `alerting.clickup.name` | Custom task name template (supports placeholders) | `""` |
909-
| `alerting.clickup.content` | Custom task content template (supports placeholders) | `""` |
910-
| `alerting.clickup.default-alert` | Default alert configuration. <br />See [Setting a default alert](#setting-a-default-alert) | N/A |
899+
900+
| Parameter | Description | Default |
901+
| :------------------------------- | :----------------------------------------------------------------------------------------- | :------------ |
902+
| `alerting.clickup` | Configuration for alerts of type `clickup` | `{}` |
903+
| `alerting.clickup.list-id` | ClickUp List ID where tasks will be created | Required `""` |
904+
| `alerting.clickup.token` | ClickUp API token | Required `""` |
905+
| `alerting.clickup.api-url` | Custom API URL | `https://api.clickup.com/api/v2` |
906+
| `alerting.clickup.assignees` | List of user IDs to assign tasks to | `[]` |
907+
| `alerting.clickup.status` | Initial status for created tasks | `""` |
908+
| `alerting.clickup.priority` | Priority level for created tasks (1-4) | `0` |
909+
| `alerting.clickup.name` | Custom task name template (supports placeholders) | `Health Check: [ENDPOINT_GROUP]:[ENDPOINT_NAME]` |
910+
| `alerting.clickup.content` | Custom task content template (supports placeholders) | `Triggered: [ENDPOINT_GROUP] - [ENDPOINT_NAME] - [ALERT_DESCRIPTION] - [RESULT_ERRORS]` |
911+
| `alerting.clickup.default-alert` | Default alert configuration. <br />See [Setting a default alert](#setting-a-default-alert) | N/A |
911912

912913
The ClickUp alerting provider creates tasks in a ClickUp list when alerts are triggered. If `send-on-resolved` is set to `true` on the endpoint alert, the task will be automatically closed when the alert is resolved.
913914

914915
The following placeholders are supported in `name` and `content`:
915-
- `[ENDPOINT_GROUP]` - Resolved from `endpoints[].group`
916-
- `[ENDPOINT_NAME]` - Resolved from `endpoints[].name`
917-
- `[ALERT_DESCRIPTION]` - Resolved from `endpoints[].alerts[].description`
918-
- `[RESULT_ERRORS]` - Resolved from the health evaluation errors
916+
917+
- `[ENDPOINT_GROUP]` - Resolved from `endpoints[].group`
918+
- `[ENDPOINT_NAME]` - Resolved from `endpoints[].name`
919+
- `[ALERT_DESCRIPTION]` - Resolved from `endpoints[].alerts[].description`
920+
- `[RESULT_ERRORS]` - Resolved from the health evaluation errors
919921

920922
```yaml
921923
alerting:
922-
clickup:
923-
list-id: "123456789"
924-
token: "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
925-
assignees:
926-
- "12345"
927-
- "67890"
928-
status: "in progress"
929-
priority: 2
930-
name: "Health Check Alert: [ENDPOINT_GROUP] - [ENDPOINT_NAME]"
931-
content: "Alert triggered for [ENDPOINT_GROUP] - [ENDPOINT_NAME]\n\nDescription: [ALERT_DESCRIPTION]\n\nErrors: [RESULT_ERRORS]"
932-
933-
endpoints:
934-
- name: website
935-
url: "https://twin.sh/health"
936-
interval: 5m
937-
conditions:
938-
- "[STATUS] == 200"
939-
- "[BODY].status == UP"
940-
- "[RESPONSE_TIME] < 300"
941-
alerts:
942-
- type: clickup
943-
failure-threshold: 2
944-
success-threshold: 3
945-
send-on-resolved: true
946-
description: "healthcheck failed"
924+
clickup:
925+
list-id: "123456789"
926+
token: "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
927+
assignees:
928+
- "12345"
929+
- "67890"
930+
status: "in progress"
931+
priority: 2
932+
name: "Health Check Alert: [ENDPOINT_GROUP] - [ENDPOINT_NAME]"
933+
content: "Alert triggered for [ENDPOINT_GROUP] - [ENDPOINT_NAME]\n\nDescription: [ALERT_DESCRIPTION]\n\nErrors: [RESULT_ERRORS]"
934+
935+
endpoints:
936+
- name: website
937+
url: "https://twin.sh/health"
938+
interval: 5m
939+
conditions:
940+
- "[STATUS] == 200"
941+
- "[BODY].status == UP"
942+
- "[RESPONSE_TIME] < 300"
943+
alerts:
944+
- type: clickup
945+
failure-threshold: 2
946+
success-threshold: 3
947+
send-on-resolved: true
948+
description: "healthcheck failed"
947949
```
948950

949951
To get your ClickUp API token follow: [Generate or regenerate a Personal API Token](https://developer.clickup.com/docs/authentication#:~:text=the%20API%20docs.-,Generate%20or%20regenerate%20a%20Personal%20API%20Token,-Log%20in%20to)
950952

951953
To find your List ID:
954+
952955
1. Open the ClickUp list where you want tasks to be created
953956
2. The List ID is in the URL: `https://app.clickup.com/{workspace_id}/v/l/li/{list_id}`
954957

955-
956958
#### Configuring Datadog alerts
957959

958960
> ⚠️ **WARNING**: This alerting provider has not been tested yet. If you've tested it and confirmed that it works, please remove this warning and create a pull request, or comment on [#1223](https://github.com/TwiN/gatus/discussions/1223) with whether the provider works as intended. Thank you for your cooperation.

alerting/provider/clickup/clickup.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ func (cfg *Config) Validate() error {
3838
return ErrTokenNotSet
3939
}
4040
if cfg.APIURL == "" {
41-
cfg.APIURL = "https://api.clickup.com/api/v2/list/" + cfg.ListID + "/task"
41+
cfg.APIURL = "https://api.clickup.com/api/v2"
42+
}
43+
if cfg.Name == "" {
44+
cfg.Name = "Health Check: [ENDPOINT_GROUP]:[ENDPOINT_NAME]"
45+
}
46+
if cfg.MarkdownContent == "" {
47+
cfg.MarkdownContent = "Triggered: [ENDPOINT_GROUP] - [ENDPOINT_NAME] - [ALERT_DESCRIPTION] - [RESULT_ERRORS]"
4248
}
4349
return nil
4450
}
@@ -86,21 +92,11 @@ func (provider *AlertProvider) Send(ep *endpoint.Endpoint, alert *alert.Alert, r
8692
return provider.CloseTask(cfg, ep)
8793
}
8894

89-
name := cfg.Name
90-
if name == "" {
91-
name = "Health Check: [ENDPOINT_GROUP]:[ENDPOINT_NAME]"
92-
}
93-
94-
markdownContent := cfg.MarkdownContent
95-
if markdownContent == "" {
96-
markdownContent = "Triggered: [ENDPOINT_GROUP] - [ENDPOINT_NAME] - [ALERT_DESCRIPTION] - [RESULT_ERRORS]"
97-
}
98-
9995
// Replace placeholders
100-
name = strings.ReplaceAll(name, "[ENDPOINT_GROUP]", ep.Group)
96+
name := strings.ReplaceAll(cfg.Name, "[ENDPOINT_GROUP]", ep.Group)
10197
name = strings.ReplaceAll(name, "[ENDPOINT_NAME]", ep.Name)
10298

103-
markdownContent = strings.ReplaceAll(markdownContent, "[ENDPOINT_GROUP]", ep.Group)
99+
markdownContent := strings.ReplaceAll(cfg.MarkdownContent, "[ENDPOINT_GROUP]", ep.Group)
104100
markdownContent = strings.ReplaceAll(markdownContent, "[ENDPOINT_NAME]", ep.Name)
105101
markdownContent = strings.ReplaceAll(markdownContent, "[ALERT_DESCRIPTION]", alert.GetDescription())
106102
markdownContent = strings.ReplaceAll(markdownContent, "[RESULT_ERRORS]", strings.Join(result.Errors, ", "))
@@ -123,7 +119,8 @@ func (provider *AlertProvider) CreateTask(cfg *Config, body map[string]interface
123119
return err
124120
}
125121

126-
req, err := http.NewRequest("POST", cfg.APIURL, bytes.NewBuffer(jsonBody))
122+
createURL := fmt.Sprintf("%s/list/%s/task", cfg.APIURL, cfg.ListID)
123+
req, err := http.NewRequest("POST", createURL, bytes.NewBuffer(jsonBody))
127124
if err != nil {
128125
return err
129126
}
@@ -145,7 +142,7 @@ func (provider *AlertProvider) CreateTask(cfg *Config, body map[string]interface
145142
}
146143

147144
func (provider *AlertProvider) CloseTask(cfg *Config, ep *endpoint.Endpoint) error {
148-
fetchURL := fmt.Sprintf("https://api.clickup.com/api/v2/list/%s/task?include_closed=false", cfg.ListID)
145+
fetchURL := fmt.Sprintf("%s/list/%s/task?include_closed=false", cfg.APIURL, cfg.ListID)
149146

150147
req, err := http.NewRequest("GET", fetchURL, nil)
151148
if err != nil {
@@ -195,7 +192,7 @@ func (provider *AlertProvider) CloseTask(cfg *Config, ep *endpoint.Endpoint) err
195192
}
196193

197194
func (provider *AlertProvider) UpdateTaskStatus(cfg *Config, taskID, status string) error {
198-
updateURL := fmt.Sprintf("https://api.clickup.com/api/v2/task/%s", taskID)
195+
updateURL := fmt.Sprintf("%s/task/%s", cfg.APIURL, taskID)
199196
body := map[string]interface{}{"status": status}
200197

201198
jsonBody, err := json.Marshal(body)

alerting/provider/clickup/clickup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestAlertProvider_Validate(t *testing.T) {
2626
if err := validProvider.Validate(); err != nil {
2727
t.Error("provider should've been valid")
2828
}
29-
validProviderWithAPIURL := AlertProvider{DefaultConfig: Config{ListID: "test-list-id", Token: "test-token", APIURL: "https://api.clickup.com/api/v2/list/test-list-id/task"}}
29+
validProviderWithAPIURL := AlertProvider{DefaultConfig: Config{ListID: "test-list-id", Token: "test-token", APIURL: "https://api.clickup.com/api/v2"}}
3030
if err := validProviderWithAPIURL.Validate(); err != nil {
3131
t.Error("provider should've been valid")
3232
}
@@ -37,7 +37,7 @@ func TestAlertProvider_ValidateSetsDefaultAPIURL(t *testing.T) {
3737
if err := provider.Validate(); err != nil {
3838
t.Error("provider should've been valid")
3939
}
40-
if provider.DefaultConfig.APIURL != "https://api.clickup.com/api/v2/list/test-list-id/task" {
40+
if provider.DefaultConfig.APIURL != "https://api.clickup.com/api/v2" {
4141
t.Errorf("expected APIURL to be set to default, got %s", provider.DefaultConfig.APIURL)
4242
}
4343
}

0 commit comments

Comments
 (0)