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>
  • Loading branch information
Atul-source committed Nov 28, 2023
1 parent 25692d1 commit f95750f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions kf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,13 @@ 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 {
stats.Incr(stats.NFUpdateFailedCount, b.Program.Name, direction, ifaceName)
return fmt.Errorf("cmd wait at starting of bpf program returned with error %v", err)
}

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 f95750f

Please sign in to comment.