Skip to main content

diagrid notification destination create

Create a notification destination

Description

Create a notification destination.

A destination is the sink a matched notification is delivered to. It is reusable: several notification routes may name the same destination.

The flags a destination takes depend on its --type. The webhook flags are prefixed --webhook-.

--webhook-auth-token sets the bearer token sent with every delivery. The token is moved into the project's secret store on the way in: it is not kept on the destination and reading the destination back never returns it.

By default the body is the notification serialized as JSON. The --webhook-body-template flag renders it instead, with the notification as the template data: .Type, .Labels, .Message and .Timestamp. Pipe every interpolated value through the json function so the body stays valid whatever the value contains.

diagrid notification destination create <name> [flags]

Examples


# An unauthenticated webhook
diagrid notification destination create ops-webhook \
--webhook-url https://hooks.example.com/catalyst

# A webhook authenticated with a bearer token
diagrid notification destination create ops-webhook \
--webhook-url https://hooks.example.com/catalyst \
--webhook-auth-token s3cr3t

# Add a header the receiver expects
diagrid notification destination create ops-webhook \
--webhook-url https://hooks.example.com/catalyst \
--webhook-header X-Diagrid-Source:catalyst

# Shape the body for a chat webhook
diagrid notification destination create slack \
--webhook-url https://hooks.slack.com/services/... \
--webhook-body-template '{"text": {{ .Message | json }}}'

Options

-p, --project string Name of existing project
--type string Destination channel (default "webhook")
--webhook-url string Endpoint each matching notification is POSTed to
--webhook-auth-token string Bearer token sent with every delivery; stored in the project's secret store
--webhook-header stringArray Extra request header as Name:value; repeat for several
--webhook-body-template string Go text template rendering the request body from the notification (.Type, .Labels, .Message, .Timestamp). Omit to send the notification as JSON.
-h, --help help for create

Options inherited from parent commands

--api-key string Diagrid Cloud API key

SEE ALSO