CodexBloom - Programming Q&A Platform

OCI Load Balancer Auto-Scaling Not Triggering as Expected with Custom Metrics

👀 Views: 42 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
OracleCloud AutoScaling LoadBalancing Metrics Python

Hey everyone, I'm running into an issue that's driving me crazy... I'm upgrading from an older version and After trying multiple solutions online, I still can't figure this out... I'm working with an scenario with the OCI Load Balancer where the auto-scaling feature is not triggering as expected based on the custom metrics I've defined. I set up a load balancer with a backend set that has multiple instances, and I want to scale out when CPU utilization exceeds 70%. However, despite the CPU load being consistently over that threshold, no new instances are being launched. I've configured my auto-scaling policy in the OCI console like so: ```json { "name": "CPU-Scaling-Policy", "scalingConfiguration": { "dynamic": { "scalingPolicy": { "resourceType": "cpu", "metricName": "cpuUtilization", "operator": "GREATER_THAN", "threshold": 70, "adjustmentType": "CHANGE_IN_CAPACITY", "scalingAdjustment": 1, "cooldown": 300 } } } } ``` I also have a monitoring script that updates the CPU utilization metric every minute. This is the relevant part of the script that pushes the custom metric: ```python import oci from oci.monitoring import MonitoringClient client = MonitoringClient(config) namespace = 'my_namespace' metric_name = 'cpuUtilization' # Assuming cpu_util is calculated from your instance client.publish_metrics(namespace, [ oci.monitoring.models.MetricData( namespace=namespace, metric_name=metric_name, value=cpu_util, dimensions={ "instanceId": "your_instance_id" }, timestamp=datetime.utcnow().isoformat() + 'Z' ) ]) ``` I've confirmed that the metrics are being sent correctly to OCI as I can see them in the monitoring dashboard. However, the auto-scaling action remains dormant. I've checked the logs for any behavior messages but found nothing related to the scaling policies. Is there a specific configuration or additional steps I need to ensure that the auto-scaling is triggered properly? Any insights would be greatly appreciated. What am I doing wrong? Is this even possible? Any feedback is welcome!