Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pingdom Transaction Checks #570

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c0ca1e2
feat(pingdom): add post data field (#1)
karlderkaefer Nov 17, 2023
6efde90
feat: add pingdom transaction checks
karlderkaefer Jan 17, 2024
2c0ed34
feat: add pingdom transaction checks
karlderkaefer Jan 17, 2024
24538dc
Merge branch 'master' into add-pingdom-transaction-checks
karlderkaefer Jan 18, 2024
295032a
feat: generate crds
karlderkaefer Jan 18, 2024
eaf216e
feat: add mapping for step args
karlderkaefer Jan 18, 2024
1e26926
feat: support multiple providers
karlderkaefer Jan 21, 2024
43aac90
fix: optimize log outputs
karlderkaefer Jan 21, 2024
3f1f566
fix: make test compability with macos arm64
karlderkaefer Jan 21, 2024
2d24ee5
fix: update pingdom client to latest tag
karlderkaefer Jan 21, 2024
0ef7381
fix: move util function to utils
karlderkaefer Jan 21, 2024
38289cd
chore: go vet and go fmt
karlderkaefer Jan 21, 2024
b48165f
feat: update CRD for helm chart
karlderkaefer Jan 21, 2024
6b72345
chore: reset helm chart spec
karlderkaefer Jan 21, 2024
24c605b
fix: update golang client
karlderkaefer Jan 21, 2024
a834cea
docs: add readme for pingdom transaction
karlderkaefer Jan 21, 2024
8dff896
chore: update crd
karlderkaefer Jan 21, 2024
d18cdc5
chore: update log output for pingdom
karlderkaefer Jan 22, 2024
2f49d66
fix: logs need key pair values as input
karlderkaefer Jan 22, 2024
ff9d48e
feat: add secret template for sensitive data (#3)
karlderkaefer Jan 26, 2024
c06ff6e
fix: use helm compatible template for secrets
karlderkaefer Jan 30, 2024
8e9a013
Merge branch 'master' into add-pingdom-transaction-checks
karlderkaefer Jun 8, 2024
08fa1fd
chore: update go mod
karlderkaefer Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ vet: ## Run go vet against code.

ENVTEST_ASSETS_DIR = $(shell pwd)/testbin
.PHONY: test
test: generate fmt vet manifests
mkdir -p $(ENVTEST_ASSETS_DIR)
test -f $(ENVTEST_ASSETS_DIR)/setup-envtest.sh || curl -sSLo $(ENVTEST_ASSETS_DIR)/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.6.3/hack/setup-envtest.sh
source $(ENVTEST_ASSETS_DIR)/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -count=1 -coverprofile cover.out
test: generate fmt vet manifests envtest
$(ENVTEST) use -p path 1.28.x!
go test ./... -count=1 -coverprofile cover.out

##@ Build

Expand Down
68 changes: 68 additions & 0 deletions api/v1alpha1/endpointmonitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ type EndpointMonitorSpec struct {
// +optional
PingdomConfig *PingdomConfig `json:"pingdomConfig,omitempty"`

// Configuration for Pingdom Transaction Monitor Provider
// +optional
PingdomTransactionConfig *PingdomTransactionConfig `json:"pingdomTransactionConfig,omitempty"`

// Configuration for AppInsights Monitor Provider
// +optional
AppInsightsConfig *AppInsightsConfig `json:"appInsightsConfig,omitempty"`
Expand Down Expand Up @@ -288,6 +292,70 @@ type PingdomConfig struct {
PostDataEnvVar string `json:"postDataEnvVar,omitempty"`
}

// PingdomTransactionConfig defines the configuration for Pingdom Transaction Monitor Provider
type PingdomTransactionConfig struct {

// Check status: active or inactive
// +optional
Paused bool `json:"paused,omitempty"`

// Custom message that is part of the email and webhook alerts
// +optional
CustomMessage string `json:"custom_message,omitempty"`

// TMS test intervals in minutes. Allowed intervals: 5,10,20,60,720,1440. The interval you're allowed to set may vary depending on your current plan.
// +optional
// +kubebuilder:validation:Enum=5;10;20;60;720;1440
Interval int `json:"interval,omitempty"`

// Name of the region where the check is executed. Supported regions: us-east, us-west, eu, au
// +optional
// +kubebuilder:validation:Enum=us-east;us-west;eu;au
Region string `json:"region,omitempty"`

// Send notification when down X times
SendNotificationWhenDown int64 `json:"send_notification_when_down,omitempty"`

// Check importance- how important are the alerts when the check fails. Allowed values: low, high
// +optional
// +kubebuilder:validation:Enum=low;high
SeverityLevel string `json:"severity_level,omitempty"`

// steps to be executed as part of the check
// +required
Steps []PingdomStep `json:"steps"`

// List of tags for a check. The tag name may contain the characters 'A-Z', 'a-z', '0-9', '_' and '-'. The maximum length of a tag is 64 characters.
Tags []string `json:"tags,omitempty"`

// `-` separated set list of integrations ids (e.g. "91166-12168")
// +optional
AlertIntegrations string `json:"alertIntegrations,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally would prefer a string array here because it's more natural for yaml and users. On the other hand, pingdom user might be used to existing format, What is your opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i myself prefer arrays as well for such conditions, pushed a change recently with array for grafana cloud

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this requires a refactoring. The problem is the alertIntegration, alertContacts and TeamAlerts are defined in Provider struct

AlertContacts string `yaml:"alertContacts"`
AlertIntegrations string `yaml:"alertIntegrations"`
TeamAlertContacts string `yaml:"teamAlertContacts"`

This is used by all provider implementation. Probably string was used to allow more flexible setup and let the parsing upto the specific provider implementation.
I think its fine if we keep string here, also to align to existing pingdom configuration. I would like to do changes here


// `-` separated contact id's (e.g. "1234567_8_9-9876543_2_1")
// +optional
AlertContacts string `json:"alertContacts,omitempty"`

// `-` separated team id's (e.g. "1234567_8_9-9876543_2_1")
// +optional
TeamAlertContacts string `json:"teamAlertContacts,omitempty"`
}

// PingdomStep respresents a step of the script to run a transcaction check
type PingdomStep struct {
// contains the html element with assigned value
// the key element is always lowercase for example {"url": "https://www.pingdom.com"}
// see available values at https://pkg.go.dev/github.com/karlderkaefer/pingdom-golang-client@latest/pkg/pingdom/client/tmschecks#StepArg
// +required
Args map[string]string `json:"args"`
// contains the function that is executed as part of the step
// commands: go_to, click, fill, check, uncheck, sleep, select_radio, basic_auth, submit, wait_for_element, wait_for_contains
// validations: url, exists, not_exists, contains, not_contains, field_contains, field_not_contains, is_checked, is_not_checked, radio_selected, dropdown_selected, dropdown_not_selected
// see updated list https://docs.pingdom.com/api/#section/TMS-Steps-Vocabulary/Script-transaction-checks
// +required
Function string `json:"function"`
}

// AppInsightsConfig defines the configuration for AppInsights Monitor Provider
type AppInsightsConfig struct {
// Returned status code that is counted as a success
Expand Down
54 changes: 54 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,95 @@ spec:
HTTP checks.
type: boolean
type: object
pingdomTransactionConfig:
description: Configuration for Pingdom Transaction Monitor Provider
properties:
alertContacts:
description: '`-` separated contact id''s (e.g. "1234567_8_9-9876543_2_1")'
type: string
alertIntegrations:
description: '`-` separated set list of integrations ids (e.g.
"91166-12168")'
type: string
custom_message:
description: Custom message that is part of the email and webhook
alerts
type: string
interval:
description: 'TMS test intervals in minutes. Allowed intervals:
5,10,20,60,720,1440. The interval you''re allowed to set may
vary depending on your current plan.'
enum:
- 5
- 10
- 20
- 60
- 720
- 1440
type: integer
paused:
description: 'Check status: active or inactive'
type: boolean
region:
description: 'Name of the region where the check is executed.
Supported regions: us-east, us-west, eu, au'
enum:
- us-east
- us-west
- eu
- au
type: string
send_notification_when_down:
description: Send notification when down X times
format: int64
type: integer
severity_level:
description: 'Check importance- how important are the alerts when
the check fails. Allowed values: low, high'
enum:
- low
- high
type: string
steps:
description: steps to be executed as part of the check
items:
description: PingdomStep respresents a step of the script to
run a transcaction check
properties:
args:
additionalProperties:
type: string
description: 'contains the html element with assigned value
the key element is always lowercase for example {"url":
"https://www.pingdom.com"} see available values at https://pkg.go.dev/github.com/karlderkaefer/pingdom-golang-client@latest/pkg/pingdom/client/tmschecks#StepArg'
type: object
function:
description: 'contains the function that is executed as
part of the step commands: go_to, click, fill, check,
uncheck, sleep, select_radio, basic_auth, submit, wait_for_element,
wait_for_contains validations: url, exists, not_exists,
contains, not_contains, field_contains, field_not_contains,
is_checked, is_not_checked, radio_selected, dropdown_selected,
dropdown_not_selected see updated list https://docs.pingdom.com/api/#section/TMS-Steps-Vocabulary/Script-transaction-checks'
type: string
required:
- args
- function
type: object
type: array
tags:
description: List of tags for a check. The tag name may contain
the characters 'A-Z', 'a-z', '0-9', '_' and '-'. The maximum
length of a tag is 64 characters.
items:
type: string
type: array
teamAlertContacts:
description: '`-` separated team id''s (e.g. "1234567_8_9-9876543_2_1")'
type: string
required:
- steps
type: object
providers:
description: Comma separated list of providers
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,95 @@ spec:
HTTP checks.
type: boolean
type: object
pingdomTransactionConfig:
description: Configuration for Pingdom Transaction Monitor Provider
properties:
alertContacts:
description: '`-` separated contact id''s (e.g. "1234567_8_9-9876543_2_1")'
type: string
alertIntegrations:
description: '`-` separated set list of integrations ids (e.g.
"91166-12168")'
type: string
custom_message:
description: Custom message that is part of the email and webhook
alerts
type: string
interval:
description: 'TMS test intervals in minutes. Allowed intervals:
5,10,20,60,720,1440. The interval you''re allowed to set may
vary depending on your current plan.'
enum:
- 5
- 10
- 20
- 60
- 720
- 1440
type: integer
paused:
description: 'Check status: active or inactive'
type: boolean
region:
description: 'Name of the region where the check is executed.
Supported regions: us-east, us-west, eu, au'
enum:
- us-east
- us-west
- eu
- au
type: string
send_notification_when_down:
description: Send notification when down X times
format: int64
type: integer
severity_level:
description: 'Check importance- how important are the alerts when
the check fails. Allowed values: low, high'
enum:
- low
- high
type: string
steps:
description: steps to be executed as part of the check
items:
description: PingdomStep respresents a step of the script to
run a transcaction check
properties:
args:
additionalProperties:
type: string
description: 'contains the html element with assigned value
the key element is always lowercase for example {"url":
"https://www.pingdom.com"} see available values at https://pkg.go.dev/github.com/karlderkaefer/pingdom-golang-client@latest/pkg/pingdom/client/tmschecks#StepArg'
type: object
function:
description: 'contains the function that is executed as
part of the step commands: go_to, click, fill, check,
uncheck, sleep, select_radio, basic_auth, submit, wait_for_element,
wait_for_contains validations: url, exists, not_exists,
contains, not_contains, field_contains, field_not_contains,
is_checked, is_not_checked, radio_selected, dropdown_selected,
dropdown_not_selected see updated list https://docs.pingdom.com/api/#section/TMS-Steps-Vocabulary/Script-transaction-checks'
type: string
required:
- args
- function
type: object
type: array
tags:
description: List of tags for a check. The tag name may contain
the characters 'A-Z', 'a-z', '0-9', '_' and '-'. The maximum
length of a tag is 64 characters.
items:
type: string
type: array
teamAlertContacts:
description: '`-` separated team id''s (e.g. "1234567_8_9-9876543_2_1")'
type: string
required:
- steps
type: object
providers:
description: Comma separated list of providers
type: string
Expand Down
1 change: 1 addition & 0 deletions docs/pingdom-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ spec:
teamAlertContacts: "1234567_8_9-9876543_2_1,1234567_8_9-9876543_2_2"
postDataEnvVar: "monitor-user"
```

Loading
Loading