Skip to content

Commit

Permalink
enhancement: Add information about environment variables in the notif…
Browse files Browse the repository at this point in the history
…iciations (#702)

* enhancement: Add information about environment variables in the notification plugins

* enhancement: concise information
  • Loading branch information
LaurenceJJones authored Dec 26, 2024
1 parent 822424a commit 9b69424
Showing 1 changed file with 31 additions and 0 deletions.
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 protected]
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

0 comments on commit 9b69424

Please sign in to comment.