|
3 | 3 | * Webhooks in "production" are deployed to a Google Cloud Run instance, in the project `super-big-data`. Why? (TODO insert why) |
4 | 4 | * The webhook points to `https://product-eng-webhooks-vmrqv3f7nq-uw.a.run.app` |
5 | 5 |
|
| 6 | +## Generic Event Notifier |
| 7 | + |
| 8 | +The folder `generic-notifier` provides a generic webhook which can be used to send messages to Sentry Slack channels and Sentry Datadog. Using this webhook is VERY simple. |
| 9 | + |
| 10 | +Simply, go to `@/config/secrets.ts` and add an entry to the `EVENT_NOTIFIER_SECRETS` object. This entry should contain a mapping from the name of your service (for example, `example-service`) to an environment variable. [TODO: Fill in how to set the prod env var here]. Make a PR with this change and get it approved & merged. |
| 11 | + |
| 12 | +Once this has been deployed, all you have to do is send a POST request to `https://product-eng-webhooks-vmrqv3f7nq-uw.a.run.app/event-notifier/v1` with a JSON payload in the format of the type `GenericEvent` defined in `@/types/index.ts`. Example: |
| 13 | + |
| 14 | +```json |
| 15 | +{ |
| 16 | + "source": "example-service", // This must match the mapping string you define in the EVENT_NOTIFIER_SECRETS obj |
| 17 | + "timestamp": 0, |
| 18 | + "service_name": "official_service_name", |
| 19 | + "data": { |
| 20 | + "title": "This is an Example Notification", |
| 21 | + "message": "Random text here", |
| 22 | + "tags": [ |
| 23 | + "source:example-service", "sentry-region:all", "sentry-user:bob" |
| 24 | + ], |
| 25 | + "misc": {}, |
| 26 | + "channels": { |
| 27 | + "slack": ["C07EH2QGGQ5"], |
| 28 | + "jira": ["TEST"] |
| 29 | + } |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +Additionally, you must compute the HMAC SHA256 hash of the raw payload string computed with the secret key, and attach it to the `Authorization` header. EX: `Authorization: <Hash here>` |
| 35 | + |
6 | 36 | ## Adding a webhook to GoCD event emitter |
7 | 37 |
|
8 | 38 | * goto [gocd](deploy.getsentry.net) |
@@ -30,7 +60,3 @@ Make sure to write the appropriate tests for the new webhook as well, by creatin |
30 | 60 | ## Authentication |
31 | 61 |
|
32 | 62 | Auth is handled via HMAC SHA256 signing. Each webhook expects a HMAC SHA hash sent in the `x-` header. Requests are validated by locally computing the expected HMAC SHA hash using a local secret (from an env variable) and comparing the values. `@/utils/auth/extractAndVerifySignature.ts` provides a utility function for authenticating requests. |
33 | | - |
34 | | -## Generic Event Notifier |
35 | | - |
36 | | -Handlers in the folder `notifier` can be used to send messages to be sent to Sentry Slack channels. |
|
0 commit comments