projectAlertRuleConfiguration.ts 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. import {
  2. IssueAlertRuleActionTemplate,
  3. IssueAlertRuleConditionTemplate,
  4. } from 'sentry/types/alerts';
  5. type Config = {
  6. actions: IssueAlertRuleActionTemplate[];
  7. conditions: IssueAlertRuleConditionTemplate[];
  8. filters: IssueAlertRuleConditionTemplate[];
  9. };
  10. export function ProjectAlertRuleConfiguration(params: Partial<Config> = {}): Config {
  11. return {
  12. actions: [
  13. {
  14. id: 'sentry.mail.actions.NotifyEmailAction',
  15. label: 'Send a notification to {targetType}',
  16. enabled: true,
  17. prompt: 'Send a notification',
  18. formFields: {
  19. targetType: {
  20. type: 'choice',
  21. placeholder: 'mailAction',
  22. choices: [
  23. ['IssueOwners', 'Issue Owners'],
  24. ['Team', 'Team'],
  25. ['Member', 'Member'],
  26. ],
  27. },
  28. },
  29. },
  30. {
  31. id: 'sentry.rules.actions.notify_event.NotifyEventAction',
  32. label: 'Send a notification (for all legacy integrations)',
  33. enabled: true,
  34. prompt: 'Send a notification to all legacy integrations',
  35. },
  36. {
  37. id: 'sentry.integrations.slack.notify_action.SlackNotifyServiceAction',
  38. label:
  39. 'Send a notification to the {workspace} Slack workspace to {channel} (optionally, an ID: {channel_id}) and show tags {tags} in notification',
  40. enabled: true,
  41. prompt: 'Send a Slack notification',
  42. formFields: {
  43. workspace: {type: 'choice', choices: [['123', 'Sentry']]},
  44. channel: {type: 'string', placeholder: 'i.e #critical, Jane Schmidt'},
  45. channel_id: {type: 'string', placeholder: 'i.e. CA2FRA079 or UA1J9RTE1'},
  46. tags: {type: 'string', placeholder: 'i.e environment,user,my_tag'},
  47. },
  48. },
  49. {
  50. id: 'sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction',
  51. label: 'Send a notification to PagerDuty account {account} and service {service}',
  52. enabled: true,
  53. prompt: 'Send a PagerDuty notification',
  54. formFields: {
  55. account: {type: 'choice', choices: []},
  56. service: {type: 'choice', choices: []},
  57. },
  58. },
  59. ],
  60. conditions: [
  61. {
  62. id: 'sentry.rules.conditions.every_event.EveryEventCondition',
  63. label: 'The event occurs',
  64. enabled: false,
  65. },
  66. {
  67. id: 'sentry.rules.conditions.first_seen_event.FirstSeenEventCondition',
  68. label: 'A new issue is created',
  69. enabled: true,
  70. },
  71. {
  72. id: 'sentry.rules.conditions.regression_event.RegressionEventCondition',
  73. label: 'The issue changes state from resolved to unresolved',
  74. enabled: true,
  75. },
  76. {
  77. id: 'sentry.rules.conditions.reappeared_event.ReappearedEventCondition',
  78. label: 'The issue changes state from ignored to unresolved',
  79. enabled: true,
  80. },
  81. {
  82. id: 'sentry.rules.conditions.event_frequency.EventFrequencyCondition',
  83. label: 'The issue is seen more than {value} times in {interval}',
  84. enabled: true,
  85. formFields: {
  86. value: {type: 'number', placeholder: 100},
  87. interval: {
  88. type: 'choice',
  89. choices: [
  90. ['1m', 'one minute'],
  91. ['5m', '5 minutes'],
  92. ['15m', '15 minutes'],
  93. ['1h', 'one hour'],
  94. ['1d', 'one day'],
  95. ['1w', 'one week'],
  96. ['30d', '30 days'],
  97. ],
  98. },
  99. },
  100. },
  101. {
  102. id: 'sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition',
  103. label: 'The issue is seen by more than {value} users in {interval}',
  104. enabled: true,
  105. formFields: {
  106. value: {type: 'number', placeholder: 100},
  107. interval: {
  108. type: 'choice',
  109. choices: [
  110. ['1m', 'one minute'],
  111. ['5m', '5 minutes'],
  112. ['15m', '15 minutes'],
  113. ['1h', 'one hour'],
  114. ['1d', 'one day'],
  115. ['1w', 'one week'],
  116. ['30d', '30 days'],
  117. ],
  118. },
  119. },
  120. },
  121. {
  122. id: 'sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition',
  123. label: 'The issue affects more than {value} percent of sessions in {interval}',
  124. enabled: true,
  125. formFields: {
  126. value: {type: 'number', placeholder: 100},
  127. interval: {
  128. type: 'choice',
  129. choices: [
  130. ['5m', '5 minutes'],
  131. ['10m', '10 minutes'],
  132. ['30m', '30 minutes'],
  133. ['1h', '1 hour'],
  134. ],
  135. },
  136. },
  137. },
  138. ],
  139. filters: [
  140. {
  141. id: 'sentry.rules.filters.age_comparison.AgeComparisonFilter',
  142. label: 'The issue is {comparison_type} than {value} {time}',
  143. enabled: true,
  144. prompt: 'The issue is older or newer than...',
  145. formFields: {
  146. comparison_type: {
  147. type: 'choice',
  148. choices: [
  149. ['older', 'older'],
  150. ['newer', 'newer'],
  151. ],
  152. },
  153. value: {type: 'number', placeholder: 10},
  154. time: {
  155. type: 'choice',
  156. choices: [
  157. ['minute', 'minute(s)'],
  158. ['hour', 'hour(s)'],
  159. ['day', 'day(s)'],
  160. ['week', 'week(s)'],
  161. ],
  162. },
  163. },
  164. },
  165. {
  166. id: 'sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter',
  167. label: 'The issue has happened at least {value} times',
  168. enabled: true,
  169. prompt: 'The issue has happened at least {x} times (Note: this is approximate)',
  170. formFields: {value: {type: 'number', placeholder: 10}},
  171. },
  172. {
  173. id: 'sentry.rules.filters.assigned_to.AssignedToFilter',
  174. label: 'The issue is assigned to {targetType}',
  175. enabled: true,
  176. prompt: 'The issue is assigned to {no one/team/member}',
  177. formFields: {
  178. targetType: {
  179. type: 'choice',
  180. placeholder: 'assignee',
  181. choices: [
  182. ['Unassigned', 'Unassigned'],
  183. ['Team', 'Team'],
  184. ['Member', 'Member'],
  185. ],
  186. },
  187. },
  188. },
  189. {
  190. id: 'sentry.rules.filters.event_attribute.EventAttributeFilter',
  191. label: "The event's {attribute} value {match} {value}",
  192. enabled: true,
  193. formFields: {
  194. attribute: {
  195. type: 'choice',
  196. placeholder: 'i.e. exception.type',
  197. choices: [
  198. ['message', 'message'],
  199. ['platform', 'platform'],
  200. ['environment', 'environment'],
  201. ['type', 'type'],
  202. ['exception.type', 'exception.type'],
  203. ['exception.value', 'exception.value'],
  204. ['user.id', 'user.id'],
  205. ['user.email', 'user.email'],
  206. ['user.username', 'user.username'],
  207. ['user.ip_address', 'user.ip_address'],
  208. ['http.method', 'http.method'],
  209. ['http.url', 'http.url'],
  210. ['sdk.name', 'sdk.name'],
  211. ['stacktrace.code', 'stacktrace.code'],
  212. ['stacktrace.module', 'stacktrace.module'],
  213. ['stacktrace.filename', 'stacktrace.filename'],
  214. ['stacktrace.abs_path', 'stacktrace.abs_path'],
  215. ['stacktrace.package', 'stacktrace.package'],
  216. ],
  217. },
  218. match: {
  219. type: 'choice',
  220. choices: [
  221. ['co', 'contains'],
  222. ['ew', 'ends with'],
  223. ['eq', 'equals'],
  224. ['is', 'is set'],
  225. ['nc', 'does not contain'],
  226. ['new', 'does not end with'],
  227. ['ne', 'does not equal'],
  228. ['ns', 'is not set'],
  229. ['nsw', 'does not start with'],
  230. ['sw', 'starts with'],
  231. ],
  232. },
  233. value: {type: 'string', placeholder: 'value'},
  234. },
  235. },
  236. {
  237. id: 'sentry.rules.filters.tagged_event.TaggedEventFilter',
  238. label: "The event's tags match {key} {match} {value}",
  239. enabled: true,
  240. formFields: {
  241. key: {type: 'string', placeholder: 'key'},
  242. match: {
  243. type: 'choice',
  244. choices: [
  245. ['co', 'contains'],
  246. ['ew', 'ends with'],
  247. ['eq', 'equals'],
  248. ['is', 'is set'],
  249. ['nc', 'does not contain'],
  250. ['new', 'does not end with'],
  251. ['ne', 'does not equal'],
  252. ['ns', 'is not set'],
  253. ['nsw', 'does not start with'],
  254. ['sw', 'starts with'],
  255. ],
  256. },
  257. value: {type: 'string', placeholder: 'value'},
  258. },
  259. },
  260. {
  261. id: 'sentry.rules.filters.level.LevelFilter',
  262. label: "The event's level is {match} {level}",
  263. enabled: true,
  264. formFields: {
  265. level: {
  266. type: 'choice',
  267. choices: [
  268. ['50', 'fatal'],
  269. ['40', 'error'],
  270. ['30', 'warning'],
  271. ['20', 'info'],
  272. ['10', 'debug'],
  273. ['0', 'sample'],
  274. ],
  275. },
  276. match: {
  277. type: 'choice',
  278. choices: [
  279. ['eq', 'equal to'],
  280. ['gte', 'greater than or equal to'],
  281. ['lte', 'less than or equal to'],
  282. ],
  283. },
  284. },
  285. },
  286. ],
  287. ...params,
  288. };
  289. }