renoki-co / laravel-helm-demo

Example of a horizontally-scaled Laravel 8 app that runs on Kubernetes with NGINX Ingress Controller.
https://github.com/renoki-co/charts/tree/master/charts/laravel
62 stars 16 forks source link

HPA unable to get metric phpfpm_process_utilization #27

Closed dreamci closed 2 years ago

dreamci commented 3 years ago

Hello,

I made a fresh deployment using ./helm/deploy.sh

I installed prometheus-adapter and prometheus extra charts.

Everything working well other than HPA

Here is the error:

The HPA was unable to compute the replica count: unable to get metric phpfpm_process_utilization: unable to fetch metrics from custom metrics API: the server could not find the metric phpfpm_process_utilization for pods

In http://localhost:9253/metrics

I can see the phpfpm_total_processes which was used in the calculation of custom metrics.

phpfpm_total_processes{pool="www",scrape_uri="tcp://127.0.0.1:9001/status"} 3

In prometheus adapter logs:

prometheus prometheus-adapter-6b8945c78-kcdwz prometheus-adapter E0625 16:01:26.278554 1 provider.go:227] unable to update list of all metrics: unable to fetch metrics for query "{name=~\"^container.*\",container!=\"POD\",namespace!=\"\",pod!=\"\"}": Get "http://prometheus-server.default.svc.cluster.local:9090/api/v1/series?match%5B%5D=%7B__name__%3D~%22%5Econtainer.%2A%22%2Ccontainer%21%3D%22POD%22%2Cnamespace%21%3D%22%22%2Cpod%21%3D%22%22%7D&start=1624636826.24": dial tcp: lookup prometheus-server.default.svc.cluster.local on 10.128.0.10:53: no such host

I changed http://prometheus-server.default.svc.cluster.local URL to localhost and also Cluster Ip but it did not help.

Are there additional settings I have to do?

Thanks

rennokki commented 3 years ago

Did you add the Prometheus annotation on the pods? https://www.weave.works/docs/cloud/latest/tasks/monitor/configuration-k8s/#per-pod-prometheus-annotations