I have dockerize the microservice app and now using Kubernetes.
Sometimes container is running in healthy
state but there is a problem in microservice app so I have to get the app metrics.
Is it possible to get the metrics from outside the container/pod?
I would suggest designing your application using the Observability patter, basically, you will create a path, /metrics
for example, and you will hit this path every time you need the application's info. The path is populated of all the information you need (killed threads for example) This approach could be called withe box monitoring
: the application knows his status. Then you can either use tools like Prometheus to query the path and create alerts or just hit the path retrieving information which are exposed in the format you want to (json, yml, ecc). The path will be reached using a simple web server, may be integrated into the application as well. Exposing the container port 80
you can basically run a simple curl http://<container name | localhost>/metrics
getting all the information you need. You can find a bunch of library you can integrate into your application.
To monitor your cluster you can use kube-prometheus. Additionally you can setup metrics-server and get your pod metrics by running
kubectl top pod --namespace=NAMESPACE