Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netobserv-ebpf-agent
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
netobserv-ebpf-agent
Commits
47f7fcf7
Unverified
Commit
47f7fcf7
authored
3 months ago
by
Joel Takvorian
Committed by
GitHub
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add ovn model utilities (#481)
parent
b4122b04
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/agent/agent.go
+2
-0
2 additions, 0 deletions
pkg/agent/agent.go
pkg/model/record.go
+3
-18
3 additions, 18 deletions
pkg/model/record.go
pkg/utils/network_events.go
+63
-0
63 additions, 0 deletions
pkg/utils/network_events.go
with
68 additions
and
18 deletions
pkg/agent/agent.go
+
2
−
0
View file @
47f7fcf7
...
...
@@ -178,6 +178,8 @@ func FlowsAgent(cfg *Config) (*Flows, error) {
if
s
,
err
=
ovnobserv
.
NewSampleDecoderWithDefaultCollector
(
context
.
Background
(),
networkEventsDBPath
,
networkEventsOwnerName
,
cfg
.
NetworkEventsMonitoringGroupID
);
err
!=
nil
{
alog
.
Warnf
(
"failed to create Network Events sample decoder: %v for id: %d"
,
err
,
cfg
.
NetworkEventsMonitoringGroupID
)
}
else
{
alog
.
Info
(
"Network Events sample decoder successfully created"
)
}
}
else
{
alog
.
Warn
(
"old kernel doesn't support network events monitoring skip"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/model/record.go
+
3
−
18
View file @
47f7fcf7
...
...
@@ -9,8 +9,8 @@ import (
"time"
"github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf"
"github.com/netobserv/netobserv-ebpf-agent/pkg/utils"
ovnmodel
"github.com/ovn-org/ovn-kubernetes/go-controller/observability-lib/model"
ovnobserv
"github.com/ovn-org/ovn-kubernetes/go-controller/observability-lib/sampledecoder"
"github.com/sirupsen/logrus"
)
...
...
@@ -114,26 +114,11 @@ func NewRecord(
record
.
NetworkMonitorEventsMD
=
make
([]
map
[
string
]
string
,
0
)
for
_
,
metadata
:=
range
metrics
.
AdditionalMetrics
.
NetworkEvents
{
if
!
AllZerosMetaData
(
metadata
)
{
var
cm
map
[
string
]
string
if
md
,
err
:=
s
.
DecodeCookie8Bytes
(
metadata
);
err
==
nil
{
acl
,
ok
:=
md
.
(
*
ovnmodel
.
ACLEvent
)
mdStr
:=
md
.
String
()
if
!
seen
[
mdStr
]
{
if
ok
{
cm
=
map
[
string
]
string
{
"Action"
:
acl
.
Action
,
"Type"
:
acl
.
Actor
,
"Feature"
:
"acl"
,
"Name"
:
acl
.
Name
,
"Namespace"
:
acl
.
Namespace
,
"Direction"
:
acl
.
Direction
,
}
}
else
{
cm
=
map
[
string
]
string
{
"Message"
:
mdStr
,
}
}
record
.
NetworkMonitorEventsMD
=
append
(
record
.
NetworkMonitorEventsMD
,
cm
)
asMap
:=
utils
.
NetworkEventToMap
(
md
)
record
.
NetworkMonitorEventsMD
=
append
(
record
.
NetworkMonitorEventsMD
,
asMap
)
seen
[
mdStr
]
=
true
}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/utils/network_events.go
0 → 100644
+
63
−
0
View file @
47f7fcf7
package
utils
import
(
"github.com/netobserv/flowlogs-pipeline/pkg/config"
ovnmodel
"github.com/ovn-org/ovn-kubernetes/go-controller/observability-lib/model"
)
func
NetworkEventToMap
(
netev
ovnmodel
.
NetworkEvent
)
map
[
string
]
string
{
if
acl
,
ok
:=
netev
.
(
*
ovnmodel
.
ACLEvent
);
ok
{
return
map
[
string
]
string
{
"Action"
:
acl
.
Action
,
"Type"
:
acl
.
Actor
,
"Feature"
:
"acl"
,
"Name"
:
acl
.
Name
,
"Namespace"
:
acl
.
Namespace
,
"Direction"
:
acl
.
Direction
,
}
}
return
map
[
string
]
string
{
"Message"
:
netev
.
String
(),
}
}
func
NetworkEventsToStrings
(
flow
config
.
GenericMap
)
[]
string
{
if
ne
,
found
:=
flow
[
"NetworkEvents"
];
found
{
if
neList
,
isList
:=
ne
.
([]
any
);
isList
{
var
messages
[]
string
for
_
,
item
:=
range
neList
{
if
neItem
,
isMap
:=
item
.
(
map
[
string
]
any
);
isMap
{
messages
=
append
(
messages
,
networkEventItemToString
(
neItem
))
}
}
return
messages
}
}
return
nil
}
func
networkEventItemToString
(
in
map
[
string
]
any
)
string
{
if
msg
:=
getAsString
(
in
,
"Message"
);
msg
!=
""
{
return
msg
}
if
feat
:=
getAsString
(
in
,
"Feature"
);
feat
==
"acl"
{
aclObj
:=
ovnmodel
.
ACLEvent
{
Action
:
getAsString
(
in
,
"Action"
),
Actor
:
getAsString
(
in
,
"Type"
),
Name
:
getAsString
(
in
,
"Name"
),
Namespace
:
getAsString
(
in
,
"Namespace"
),
Direction
:
getAsString
(
in
,
"Direction"
),
}
return
aclObj
.
String
()
}
return
""
}
func
getAsString
(
in
map
[
string
]
any
,
key
string
)
string
{
if
anyV
,
hasKey
:=
in
[
key
];
hasKey
{
if
v
,
isStr
:=
anyV
.
(
string
);
isStr
{
return
v
}
}
return
""
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment