-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> For #163
- Loading branch information
1 parent
656c86b
commit 29a6c32
Showing
10 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package outputs | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/DataDog/datadog-go/statsd" | ||
"github.com/PagerDuty/go-pagerduty" | ||
"github.com/falcosecurity/falcosidekick/types" | ||
) | ||
|
||
// NewPagerdutyClient returns a new output.Client for accessing the Pagerduty API. | ||
func NewPagerdutyClient(config *types.Configuration, stats *types.Statistics, promStats *types.PromStatistics, statsdClient, dogstatsdClient *statsd.Client) (*Client, error) { | ||
if len(config.Pagerduty.Assignee) > 0 && config.Pagerduty.EscalationPolicy != "" { | ||
return nil, fmt.Errorf("assignee and escalation policy cannot be both configured") | ||
} | ||
|
||
return &Client{ | ||
OutputType: "GCP", | ||
Config: config, | ||
Stats: stats, | ||
PromStats: promStats, | ||
StatsdClient: statsdClient, | ||
DogstatsdClient: dogstatsdClient, | ||
PagerdutyClient: pagerduty.NewClient(config.Pagerduty.APIKey), | ||
}, nil | ||
} | ||
|
||
// PagerdutyPost posts incident to Pagerduty | ||
func (c *Client) PagerdutyPost(falcopayload types.FalcoPayload) { | ||
c.Stats.Pagerduty.Add(Total, 1) | ||
|
||
// TODO: Implement pagerduty post | ||
err := c.Post(newDatadogPayload(falcopayload)) | ||
if 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() | ||
log.Printf("[ERROR] : Pagerduty - %v\n", err) | ||
return | ||
} | ||
|
||
go c.CountMetric(Outputs, 1, []string{"output:pagerduty", "status:ok"}) | ||
c.Stats.Pagerduty.Add(OK, 1) | ||
c.PromStats.Outputs.With(map[string]string{"destination": "pagerduty", "status": OK}).Inc() | ||
log.Printf("[INFO] : Pagerduty - Publish OK\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters