Skip to content

Commit

Permalink
teams: 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 7c14896 commit d11818c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions outputs/teams.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package outputs

import (
"log"
"strings"

"github.com/falcosecurity/falcosidekick/types"
Expand Down Expand Up @@ -28,10 +29,12 @@ type teamsPayload struct {
}

func newTeamsPayload(falcopayload types.FalcoPayload, config *types.Configuration) teamsPayload {
var sections []teamsSection
var section teamsSection
var facts []teamsFact
var fact teamsFact
var (
sections []teamsSection
section teamsSection
facts []teamsFact
fact teamsFact
)

section.ActivityTitle = "Falco Sidekick"
section.ActivitySubTitle = falcopayload.Time.String()
Expand All @@ -53,6 +56,7 @@ func newTeamsPayload(falcopayload types.FalcoPayload, config *types.Configuratio
default:
continue
}

facts = append(facts, fact)
}

Expand Down Expand Up @@ -100,14 +104,20 @@ func newTeamsPayload(falcopayload types.FalcoPayload, config *types.Configuratio

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

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

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

0 comments on commit d11818c

Please sign in to comment.