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

Fix Sentry Issue Alert action, condition, and filter definitions #268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 54 additions & 25 deletions docs/resources/issue_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "sentry_issue_alert Resource - terraform-provider-sentry"
subcategory: ""
description: |-
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.
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.
---

# sentry_issue_alert (Resource)

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).
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.

## Example Usage

Expand All @@ -23,101 +23,131 @@ resource "sentry_issue_alert" "main" {
frequency = 30

conditions = [
# A new issue is created
{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
name = "A new issue is created"
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},

# The issue changes state from resolved to unresolved
{
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
name = "The issue changes state from resolved to unresolved"
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
},

# The issue is seen more than 100 times in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
name = "The issue is seen more than 100 times in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},

# The issue is seen by more than 100 users in 1h
{
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
name = "The issue is seen by more than 100 users in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},

# The issue affects more than 50.0 percent of sessions in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
name = "The issue affects more than 50.0 percent of sessions in 1h"
value = 50.0
value = "50.0" # Express the percentage as a string
comparisonType = "count"
interval = "1h"
},
]

filters = [
# The issue is older than 10 minute
{
id = "sentry.rules.filters.age_comparison.AgeComparisonFilter"
name = "The issue is older than 10 minute"
value = 10
time = "minute"
comparison_type = "older"
},

# The issue has happened at least 10 times
{
id = "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter"
name = "The issue has happened at least 10 times"
value = 10
},

# The issue is assigned to Team
{
id = "sentry.rules.filters.assigned_to.AssignedToFilter"
name = "The issue is assigned to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},

# The event is from the latest release
{
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
name = "The event is from the latest release"
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
},

# The event's message value contains test
{
id = "sentry.rules.filters.event_attribute.EventAttributeFilter"
name = "The event's message value contains test"
attribute = "message"
match = "co"
value = "test"
},

# The event's tags match test contains test
{
id = "sentry.rules.filters.tagged_event.TaggedEventFilter"
name = "The event's tags match test contains test"
key = "test"
match = "co"
value = "test"
},

# The event's level is equal to fatal
{
id = "sentry.rules.filters.level.LevelFilter"
name = "The event's level is equal to fatal"
match = "eq"
level = "50"
}
]

actions = [
# Send a notification to IssueOwners
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to IssueOwners"
targetType = "IssueOwners"
targetIdentifier = ""
},

# Send a notification to Team
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},

# Send a notification (for all legacy integrations)
{
id = "sentry.rules.actions.notify_event.NotifyEventAction"
name = "Send a notification (for all legacy integrations)"
}
id = "sentry.rules.actions.notify_event.NotifyEventAction"
},

# Send a notification to the Slack workspace to #general
{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#general"

# From: https://sentry.io/settings/[org-slug]/integrations/slack/[slack-integration-id]/
# Or use the sentry_organization_integration data source to retrieve the integration ID:
workspace = data.sentry_organization_integration.slack.internal_id
},
]
}

# Retrieve a Slack integration
data "sentry_organization_integration" "slack" {
organization = sentry_project.test.organization

provider_key = "slack"
name = "Slack Workspace" # Name of your Slack workspace
}
```

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

```shell
# import using the organization, project slugs and rule id from the URL:
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/[project-slug]/[rule-id]/details/
terraform import sentry_issue_alert.default org-slug/project-slug/rule-id
```
2 changes: 2 additions & 0 deletions docs/resources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ Import is supported using the following syntax:
# import using the organization, project slugs and rule id from the URL:
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
# or
# https://sentry.io/organizations/[org-slug]/alerts/metric-rules/[project-slug]/[rule-id]/
terraform import sentry_metric_alert.default org-slug/project-slug/rule-id
```
3 changes: 1 addition & 2 deletions examples/resources/sentry_issue_alert/import.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# import using the organization, project slugs and rule id from the URL:
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/[project-slug]/[rule-id]/details/
terraform import sentry_issue_alert.default org-slug/project-slug/rule-id
72 changes: 51 additions & 21 deletions examples/resources/sentry_issue_alert/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,128 @@ resource "sentry_issue_alert" "main" {
frequency = 30

conditions = [
# A new issue is created
{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
name = "A new issue is created"
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},

# The issue changes state from resolved to unresolved
{
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
name = "The issue changes state from resolved to unresolved"
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
},

# The issue is seen more than 100 times in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
name = "The issue is seen more than 100 times in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},

# The issue is seen by more than 100 users in 1h
{
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
name = "The issue is seen by more than 100 users in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},

# The issue affects more than 50.0 percent of sessions in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
name = "The issue affects more than 50.0 percent of sessions in 1h"
value = 50.0
value = "50.0" # Express the percentage as a string
comparisonType = "count"
interval = "1h"
},
]

filters = [
# The issue is older than 10 minute
{
id = "sentry.rules.filters.age_comparison.AgeComparisonFilter"
name = "The issue is older than 10 minute"
value = 10
time = "minute"
comparison_type = "older"
},

# The issue has happened at least 10 times
{
id = "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter"
name = "The issue has happened at least 10 times"
value = 10
},

# The issue is assigned to Team
{
id = "sentry.rules.filters.assigned_to.AssignedToFilter"
name = "The issue is assigned to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},

# The event is from the latest release
{
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
name = "The event is from the latest release"
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
},

# The event's message value contains test
{
id = "sentry.rules.filters.event_attribute.EventAttributeFilter"
name = "The event's message value contains test"
attribute = "message"
match = "co"
value = "test"
},

# The event's tags match test contains test
{
id = "sentry.rules.filters.tagged_event.TaggedEventFilter"
name = "The event's tags match test contains test"
key = "test"
match = "co"
value = "test"
},

# The event's level is equal to fatal
{
id = "sentry.rules.filters.level.LevelFilter"
name = "The event's level is equal to fatal"
match = "eq"
level = "50"
}
]

actions = [
# Send a notification to IssueOwners
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to IssueOwners"
targetType = "IssueOwners"
targetIdentifier = ""
},

# Send a notification to Team
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},

# Send a notification (for all legacy integrations)
{
id = "sentry.rules.actions.notify_event.NotifyEventAction"
name = "Send a notification (for all legacy integrations)"
}
id = "sentry.rules.actions.notify_event.NotifyEventAction"
},

# Send a notification to the Slack workspace to #general
{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#general"

# From: https://sentry.io/settings/[org-slug]/integrations/slack/[slack-integration-id]/
# Or use the sentry_organization_integration data source to retrieve the integration ID:
workspace = data.sentry_organization_integration.slack.internal_id
},
]
}

# Retrieve a Slack integration
data "sentry_organization_integration" "slack" {
organization = sentry_project.test.organization

provider_key = "slack"
name = "Slack Workspace" # Name of your Slack workspace
}
2 changes: 2 additions & 0 deletions examples/resources/sentry_metric_alert/import.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# import using the organization, project slugs and rule id from the URL:
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
# or
# https://sentry.io/organizations/[org-slug]/alerts/metric-rules/[project-slug]/[rule-id]/
terraform import sentry_metric_alert.default org-slug/project-slug/rule-id
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/jianyuan/terraform-provider-sentry
go 1.19

require (
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.2
github.com/hashicorp/terraform-plugin-docs v0.13.0
Expand Down Expand Up @@ -32,7 +33,6 @@ require (
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.3.1 // indirect
github.com/hashicorp/go-plugin v1.4.6 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand Down
Loading