You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crowdsec-docs/docs/local_api/notification_plugins/intro.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,22 @@ CrowdSec rejects the plugins binaries if one of the following is true :
27
27
28
28
It is possible to set configuration values based on environment variables.
29
29
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
+
30
46
For example, if you don't want to store your SMTP host password in the configuration file, you can do this:
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
0 commit comments