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

chore(logs): add output format option to karmor logs command #447

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

navin772
Copy link
Member

Fixes: #439

Introduced new flags for pretty and normal printing:

karmor logs --output json
karmor logs --output pretty-json
karmor logs --output text

Shorthand -> -o

The --json flag is still present:
karmor logs --json

Output:

$ ./karmor logs -o pretty-json

local port to be used for port forwarding kubearmor-relay-8464877449-sp5mt: 32816 
Created a gRPC client (localhost:32816)
Checked the liveness of the gRPC server
Started to watch alerts

{
  "Timestamp": 1719459063,
  "UpdatedTime": "2024-06-27T03:31:03.302163Z",
  "ClusterName": "default",
  "HostName": "navin",
  "HostPPID": 8384,
  "HostPID": 14768,
  "PPID": 8384,
  "PID": 14768,
  "UID": 1000,
  "ParentProcessName": "/usr/bin/bash",
  "ProcessName": "/usr/bin/date",
  "PolicyName": "hsp-kubearmor-dev-proc-path-block-fromsource",
  "Severity": "5",
  "Type": "MatchedHostPolicy",
  "Source": "/usr/bin/bash",
  "Operation": "Process",
  "Resource": "/usr/bin/date",
  "Data": "lsm=SECURITY_BPRM_CHECK",
  "Enforcer": "BPFLSM",
  "Action": "Block",
  "Result": "Permission denied",
  "Cwd": "/"
}

log/logClient.go Outdated Show resolved Hide resolved
@navin772 navin772 requested a review from daemon1024 June 27, 2024 15:20
log/logClient.go Outdated Show resolved Hide resolved
@navin772 navin772 requested a review from daemon1024 June 27, 2024 16:10
@daemon1024
Copy link
Member

Can we squash the commits please? Thanks

@DelusionalOptimist
Copy link
Member

@navin772 please rebase with upstream main once to fix the failing tests.

@navin772
Copy link
Member Author

@DelusionalOptimist all the tests are now passing.

@daemon1024
Copy link
Member

Please squash the commits 🙌 Rest LGTM

@navin772
Copy link
Member Author

@daemon1024 can you rebase and merge the PR, having some issues with squashing.

@daemon1024 daemon1024 merged commit 217e88d into kubearmor:main Jul 24, 2024
4 checks passed
@navin772 navin772 deleted the karmor-json-pretty branch July 24, 2024 12:31
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.

JSON output from karmor logs --json is not beautified
3 participants