Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix improve cgoreceiver log format #455

Merged

Conversation

NeJan2020
Copy link
Collaborator

@NeJan2020 NeJan2020 commented Feb 17, 2023

Optimized the log output of CgoReceiver to display the specific value in UserAttribute

Description

Print Specific Value of UserAttributes rather than base64 Encoding.

Only print printable character (ASCII char code from 32 to 126) for ByteBuffer , other character will be replaced by .
The max length is 200, and extra bytes will be count, such as <POST /test?sleep=800 HTTP/1.1xxxxx(69 bytes more)>

How Has This Been Tested?

Running tool: /usr/local/go/bin/go test -timeout 60m -run ^TestTextEvent$ github.com/Kindling-project/kindling/collector/pkg/model

=== RUN   TestTextEventa
--- PASS: TestTextEvent (0.00s)
PASS
ok      github.com/Kindling-project/kindling/collector/pkg/model        0.010s

Here is some examples.

{Name:read Category:3 ParamsNumber:3 UserAttributes:[starttime:1666085694803271345 data:<POST /test?sleep=800 HTTP/1.1...Host: 10.10.103.148:9000...Content-Type: application/x-www-form-urlencoded ...xxxxjkajdnaksndandlkajelkqjweklqwjeklqjlwejklasdas...qwelkqnmwlkenqlwenqwnekqkwelkqmnwlekq(69 bytes more)>] Ctx:{ThreadInfo:{Pid:22592 Tid:22592 Uid:0 Gid:0 Comm:node ContainerId:123123 ContainerName:test} FdInfo:{Num:19 TypeFd:3 Filename:tmp Directory:/root Protocol:1 Role:true Sip:[16777343] Dip:[16777343] Sport:39620 Dport:37093 Source:0 Destination:0}} Latency:100 Timestamp:160000}

Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
@NeJan2020 NeJan2020 requested a review from dxsup February 17, 2023 03:19
@dxsup
Copy link
Member

dxsup commented Feb 17, 2023

Only print char in [a-zA-Z0-9] and . / \ @ ? - = for ByteBuffer now, other char will be replaced by ,

I think . is better because Sysdig does like it which we have been familiar with.

and the max length is 80

80 is not enough since we set SNAPLEN to 1000 by default. We better set the max length to 200 at least and add a sign if there are more than 200 bytes to explicitly tell users we truncate the bytes - maybe we could add an xxx bytes more sign at the tail.

@dxsup dxsup force-pushed the fix-improve-cgoreceiver-log-format branch from 6bc413c to 9efcbfd Compare February 17, 2023 07:45
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
dxsup
dxsup previously approved these changes Feb 17, 2023
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
@dxsup dxsup merged commit 5024e33 into KindlingProject:main Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants