Skip to content

Commit

Permalink
Add alertmanager variable to choose the endpoint version of alertmana…
Browse files Browse the repository at this point in the history
…ger api

Signed-off-by: Mathilde Hermet <mathildehermet94260@gmail.com>
  • Loading branch information
mathildeHermet authored and poiana committed Nov 19, 2021
1 parent 5ee27aa commit cefd9b8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ alertmanager:
# minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)
# mutualtls: false # if true, checkcert flag will be ignored (server cert will always be checked)
# checkcert: true # check if ssl certificate of the output is valid (default: true)
# endpoint: "" # alertmanager endpoint for posting alerts: "/api/v1/alerts" or "/api/v2/alerts" (default: "/api/v1/alerts")


elasticsearch:
# hostport: "" # http://{domain or ip}:{port}, if not empty, Elasticsearch output is enabled
Expand Down Expand Up @@ -543,6 +545,8 @@ care of lower/uppercases**) : `yaml: a.b --> envvar: A_B` :
`false`)
- **ALERTMANAGER_CHECKCERT** : check if ssl certificate of the output is valid (default:
`true`)
- **ALERTMANAGER_ENDPOINT** : alertmanager endpoint on which falcosidekick posts alerts, choice is:
`"/api/v1/alerts" or "/api/v2/alerts" , default is "/api/v1/alerts"`
- **ELASTICSEARCH_HOSTPORT** : Elasticsearch http://host:port, if not `empty`,
Elasticsearch is _enabled_
- **ELASTICSEARCH_INDEX** : Elasticsearch index (default: falco)
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func getConfig() *types.Configuration {
v.SetDefault("Alertmanager.MinimumPriority", "")
v.SetDefault("Alertmanager.MutualTls", false)
v.SetDefault("Alertmanager.CheckCert", true)
v.SetDefault("Alertmanager.Endpoint", "/api/v1/alerts")

v.SetDefault("Elasticsearch.HostPort", "")
v.SetDefault("Elasticsearch.Index", "falco")
Expand Down
1 change: 1 addition & 0 deletions config_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ alertmanager:
# minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)
# mutualtls: false # if true, checkcert flag will be ignored (server cert will always be checked)
# checkcert: true # check if ssl certificate of the output is valid (default: true)
# endpoint: "" # alertmanager endpoint for posting alerts: "/api/v1/alerts" or "/api/v2/alerts" (default: "/api/v1/alerts")

elasticsearch:
# hostport: "" # http://{domain or ip}:{port}, if not empty, Elasticsearch output is enabled
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func init() {

if config.Alertmanager.HostPort != "" {
var err error
alertmanagerClient, err = outputs.NewClient("AlertManager", config.Alertmanager.HostPort+outputs.AlertmanagerURI, config.Alertmanager.MutualTLS, config.Alertmanager.CheckCert, config, stats, promStats, statsdClient, dogstatsdClient)
alertmanagerClient, err = outputs.NewClient("AlertManager", config.Alertmanager.HostPort+config.Alertmanager.Endpoint, config.Alertmanager.MutualTLS, config.Alertmanager.CheckCert, config, stats, promStats, statsdClient, dogstatsdClient)
if err != nil {
config.Alertmanager.HostPort = ""
} else {
Expand Down
5 changes: 0 additions & 5 deletions outputs/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import (
"github.com/falcosecurity/falcosidekick/types"
)

const (
// AlertmanagerURI is default endpoint where to send events
AlertmanagerURI string = "/api/v1/alerts"
)

type alertmanagerPayload struct {
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type alertmanagerOutputConfig struct {
MinimumPriority string
CheckCert bool
MutualTLS bool
Endpoint string
}

type elasticsearchOutputConfig struct {
Expand Down

0 comments on commit cefd9b8

Please sign in to comment.