|
| 1 | +--- |
| 2 | +title: Autoscaling Support for Addon Pods |
| 3 | +description: Documentation regarding addon pod autoscaling support for Azure Managed Prometheus. |
| 4 | +ms.topic: conceptual |
| 5 | +ms.date: 2/28/2024 |
| 6 | +ms.reviewer: rashmy |
| 7 | +--- |
| 8 | + |
| 9 | +# Horizontal Pod Autoscaling (HPA) for Collector Replica set |
| 10 | + |
| 11 | +### Overview |
| 12 | +Azure Managed Prometheus supports Horizontal Pod Autoscaling(HPA) for the ama-metrics replica set pod by default. |
| 13 | +The HPA allows the ama-metrics replica set pod, which scrapes Prometheus metrics with custom jobs, to scale automatically based on memory utilization to prevent OOMKills. By default, the HPA is configured with a minimum of two replicas and a maximum of 12 replicas. Users can configure the number of shards within the range of 2 to 12 replicas. |
| 14 | + |
| 15 | +[Kubernetes support for HPA](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) |
| 16 | + |
| 17 | +### Update Min and Max shards |
| 18 | +The HPA object named **ama-metrics-hpa** in the kube-system namespace can be edited to update the min and max shards/replica set instances. |
| 19 | +If the changes aren't within the supported range of 2 to 12 they are ineffective and fall back to the last known good. |
| 20 | + |
| 21 | +**Update Min replicas** |
| 22 | +```bash |
| 23 | +kubectl patch hpa ama-metrics-hpa -n kube-system --type merge --patch '{"spec": {"minReplicas": 4}}' |
| 24 | +``` |
| 25 | + |
| 26 | +**Update Max replicas** |
| 27 | +```bash |
| 28 | +kubectl patch hpa ama-metrics-hpa -n kube-system --type merge --patch '{"spec": {"maxReplicas": 10}}' |
| 29 | +``` |
| 30 | + |
| 31 | +**Update Min and Max replicas** |
| 32 | +```bash |
| 33 | +kubectl patch hpa ama-metrics-hpa -n kube-system --type merge --patch '{"spec": {"minReplicas": 3, "maxReplicas": 10}}' |
| 34 | +``` |
| 35 | + |
| 36 | +**or** |
| 37 | + |
| 38 | +The min and max replicas can also be edited by doing a **kubectl edit** and updating the spec in the editor |
| 39 | +```bash |
| 40 | +kubectl edit hpa ama-metrics-hpa -n kube-system |
| 41 | +``` |
| 42 | + |
| 43 | +### Update min and max shards to disable HPA scaling |
| 44 | +If the default HPA settings don't meet the customer's requirements, they can configure the minimum and maximum number of shards to be the same. |
| 45 | +This prevents the HPA from scaling the replicas based on varying loads, ensuring a consistent number of replicas. |
| 46 | + |
| 47 | +Ex - If the customer wants to set the shards to 8 and not have the HPA update the shards, update the min and max shards to 8. |
| 48 | + |
| 49 | +**Update Min and Max replicas** |
| 50 | +```bash |
| 51 | +kubectl patch hpa ama-metrics-hpa -n kube-system --type merge --patch '{"spec": {"minReplicas": 8, "maxReplicas": 8}}' |
| 52 | +``` |
| 53 | + |
| 54 | +*A kubectl edit on the ama-metrics-hpa spec gives more information about the scale up and scale down configurations used for HPA* |
| 55 | + |
| 56 | +## Next steps |
| 57 | + |
| 58 | +* [Troubleshoot issues with Prometheus data collection](prometheus-metrics-troubleshoot.md). |
0 commit comments