Skip to content
Merged
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
31 changes: 31 additions & 0 deletions crowdsec-docs/docs/local_api/notification_plugins/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ CrowdSec rejects the plugins binaries if one of the following is true :

It is possible to set configuration values based on environment variables.

However, depending on which key is using the environment variable, the syntax is different.

#### Format

The `format` key is a string that uses the [go template](https://pkg.go.dev/text/template) syntax. To use an environment variable in the `format` key, you can use the `env` function provided by [sprig](https://masterminds.github.io/sprig/).

```yaml
format: |
Received {{ len . }} alerts
Environment variable value: {{env "ENV_VAR"}}
```

#### Other keys

All other keys than `format` can use the typical `${ENV_VAR}` or `$ENV_VAR` syntax.

For example, if you don't want to store your SMTP host password in the configuration file, you can do this:

```yaml
Expand All @@ -40,6 +56,21 @@ sender_email: email@gmail.com
email_subject: "CrowdSec Notification"
```

:::warning
Please note that `cscli notifications inspect` command does not interpolate environment variables and will always show the raw value of the key.
:::

If you wish to use `cscli notifications test` command, you must provide the environment variables in the command line or within your shell environment.

For example, if you have a `SMTP_PASSWORD` environment variable, you can test the `email_default` plugin with the following command:

:::warning
Some shells may hold this information in history, so please consult your shell documentation to ensure that the password or other sensitive data is not stored in clear text.
:::

```bash
SMTP_PASSWORD=your_password cscli notifications test email_default
```

### Registering plugin to profile

Expand Down
Loading