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: Log request payload #53

Merged
merged 3 commits into from
Mar 26, 2024
Merged

Conversation

Sanskarzz
Copy link
Contributor

@Sanskarzz Sanskarzz commented Mar 15, 2024

when i executed with command curl -X POST -d '{"key": "value"}' -H "Content-Type: application/json" http://127.0.0.1:8000
The result where

sanskar@sanskar-HP-Laptop-15s-du1xxx:~/kyverno-envoy-plugin$ go run main.go 
Starting HTTP server on Port 8000
Starting GRPC server on Port 9000
Received request from 127.0.0.1:51952 /
Request payload: {"key": "value"}

Test with istio demo
Request -

sanskar@sanskar-HP-Laptop-15s-du1xxx:~/kyverno-envoy-plugin$ kubectl run test -it --rm --restart=Never --image=busybox -- wget -q --output-document - echo.demo.svc.cluster.local:8080/foo

If you don't see a command prompt, try pressing enter.
warning: couldn't attach to pod/test, falling back to streaming logs: Internal error occurred: error attaching to container: failed to load task: no running task found: task b774615d16d54e33d7853d49d28f35a29fe23d9967d2f88fb10515167b1eb836 not found: not found
{
  "path": "/foo",
  "headers": {
    "host": "echo.demo.svc.cluster.local:8080",
    "user-agent": "Wget",
    "x-forwarded-proto": "http",
    "x-request-id": "07e0fa25-e3f9-4a89-aaa5-e7dfb777e344",
    "x-b3-traceid": "3d63b0fd625a274ab26667455c817009",
    "x-b3-spanid": "b26667455c817009",
    "x-b3-sampled": "0"
  },
  "method": "GET",
  "body": "",
  "fresh": false,
  "hostname": "echo.demo.svc.cluster.local",
  "ip": "::ffff:127.0.0.6",
  "ips": [],
  "protocol": "http",
  "query": {},
  "subdomains": [
    "svc",
    "demo",
    "echo"
  ],
  "xhr": false,
  "os": {
    "hostname": "echo-6847f9f85-vpqqg"
  },
  "connection": {}
}pod "test" deleted

Log stream -

sanskar@sanskar-HP-Laptop-15s-du1xxx:~$ kubectl logs "$(kubectl get pod -l app=ext-authz -n demo -o jsonpath={.items..metadata.name})" -n demo -c ext-authz -f 
Starting HTTP server on Port 8000
Starting GRPC server on Port 9000
Header: :authority = echo.demo.svc.cluster.local:8080
Header: :scheme = http
Header: x-request-id = 07e0fa25-e3f9-4a89-aaa5-e7dfb777e344
Header: :path = /foo
Header: :method = GET
Header: x-forwarded-proto = http
Header: user-agent = Wget
Attributes: source:{address:{socket_address:{address:"10.244.0.11" port_value:50680}}} destination:{address:{socket_address:{address:"10.244.0.6" port_value:8080}}} request:{time:{seconds:1710516646 nanos:879496000} http:{id:"198740000404024245" method:"GET" headers:{key:":authority" value:"echo.demo.svc.cluster.local:8080"} headers:{key:":method" value:"GET"} headers:{key:":path" value:"/foo"} headers:{key:":scheme" value:"http"} headers:{key:"user-agent" value:"Wget"} headers:{key:"x-forwarded-proto" value:"http"} headers:{key:"x-request-id" value:"07e0fa25-e3f9-4a89-aaa5-e7dfb777e344"} path:"/foo" host:"echo.demo.svc.cluster.local:8080" scheme:"http" protocol:"HTTP/1.1"}} metadata_context:{} route_metadata_context:{}

Signed-off-by: Sanskarzz <[email protected]>
@Sanskarzz Sanskarzz requested a review from a team as a code owner March 15, 2024 12:49
@eddycharly eddycharly merged commit 72e1902 into kyverno:main Mar 26, 2024
6 checks passed
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