Skip to content

Commit efcdc64

Browse files
authored
Fix Sentry Issue Alert action, condition, and filter definitions (#268)
* Update import examples * Follow the shape of the resource definition * Express percentage value as a string * Add notice about omitting the name property * Fix data source test
1 parent 5168fc5 commit efcdc64

File tree

12 files changed

+279
-141
lines changed

12 files changed

+279
-141
lines changed

Diff for: docs/resources/issue_alert.md

+54-25
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "sentry_issue_alert Resource - terraform-provider-sentry"
44
subcategory: ""
55
description: |-
6-
Sentry Issue Alert resource. Note that there's no public documentation for the values of conditions, filters, and actions. You can either inspect the request payload sent when creating or editing an issue alert on Sentry or inspect Sentry's rules registry in the source code https://github.com/getsentry/sentry/tree/master/src/sentry/rules.
6+
Sentry Issue Alert resource. Note that there's no public documentation for the values of conditions, filters, and actions. You can either inspect the request payload sent when creating or editing an issue alert on Sentry or inspect Sentry's rules registry in the source code https://github.com/getsentry/sentry/tree/master/src/sentry/rules. Since v0.11.2, you should also omit the name property of each condition, filter, and action.
77
---
88

99
# sentry_issue_alert (Resource)
1010

11-
Sentry Issue Alert resource. Note that there's no public documentation for the values of conditions, filters, and actions. You can either inspect the request payload sent when creating or editing an issue alert on Sentry or inspect [Sentry's rules registry in the source code](https://github.com/getsentry/sentry/tree/master/src/sentry/rules).
11+
Sentry Issue Alert resource. Note that there's no public documentation for the values of conditions, filters, and actions. You can either inspect the request payload sent when creating or editing an issue alert on Sentry or inspect [Sentry's rules registry in the source code](https://github.com/getsentry/sentry/tree/master/src/sentry/rules). Since v0.11.2, you should also omit the name property of each condition, filter, and action.
1212

1313
## Example Usage
1414

@@ -23,101 +23,131 @@ resource "sentry_issue_alert" "main" {
2323
frequency = 30
2424
2525
conditions = [
26+
# A new issue is created
2627
{
27-
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
28-
name = "A new issue is created"
28+
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
2929
},
30+
31+
# The issue changes state from resolved to unresolved
3032
{
31-
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
32-
name = "The issue changes state from resolved to unresolved"
33+
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
3334
},
35+
36+
# The issue is seen more than 100 times in 1h
3437
{
3538
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
36-
name = "The issue is seen more than 100 times in 1h"
3739
value = 100
3840
comparisonType = "count"
3941
interval = "1h"
4042
},
43+
44+
# The issue is seen by more than 100 users in 1h
4145
{
4246
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
43-
name = "The issue is seen by more than 100 users in 1h"
4447
value = 100
4548
comparisonType = "count"
4649
interval = "1h"
4750
},
51+
52+
# The issue affects more than 50.0 percent of sessions in 1h
4853
{
4954
id = "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
50-
name = "The issue affects more than 50.0 percent of sessions in 1h"
51-
value = 50.0
55+
value = "50.0" # Express the percentage as a string
5256
comparisonType = "count"
5357
interval = "1h"
5458
},
5559
]
5660
5761
filters = [
62+
# The issue is older than 10 minute
5863
{
5964
id = "sentry.rules.filters.age_comparison.AgeComparisonFilter"
60-
name = "The issue is older than 10 minute"
6165
value = 10
6266
time = "minute"
6367
comparison_type = "older"
6468
},
69+
70+
# The issue has happened at least 10 times
6571
{
6672
id = "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter"
67-
name = "The issue has happened at least 10 times"
6873
value = 10
6974
},
75+
76+
# The issue is assigned to Team
7077
{
7178
id = "sentry.rules.filters.assigned_to.AssignedToFilter"
72-
name = "The issue is assigned to Team"
7379
targetType = "Team"
7480
targetIdentifier = sentry_team.main.team_id
7581
},
82+
83+
# The event is from the latest release
7684
{
77-
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
78-
name = "The event is from the latest release"
85+
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
7986
},
87+
88+
# The event's message value contains test
8089
{
8190
id = "sentry.rules.filters.event_attribute.EventAttributeFilter"
82-
name = "The event's message value contains test"
8391
attribute = "message"
8492
match = "co"
8593
value = "test"
8694
},
95+
96+
# The event's tags match test contains test
8797
{
8898
id = "sentry.rules.filters.tagged_event.TaggedEventFilter"
89-
name = "The event's tags match test contains test"
9099
key = "test"
91100
match = "co"
92101
value = "test"
93102
},
103+
104+
# The event's level is equal to fatal
94105
{
95106
id = "sentry.rules.filters.level.LevelFilter"
96-
name = "The event's level is equal to fatal"
97107
match = "eq"
98108
level = "50"
99109
}
100110
]
101111
102112
actions = [
113+
# Send a notification to IssueOwners
103114
{
104115
id = "sentry.mail.actions.NotifyEmailAction"
105-
name = "Send a notification to IssueOwners"
106116
targetType = "IssueOwners"
107117
targetIdentifier = ""
108118
},
119+
120+
# Send a notification to Team
109121
{
110122
id = "sentry.mail.actions.NotifyEmailAction"
111-
name = "Send a notification to Team"
112123
targetType = "Team"
113124
targetIdentifier = sentry_team.main.team_id
114125
},
126+
127+
# Send a notification (for all legacy integrations)
115128
{
116-
id = "sentry.rules.actions.notify_event.NotifyEventAction"
117-
name = "Send a notification (for all legacy integrations)"
118-
}
129+
id = "sentry.rules.actions.notify_event.NotifyEventAction"
130+
},
131+
132+
# Send a notification to the Slack workspace to #general
133+
{
134+
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
135+
channel = "#general"
136+
137+
# From: https://sentry.io/settings/[org-slug]/integrations/slack/[slack-integration-id]/
138+
# Or use the sentry_organization_integration data source to retrieve the integration ID:
139+
workspace = data.sentry_organization_integration.slack.internal_id
140+
},
119141
]
120142
}
143+
144+
# Retrieve a Slack integration
145+
data "sentry_organization_integration" "slack" {
146+
organization = sentry_project.test.organization
147+
148+
provider_key = "slack"
149+
name = "Slack Workspace" # Name of your Slack workspace
150+
}
121151
```
122152

123153
<!-- schema generated by tfplugindocs -->
@@ -151,7 +181,6 @@ Import is supported using the following syntax:
151181

152182
```shell
153183
# import using the organization, project slugs and rule id from the URL:
154-
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
155-
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
184+
# https://sentry.io/organizations/[org-slug]/alerts/rules/[project-slug]/[rule-id]/details/
156185
terraform import sentry_issue_alert.default org-slug/project-slug/rule-id
157186
```

Diff for: docs/resources/metric_alert.md

+2
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,7 @@ Import is supported using the following syntax:
131131
# import using the organization, project slugs and rule id from the URL:
132132
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
133133
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
134+
# or
135+
# https://sentry.io/organizations/[org-slug]/alerts/metric-rules/[project-slug]/[rule-id]/
134136
terraform import sentry_metric_alert.default org-slug/project-slug/rule-id
135137
```

