Skip to content

Commit

Permalink
process:username: metric for errors
Browse files Browse the repository at this point in the history
Signed-off-by: Djalal Harouni <[email protected]>
  • Loading branch information
tixxdz committed Jun 20, 2024
1 parent a306aa4 commit 65688a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/content/en/docs/reference/metrics.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/metrics/errormetrics/errormetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
HandlerError
// An event finalizer on Process failed
EventFinalizeProcessInfoFailed
// Failed to resolve Process uid to username
ProcessMetadataUsernameFailed
)

var errorTypeLabelValues = map[ErrorType]string{
Expand All @@ -38,6 +40,7 @@ var errorTypeLabelValues = map[ErrorType]string{
EventMissingProcessInfo: "event_missing_process_info",
HandlerError: "handler_error",
EventFinalizeProcessInfoFailed: "event_finalize_process_info_failed",
ProcessMetadataUsernameFailed: "process_metadata_username_failed",
}

func (e ErrorType) String() string {
Expand Down
2 changes: 2 additions & 0 deletions pkg/sensors/exec/userinfo/userinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/cilium/tetragon/pkg/api/processapi"
"github.com/cilium/tetragon/pkg/grpc/exec"
"github.com/cilium/tetragon/pkg/metrics/errormetrics"
"github.com/cilium/tetragon/pkg/option"
"github.com/cilium/tetragon/pkg/reader/namespace"
"github.com/cilium/tetragon/pkg/reader/userdb"
Expand Down Expand Up @@ -37,6 +38,7 @@ func MsgToExecveAccountUnix(m *exec.MsgExecveEventUnix) error {
if option.Config.UsernameMetadata == int(option.USERNAME_METADATA_UNIX) {
username, err := getAccountUnix(m.Unix.Process.UID, &m.Unix.Msg.Namespaces)
if err != nil {
errormetrics.ErrorTotalInc(errormetrics.ProcessMetadataUsernameFailed)
return err
}

Expand Down

0 comments on commit 65688a6

Please sign in to comment.