Skip to content

Commit

Permalink
webhook: add missing statds/dogstastd metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Panato <[email protected]>
  • Loading branch information
cpanato authored and poiana committed Dec 17, 2020
1 parent d11818c commit b604df9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions outputs/webhook.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package outputs

import (
"log"

"github.com/falcosecurity/falcosidekick/types"
)

// WebhookPost posts event to Slack
func (c *Client) WebhookPost(falcopayload types.FalcoPayload) {
c.Stats.Webhook.Add(Total, 1)

err := c.Post(falcopayload)
if err != nil {
go c.CountMetric(Outputs, 1, []string{"output:webhook", "status:error"})
c.Stats.Webhook.Add(Error, 1)
c.PromStats.Outputs.With(map[string]string{"destination": "webhook", "status": Error}).Inc()
} else {
c.Stats.Webhook.Add(OK, 1)
c.PromStats.Outputs.With(map[string]string{"destination": "webhook", "status": OK}).Inc()
log.Printf("[ERROR] : WebHook - %v\n", err.Error())
return
}

c.Stats.Webhook.Add(Total, 1)
// Setting the success status
go c.CountMetric(Outputs, 1, []string{"output:webhook", "status:ok"})
c.Stats.Webhook.Add(OK, 1)
c.PromStats.Outputs.With(map[string]string{"destination": "webhook", "status": OK}).Inc()
log.Printf("[INFO] : WebHook - Publish OK\n")
}

0 comments on commit b604df9

Please sign in to comment.