Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to use envvar as custom fields #353

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ See **config_example.yaml** :
#listenaddress: "" # ip address to bind falcosidekick to (default: "" meaning all addresses)
#listenport: 2801 # port to listen for daemon (default: 2801)
debug: false # if true all outputs will print in stdout the payload they send (default: false)
customfields: # custom fields are added to falco events
customfields: # custom fields are added to falco events, if the value starts with % the relative env var is used
Akey: "AValue"
Bkey: "BValue"
Ckey: "CValue"
Expand Down Expand Up @@ -520,7 +520,7 @@ care of lower/uppercases**) : `yaml: a.b --> envvar: A_B` :
- **LISTENPORT** : port to listen for daemon (default: `2801`)
- **DEBUG** : if _true_ all outputs will print in stdout the payload they send
(default: false)
- **CUSTOMFIELDS** : a list of comma separated custom fields to add to falco
- **CUSTOMFIELDS** : a list of comma separated custom fields to add to falco, if the value starts with % the relative env var is used
events, syntax is "key:value,key:value"
**MUTUALTLSFILESPATH**: path which will be used to stored certs and key for mutual tls authentication (default: "/etc/certs")
- **SLACK_WEBHOOKURL** : Slack Webhook URL (ex:
Expand Down
10 changes: 9 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,15 @@ func getConfig() *types.Configuration {
for _, label := range customfields {
tagkeys := strings.Split(label, ":")
if len(tagkeys) == 2 {
c.Customfields[tagkeys[0]] = tagkeys[1]
if strings.HasPrefix(tagkeys[1], "%") {
if s := os.Getenv(tagkeys[1][1:]); s != "" {
c.Customfields[tagkeys[0]] = s
} else {
log.Printf("[ERROR] : Can't find env var %v for custom fields", tagkeys[1][1:])
}
} else {
c.Customfields[tagkeys[0]] = tagkeys[1]
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion config_example.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#listenaddress: "" # ip address to bind falcosidekick to (default: "" meaning all addresses)
#listenport: 2801 # port to listen for daemon (default: 2801)
debug: false # if true all outputs will print in stdout the payload they send (default: false)
customfields: # custom fields are added to falco events and metrics
customfields: # custom fields are added to falco events and metrics, if the value starts with % the relative env var is used
Akey: "AValue"
Bkey: "BValue"
Ckey: "CValue"
Expand Down