Skip to content

Commit d7af042

Browse files
robinderooij-rltomhemmes-rl
authored andcommitted
Add timeout to statuscake endpointmonitor (#7)
* Add timeout to statuscake endpointmonitor StatusCake allows the user to set a timeout. I added it to the configuration to enable users of IngressMonitorController to add/change it as well. --------- Co-authored-by: Tom Hemmes <[email protected]>
1 parent 0a74a4d commit d7af042

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

api/v1alpha1/endpointmonitor_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ type StatusCakeConfig struct {
236236
// UserAgent is used to set a user agent string.
237237
// +optional
238238
UserAgent string `json:"userAgent,omitempty"`
239+
240+
// Timeout is used to set a user agent string.
241+
// +kubebuilder:validation:Maximum=75
242+
// +kubebuilder:validation:Minimum=1
243+
// +optional
244+
Timeout int `json:"timeout,omitempty"`
239245
}
240246

241247
// PingdomConfig defines the configuration for Pingdom Monitor Provider

config/crd/bases/endpointmonitor.stakater.com_endpointmonitors.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ spec:
311311
testType:
312312
description: Set Test type - HTTP, TCP, PING
313313
type: string
314+
timeout:
315+
description: Timeout is used to set a user agent string.
316+
maximum: 75
317+
minimum: 1
318+
type: integer
314319
triggerRate:
315320
description: Minutes to wait before sending an alert
316321
type: integer

docs/statuscake-configuration.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@ The following properties need to be configured for Statuscake, in addition to th
1212

1313
Currently additional Statuscake configurations can be added through these fields:
1414

15-
| Fields | Description |
16-
|:--------------------------------------------------------:|:------------------------------------------------:|
17-
| CheckRate | Set Check Rate for the monitor (default: 300) |
18-
| TestType | Set Test type - HTTP, TCP, PING (default: HTTP) |
19-
| Paused | Pause the service |
20-
| PingURL | Webhook for alerts |
21-
| FollowRedirect | Enable ingress redirects |
22-
| Port | TCP Port |
23-
| TriggerRate | Minutes to wait before sending an alert |
24-
| ContactGroup | Contact Group to be alerted. |
25-
| TestTags | Comma separated list of tags |
26-
| FindString | String to look for within the response |
27-
| BasicAuthUser | Required for [basic-authenticationchecks](#basic-auth-checks) |
28-
| BasicAuthSecret | Allows for an alternate method of adding basic-auth to checks |
29-
| Regions | Regions to execute the check from |
30-
| RawPostData | Add data to change the request to a POST |
31-
| UserAgent | Add a user agent string to the request |
15+
| Fields | Description |
16+
|:---------------:|:---------------------------------------------------------------:|
17+
| CheckRate | Set Check Rate for the monitor (default: 300) |
18+
| TestType | Set Test type - HTTP, TCP, PING (default: HTTP) |
19+
| Paused | Pause the service |
20+
| PingURL | Webhook for alerts |
21+
| FollowRedirect | Enable ingress redirects |
22+
| Port | TCP Port |
23+
| TriggerRate | Minutes to wait before sending an alert |
24+
| ContactGroup | Contact Group to be alerted. |
25+
| TestTags | Comma separated list of tags |
26+
| FindString | String to look for within the response |
27+
| BasicAuthUser | Required for [basic-authenticationchecks](#basic-auth-checks) |
28+
| BasicAuthSecret | Allows for an alternate method of adding basic-auth to checks |
29+
| Regions | Regions to execute the check from |
30+
| RawPostData | Add data to change the request to a POST |
31+
| UserAgent | Add a user agent string to the request |
32+
| Timeout | Timeout for the check in seconds (minimum of 1 and maximum of 75|
3233

3334

3435
### Basic Auth checks

pkg/monitors/statuscake/statuscake-monitor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ func buildUpsertForm(m models.Monitor, cgroup string) url.Values {
240240
if providerConfig != nil && len(providerConfig.UserAgent) > 0 {
241241
f.Add("user_agent", providerConfig.UserAgent)
242242
}
243+
if providerConfig != nil && providerConfig.Timeout > 0 {
244+
f.Add("timeout", strconv.Itoa(providerConfig.Timeout))
245+
}
243246
return f
244247
}
245248

pkg/monitors/statuscake/statuscake-monitor_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func TestBuildUpsertForm(t *testing.T) {
114114
Confirmation: 2,
115115
EnableSSLAlert: true,
116116
FindString: "",
117+
Timeout: 30,
117118

118119
// changed to string array type on statuscake api
119120
// TODO: release new apiVersion to cater new type in apiVersion struct
@@ -143,4 +144,5 @@ func TestBuildUpsertForm(t *testing.T) {
143144
assert.Equal(t, "test,testrun,uptime", convertUrlValuesToString(vals, "tags[]"))
144145
assert.Equal(t, "TCP", vals.Get("test_type"))
145146
assert.Equal(t, "1", vals.Get("trigger_rate"))
147+
assert.Equal(t, "30", vals.Get("timeout"))
146148
}

0 commit comments

Comments
 (0)