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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

navin772
Copy link

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

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
2 participants