Skip to content

Commit 9b69424

Browse files
enhancement: Add information about environment variables in the notificiations (#702)
* enhancement: Add information about environment variables in the notification plugins * enhancement: concise information
1 parent 822424a commit 9b69424

File tree

1 file changed

+31
-0
lines changed
  • crowdsec-docs/docs/local_api/notification_plugins

1 file changed

+31
-0
lines changed

crowdsec-docs/docs/local_api/notification_plugins/intro.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ CrowdSec rejects the plugins binaries if one of the following is true :
2727

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

30+
However, depending on which key is using the environment variable, the syntax is different.
31+
32+
#### Format
33+
34+
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/).
35+
36+
```yaml
37+
format: |
38+
Received {{ len . }} alerts
39+
Environment variable value: {{env "ENV_VAR"}}
40+
```
41+
42+
#### Other keys
43+
44+
All other keys than `format` can use the typical `${ENV_VAR}` or `$ENV_VAR` syntax.
45+
3046
For example, if you don't want to store your SMTP host password in the configuration file, you can do this:
3147

3248
```yaml
@@ -40,6 +56,21 @@ sender_email: [email protected]
4056
email_subject: "CrowdSec Notification"
4157
```
4258

59+
:::warning
60+
Please note that `cscli notifications inspect` command does not interpolate environment variables and will always show the raw value of the key.
61+
:::
62+
63+
If you wish to use `cscli notifications test` command, you must provide the environment variables in the command line or within your shell environment.
64+
65+
For example, if you have a `SMTP_PASSWORD` environment variable, you can test the `email_default` plugin with the following command:
66+
67+
:::warning
68+
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.
69+
:::
70+
71+
```bash
72+
SMTP_PASSWORD=your_password cscli notifications test email_default
73+
```
4374

4475
### Registering plugin to profile
4576

0 commit comments

Comments
 (0)