# The search behind each alarm, saved in the tenancy under the alarm's own # name, and one for model calls. locals { # Inference operation names, as the SDK gives them. Oracle does not say # whether Audit records them, so there is a search here and no alarm. inference_events = ["Chat", "EmbedText", "RerankText", "ApplyGuardrails"] saved = merge( { for k, d in local.detections : "ai-${k}" => { description = d.body query = "search \"${var.tenancy_ocid}/_Audit_Include_Subcompartment\" | where ${local.conditions[k]} | sort by datetime desc" } }, { "ai-inference-calls" = { description = "Model calls, if Audit records them. Oracle does not document whether inference calls reach Audit, and the Agents runtime also names its calls Chat. Check that one test call appears before relying on this." query = "search \"${var.tenancy_ocid}/_Audit_Include_Subcompartment\" | where ${join(" or ", [for e in local.inference_events : "data.eventName='${e}'"])} | sort by datetime desc" } }, ) } resource "oci_logging_log_saved_search" "ai" { for_each = local.saved compartment_id = var.tenancy_ocid name = each.key description = each.value.description query = each.value.query freeform_tags = local.tags }