Skip to content

Commit

Permalink
L3AFD metric for ebpf program update command failure count (l3af-proj…
Browse files Browse the repository at this point in the history
…ect#283)

* L3AFD metric for ebpf program update command failure count

Signed-off-by: Atul-source <atulprajapati6031@gmail.com>
Signed-off-by: sferna1 <santhosh.fernandes@gmail.com>
  • Loading branch information
Atul-source authored and sanfern committed Oct 24, 2023
1 parent a2e3dae commit b4251cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion kf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,14 @@ func (b *BPF) UpdateArgs(ifaceName, direction string) error {
log.Info().Msgf("BPF Program update command : %s %v", cmd, args)
UpdateCmd := execCommand(cmd, args...)
if err := UpdateCmd.Start(); err != nil {
stats.Incr(stats.NFUpdateFailedCount, b.Program.Name, direction, ifaceName)
log.Info().Err(err).Msgf("user mode BPF program failed - %s", b.Program.Name)
return fmt.Errorf("failed to start : %s %v", cmd, args)
}

if err := UpdateCmd.Wait(); err != nil {
log.Warn().Msgf("cmd wait at starting of bpf program returned with error %v", err)
stats.Incr(stats.NFUpdateFailedCount, b.Program.Name, direction, ifaceName)
return fmt.Errorf("cmd wait at starting of bpf program returned with error %v", err)
}

stats.Incr(stats.NFUpdateCount, b.Program.Name, direction, ifaceName)
Expand Down
24 changes: 18 additions & 6 deletions stats/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (
)

var (
NFStartCount *prometheus.CounterVec
NFStopCount *prometheus.CounterVec
NFUpdateCount *prometheus.CounterVec
NFRunning *prometheus.GaugeVec
NFStartTime *prometheus.GaugeVec
NFMonitorMap *prometheus.GaugeVec
NFStartCount *prometheus.CounterVec
NFStopCount *prometheus.CounterVec
NFUpdateCount *prometheus.CounterVec
NFUpdateFailedCount *prometheus.CounterVec
NFRunning *prometheus.GaugeVec
NFStartTime *prometheus.GaugeVec
NFMonitorMap *prometheus.GaugeVec
)

func SetupMetrics(hostname, daemonName, metricsAddr string) {
Expand Down Expand Up @@ -56,6 +57,17 @@ func SetupMetrics(hostname, daemonName, metricsAddr string) {

NFUpdateCount = nfUpdateCountVec.MustCurryWith(prometheus.Labels{"host": hostname})

nfUpdateFailedCountVec := promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: daemonName,
Name: "NFUpdateFailedCount",
Help: "The count of Failed eBPF programs updates",
},
[]string{"host", "bpf_program", "direction", "interface_name"},
)

NFUpdateFailedCount = nfUpdateFailedCountVec.MustCurryWith(prometheus.Labels{"host": hostname})

nfRunningVec := prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: daemonName,
Expand Down

0 comments on commit b4251cb

Please sign in to comment.