OCI Monitoring: Alerts Not Triggering for CPU Utilization in Custom Metric
I'm reviewing some code and I'm working on a project and hit a roadblock... I'm trying to set up an alert in Oracle Cloud Infrastructure (OCI) that triggers when CPU utilization exceeds a certain threshold for a compute instance. I created a custom metric for CPU usage but the alerts are not triggering as expected. My custom metric is being published to the monitoring service successfully since I can see the data points in the console. I'm using the following Python code to publish my custom metric: ```python import oci import time # Create a client client = oci.monitoring.MonitoringClient(config) # Publish a custom metric data point metric_data = oci.monitoring.models.DataPoint( timestamp=int(time.time()), value=75.0 ) custom_metric = oci.monitoring.models.MetricData( namespace='custom_namespace', metric_name='cpu_utilization', resource_id='your_resource_id', datapoints=[metric_data] ) response = client.put_metric_data(custom_metric) print(response) ``` I have also created the alert policy with the following parameters: - **Condition Type:** Greater than - **Threshold:** 70% - **Duration:** 5 minutes - **Compartment:** My compute instance's compartment However, the alerts are not triggering even when I know the CPU usage exceeds the threshold. I checked the alert policy status and it is enabled. I also reviewed the logs and they show no errors related to the alerting service. I wondered if there might be a delay in the metric data processing, but I have waited over 15 minutes and still nothing. Is there something I'm missing in the configuration or any best practices I should follow when setting up alerts for custom metrics? Any help would be appreciated! What am I doing wrong? I'm developing on Debian with Python. I'm using Python 3.9 in this project. Thanks, I really appreciate it!