Skip to content

Commit

Permalink
feat: add comparison delta to metric alert (#36)
Browse files Browse the repository at this point in the history
* feat: add comparisonDelta to metric alert

* refactor: minor improvement in naming

* fix: minor typo in comparison_delta description

* feat: upgrade go-sentry to v1.4.1
  • Loading branch information
taj-p authored Jul 25, 2022
1 parent ed88c94 commit 43a3f19
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 287 deletions.
4 changes: 4 additions & 0 deletions docs/data-sources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ resource "sentry_metric_alert" "copy" {
- `organization` (String) The slug of the organization the metric alert belongs to.
- `project` (String) The slug of the project the metric alert belongs to.

### Optional

- `comparison_delta` (Number) The number of minutes in the past to compare this metric to. For example, if our time window is 10 minutes, our trigger is a 10% increase in errors, and `comparison_delta = 10080`, we would trigger this metric if we experienced a 10% increase in errors compared to this time 1 week ago in 10 minute intervals.Omitting this field implies that the triggers are for static, rather than percentage change, triggers (e.g. alert when error count is over 1000 rather than alert when error count is 20% higher than this time `comparison_delta` minutes ago).

### Read-Only

- `aggregate` (String)
Expand Down
5 changes: 4 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ provider "sentry" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `token` (String, Sensitive) The authentication token used to connect to Sentry. The value can be sourced from the `SENTRY_AUTH_TOKEN` environment variable.

### Optional

- `base_url` (String) The target Sentry Base API URL in the format `https://[hostname]/api/`. The default value is `https://sentry.io/api/`. The value must be provided when working with Sentry On-Premise. The value can be sourced from the `SENTRY_BASE_URL` environment variable.
- `token` (String, Sensitive) The authentication token used to connect to Sentry. The value can be sourced from the `SENTRY_AUTH_TOKEN` environment variable.



Expand Down
3 changes: 3 additions & 0 deletions docs/resources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ resource "sentry_metric_alert" "main" {
query = ""
aggregate = "count()"
time_window = 60
comparison_delta = 10080
threshold_type = 0
resolve_threshold = 0
Expand Down Expand Up @@ -59,6 +60,8 @@ resource "sentry_metric_alert" "main" {

### Optional

- `comparison_delta` (Number) The number of minutes in the past to compare this metric to. For example, if our time window is 10 minutes, our trigger is a 10% increase in errors, and `comparison_delta = 10080`, we would trigger this metric if we experienced a 10% increase in errors compared to this time 1 week ago in 10 minute intervals. Omitting this field implies that the triggers are for static, rather than percentage change, triggers (e.g. alert when error count is over 1000 rather than alert when error count is 20% higher than this time `comparison_delta` minutes ago).
Values must be one of: 5, 15, 60 (for one hour), 1440 (for one day), 10080 (for one week), or 43200 (for one month).
- `dataset` (String) The Sentry Alert category
- `environment` (String) Perform Alert rule in a specific environment
- `owner` (String) Specifies the owner id of this Alert rule
Expand Down
7 changes: 6 additions & 1 deletion docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ resource "sentry_project" "default" {

- `name` (String) The name for the project.
- `organization` (String) The slug of the organization the project belongs to.
- `team` (String) The slug of the team to create the project for.

### Optional

- `allowed_domains` (Set of String) The domains allowed to be collected
- `digests_max_delay` (Number) The maximum amount of time (in seconds) to wait between scheduling digests for delivery.
- `digests_min_delay` (Number) The minimum amount of time (in seconds) to wait between scheduling digests for delivery after the initial scheduling.
- `grouping_enhancements` (String) Grouping enhancements pattern
- `platform` (String) The optional platform for this project.
- `remove_default_key` (Boolean) Whether to remove the default key
- `remove_default_rule` (Boolean) Whether to remove the default rule
- `resolve_age` (Number) Hours in which an issue is automatically resolve if not seen after this amount of time.
- `slug` (String) The optional slug for this project.
- `team` (String, Deprecated) The slug of the team to create the project for. One of 'team' or 'teams' must be set.
- `teams` (Set of String) The slugs of the teams to create the project for. One of 'team' or 'teams' must be set.

### Read-Only

Expand Down
1 change: 1 addition & 0 deletions examples/resources/sentry_metric_alert/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resource "sentry_metric_alert" "main" {
query = ""
aggregate = "count()"
time_window = 60
comparison_delta = 10080
threshold_type = 0
resolve_threshold = 0

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ module github.com/canva/terraform-provider-sentry

go 1.18

replace github.com/jianyuan/go-sentry/v2 => github.com/canva/go-sentry v1.4.0
replace github.com/jianyuan/go-sentry/v2 => github.com/canva/go-sentry v1.4.1

require (
github.com/google/go-cmp v0.5.8
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/hashicorp/terraform-plugin-docs v0.12.0
github.com/hashicorp/terraform-plugin-log v0.4.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0
github.com/jianyuan/go-sentry/v2 v2.0.0-20220629201240-cd06bb8f98b9
github.com/mitchellh/mapstructure v1.5.0
golang.org/x/oauth2 v0.0.0-20220630143837-2104d58473e0
)
Expand All @@ -26,13 +29,11 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-plugin v1.4.4 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand All @@ -48,7 +49,6 @@ require (
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jianyuan/go-sentry/v2 v2.0.0-20220629201240-cd06bb8f98b9 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/cli v1.1.4 // indirect
Expand Down
Loading

0 comments on commit 43a3f19

Please sign in to comment.