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 set the region for pagerduty #500

Merged
merged 1 commit into from
Jun 6, 2023
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
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ kafkarest:

pagerduty:
routingKey: "" # Pagerduty Routing Key, if not empty, Pagerduty output is enabled
region: "us" # Pagerduty Region, can be 'us' or 'eu' (default: us)
minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)

kubeless:
Expand Down Expand Up @@ -967,15 +968,9 @@ care of lower/uppercases**) : `yaml: a.b --> envvar: A_B` :
`emergency|alert|critical|error|warning|notice|informational|debug or "" (default)`
- **KAFKAREST_MUTUALTLS** : enable mutual tls authentication for this output (default: `false`)
- **KAFKAREST_CHECKCERT** : check if ssl certificate of the output is valid (default: `true`)
- **PAGERDUTY_APIKEY**: Pagerduty API Key, if not empty, Pagerduty output is
- **PAGERDUTY_ROUTINGKEY**: Pagerduty Region, can be 'us' or 'eu' (default: us)
- **PAGERDUTY_REGION**: Pagerduty Region, if not empty, Pagerduty output is
_enabled_
- **PAGERDUTY_SERVICE**: Service to create an incident (mandatory)
- **PAGERDUTY_ASSIGNEE**: A list of comma separated users to assign. Cannot be
provided if `PAGERDUTY_ESCALATION_POLICY` is already specified. If not empty,
Pagerduty is _enabled_
- **PAGERDUTY_ESCALATION_POLICY**: Escalation policy to assign. Cannot be
provided if `PAGERDUTY_ASSIGNEE` is already specified.If not empty, Pagerduty
is _enabled_
- **PAGERDUTY_MINIMUMPRIORITY**: minimum priority of event for using this
output, order is
`emergency|alert|critical|error|warning|notice|informational|debug or "" (default)`
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func getConfig() *types.Configuration {
v.SetDefault("KafkaRest.CheckCert", true)

v.SetDefault("Pagerduty.RoutingKey", "")
v.SetDefault("Pagerduty.Region", "us")
v.SetDefault("Pagerduty.MinimumPriority", "")
v.SetDefault("Pagerduty.MutualTls", false)
v.SetDefault("Pagerduty.CheckCert", true)
Expand Down
1 change: 1 addition & 0 deletions config_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ kafkarest:

pagerduty:
routingKey: "" # Pagerduty Routing Key, if not empty, Pagerduty output is enabled
region: "us" # Pagerduty Region, can be 'us' or 'eu' (default: us)
minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)

kubeless:
Expand Down
14 changes: 13 additions & 1 deletion outputs/pagerduty.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package outputs

import (
"context"
"log"
"strings"
"time"
Expand All @@ -10,13 +11,24 @@ import (
"github.com/falcosecurity/falcosidekick/types"
)

const (
USEndpoint string = "https://events.pagerduty.com"
EUEndpoint string = "https://events.eu.pagerduty.com"
)

// PagerdutyPost posts alert event to Pagerduty
func (c *Client) PagerdutyPost(falcopayload types.FalcoPayload) {
c.Stats.Pagerduty.Add(Total, 1)

event := createPagerdutyEvent(falcopayload, c.Config.Pagerduty)

if _, err := pagerduty.ManageEvent(event); err != nil {
if strings.ToLower(c.Config.Pagerduty.Region) == "eu" {
pagerduty.WithV2EventsAPIEndpoint(EUEndpoint)
} else {
pagerduty.WithV2EventsAPIEndpoint(USEndpoint)
}

if _, err := pagerduty.ManageEventWithContext(context.Background(), event); err != nil {
go c.CountMetric(Outputs, 1, []string{"output:pagerduty", "status:error"})
c.Stats.Pagerduty.Add(Error, 1)
c.PromStats.Outputs.With(map[string]string{"destination": "pagerduty", "status": Error}).Inc()
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ type KafkaRestConfig struct {

type PagerdutyConfig struct {
RoutingKey string
Region string
MinimumPriority string
CheckCert bool
MutualTLS bool
Expand Down