Diff for: examples/resources/sentry_issue_alert/import.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# import using the organization, project slugs and rule id from the URL:
2-
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
3-
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
2+
# https://sentry.io/organizations/[org-slug]/alerts/rules/[project-slug]/[rule-id]/details/
43
terraform import sentry_issue_alert.default org-slug/project-slug/rule-id

Diff for: examples/resources/sentry_issue_alert/resource.tf

+51-21
Original file line numberDiff line numberDiff line change
@@ -8,98 +8,128 @@ resource "sentry_issue_alert" "main" {
88
frequency = 30
99

1010
conditions = [
11+
# A new issue is created
1112
{
12-
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
13-
name = "A new issue is created"
13+
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
1414
},
15+
16+
# The issue changes state from resolved to unresolved
1517
{
16-
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
17-
name = "The issue changes state from resolved to unresolved"
18+
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
1819
},
20+
21+
# The issue is seen more than 100 times in 1h
1922
{
2023
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
21-
name = "The issue is seen more than 100 times in 1h"
2224
value = 100
2325
comparisonType = "count"
2426
interval = "1h"
2527
},
28+
29+
# The issue is seen by more than 100 users in 1h
2630
{
2731
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
28-
name = "The issue is seen by more than 100 users in 1h"
2932
value = 100
3033
comparisonType = "count"
3134
interval = "1h"
3235
},
36+
37+
# The issue affects more than 50.0 percent of sessions in 1h
3338
{
3439
id = "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
35-
name = "The issue affects more than 50.0 percent of sessions in 1h"
36-
value = 50.0
40+
value = "50.0" # Express the percentage as a string
3741
comparisonType = "count"
3842
interval = "1h"
3943
},
4044
]
4145

4246
filters = [
47+
# The issue is older than 10 minute
4348
{
4449
id = "sentry.rules.filters.age_comparison.AgeComparisonFilter"
45-
name = "The issue is older than 10 minute"
4650
value = 10
4751
time = "minute"
4852
comparison_type = "older"
4953
},
54+
55+
# The issue has happened at least 10 times
5056
{
5157
id = "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter"
52-
name = "The issue has happened at least 10 times"
5358
value = 10
5459
},
60+
61+
# The issue is assigned to Team
5562
{
5663
id = "sentry.rules.filters.assigned_to.AssignedToFilter"
57-
name = "The issue is assigned to Team"
5864
targetType = "Team"
5965
targetIdentifier = sentry_team.main.team_id
6066
},
67+
68+
# The event is from the latest release
6169
{
62-
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
63-
name = "The event is from the latest release"
70+
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
6471
},
72+
73+
# The event's message value contains test
6574
{
6675
id = "sentry.rules.filters.event_attribute.EventAttributeFilter"
67-
name = "The event's message value contains test"
6876
attribute = "message"
6977
match = "co"
7078
value = "test"
7179
},
80+
81+
# The event's tags match test contains test
7282
{
7383
id = "sentry.rules.filters.tagged_event.TaggedEventFilter"
74-
name = "The event's tags match test contains test"
7584
key = "test"
7685
match = "co"
7786
value = "test"
7887
},
88+
89+
# The event's level is equal to fatal
7990
{
8091
id = "sentry.rules.filters.level.LevelFilter"
81-
name = "The event's level is equal to fatal"
8292
match = "eq"
8393
level = "50"
8494
}
8595
]
8696

8797
actions = [
98+
# Send a notification to IssueOwners
8899
{
89100
id = "sentry.mail.actions.NotifyEmailAction"
90-
name = "Send a notification to IssueOwners"
91101
targetType = "IssueOwners"
92102
targetIdentifier = ""
93103
},
104+
105+
# Send a notification to Team
94106
{
95107
id = "sentry.mail.actions.NotifyEmailAction"
96-
name = "Send a notification to Team"
97108
targetType = "Team"
98109
targetIdentifier = sentry_team.main.team_id
99110
},
111+
112+
# Send a notification (for all legacy integrations)
100113
{
101-
id = "sentry.rules.actions.notify_event.NotifyEventAction"
102-
name = "Send a notification (for all legacy integrations)"
103-
}
114+
id = "sentry.rules.actions.notify_event.NotifyEventAction"
115+
},
116+
117+
# Send a notification to the Slack workspace to #general
118+
{
119+
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
120+
channel = "#general"
121+
122+
# From: https://sentry.io/settings/[org-slug]/integrations/slack/[slack-integration-id]/
123+
# Or use the sentry_organization_integration data source to retrieve the integration ID:
124+
workspace = data.sentry_organization_integration.slack.internal_id
125+
},
104126
]
105127
}
128+
129+
# Retrieve a Slack integration
130+
data "sentry_organization_integration" "slack" {
131+
organization = sentry_project.test.organization
132+
133+
provider_key = "slack"
134+
name = "Slack Workspace" # Name of your Slack workspace
135+
}

Diff for: examples/resources/sentry_metric_alert/import.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# import using the organization, project slugs and rule id from the URL:
22
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
33
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
4+
# or
5+
# https://sentry.io/organizations/[org-slug]/alerts/metric-rules/[project-slug]/[rule-id]/
46
terraform import sentry_metric_alert.default org-slug/project-slug/rule-id

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/jianyuan/terraform-provider-sentry
33
go 1.19
44

55
require (
6+
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
67
github.com/hashicorp/go-multierror v1.1.1
78
github.com/hashicorp/go-retryablehttp v0.7.2
89
github.com/hashicorp/terraform-plugin-docs v0.13.0
@@ -32,7 +33,6 @@ require (
3233
github.com/hashicorp/errwrap v1.1.0 // indirect
3334
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
3435
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
35-
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
3636
github.com/hashicorp/go-hclog v1.3.1 // indirect
3737
github.com/hashicorp/go-plugin v1.4.6 // indirect
3838
github.com/hashicorp/go-uuid v1.0.3 // indirect

0 commit comments

Comments
 (0)