0

I created an express app and deployed to Google kubernetes. I can see the workload there and access the app using the service URL.

How can I see the traffic information with the status code? E.g. the number of times the API is hit with status code such as 2xx, 4xx, 5xx, etc?

Thanks.

AlirezaK
  • 316
  • 3
  • 20
Mohd Shahid
  • 101
  • 1

3 Answers3

0

I think you are asking for how to see response codes of your deployed app, rather than response codes of the K8s APIserver.

This looks like something you would get out of using Istio. Istio does inspection of http[s] API calls and reports metrics like response codes, latency, and throughput.

0

You can instrument your app to export metrics to Prometheus. I recommend you deploy Prometheus with Prometheus operator, and then integrate it into your app with the nodejs client lib.

You can also take a look at Stackdriver monitoring, if you want a more ready-made product, but it'll be less flexible.

Dirbaio
  • 223
  • 1
  • 6
-1

Kube-apiserver performs auditing.

Based on audit policy you can define what events should be recorded and what data they should include.

None - don’t log events that match this rule.

Metadata - log request metadata (requesting user, timestamp, resource, verb, etc.) but not request or response body.

Request - log event metadata and request body but not response body. This does not apply for non-resource requests.

RequestResponse - log event metadata, request and response bodies. This does not apply for non-resource requests.

You can pass a file with the policy to kube-apiserver using the --audit-policy-file flag

Here is an example of the policy manifest

To read audit logs on GKE you should

1) start proxy to your API server

kubectl proxy

2) curl a log file

curl http://127.0.0.1:8001/logs/kube-apiserver-audit.log
A_Suh
  • 324
  • 1
  • 7