mvysny / shepherd-java-client

Vaadin Shepherd Java Client
Apache License 2.0
1 stars 1 forks source link

Memory/CPU stats of given app #2

Closed mvysny closed 1 year ago

mvysny commented 1 year ago

Obtain the stats from Kubernetes somehow

mvysny commented 1 year ago

mkctl top gets the most current stats (no history):

mkctl top pod deployment-59b67fd4c5-2sdmw --namespace shepherd-vaadin-boot-example-gradle --containers
POD                           NAME   CPU(cores)   MEMORY(bytes)   
deployment-59b67fd4c5-2sdmw   main   2m           126Mi

2m = 2 millicore = 0,2% CPU usage

There's possibility to access the Kubernetes Metrics API, explore.

mvysny commented 1 year ago

The Kubernetes metrics-service can be accessed as described at https://www.datadoghq.com/blog/how-to-collect-and-graph-kubernetes-metrics/

mkctl get --raw /apis/metrics.k8s.io/v1beta1/namespaces/shepherd-vaadin-boot-example-gradle/pods/deployment-59b67fd4c5-2sdmw
{"kind":"PodMetrics","apiVersion":"metrics.k8s.io/v1beta1","metadata":{"name":"deployment-59b67fd4c5-2sdmw","namespace":"shepherd-vaadin-boot-example-gradle","creationTimestamp":"2023-05-27T19:36:47Z","labels":{"app":"pod","pod-template-hash":"59b67fd4c5"}},"timestamp":"2023-05-27T19:36:40Z","window":"17s","containers":[{"name":"main","usage":{"cpu":"1247529n","memory":"129264Ki"}}]}

Provides no access to the 15min history of CPU/mem usage which the Dashboard can access.

mvysny commented 1 year ago

There's Dashboard Metrics Scraper which keeps last 15 minutes of history for Dashboard, but I couldn't find any documentation on how to access it programmatically. Home page: https://github.com/kubernetes-sigs/dashboard-metrics-scraper