Elastic medium stable kql

GCP Vertex AI Response Blocked by Safety Filters

Detects Vertex AI GenerateContent responses whose candidate finish_reason is SAFETY. That value is emitted when Gemini safety filters stop generation. Unlike textual refusals (finish_reason STOP), SAFETY means the provider blocked or truncated the completion.

View Source

Detection Logic

from logs-gcp_vertexai.prompt_response_logs-* metadata _id, _version, _index
| where
    data_stream.dataset == "gcp_vertexai.prompt_response_logs" and
    MV_CONTAINS(gcp.vertexai.prompt_response_logs.full_response.candidates.finish_reason, "SAFETY")
| keep
    _id,
    _version,
    _index,
    @timestamp,
    cloud.project.id,
    gcp.vertexai.prompt_response_logs.model,
    gcp.vertexai.prompt_response_logs.api_method,
    gcp.vertexai.prompt_response_logs.full_request.contents.parts.text,
    gcp.vertexai.prompt_response_logs.full_request.safety_settings.category,
    gcp.vertexai.prompt_response_logs.full_request.safety_settings.threshold,
    gcp.vertexai.prompt_response_logs.full_response.candidates.finish_reason,
    gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.category,
    gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.probability,
    gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.severity

False Positives

  • ⚠ Aggressive safetySettings (for example BLOCK_LOW_AND_ABOVE) on red-team or content-moderation workloads can produce frequent SAFETY finishes. Exclude those projects or models, or require concurrent HIGH/MEDIUM ratings.

Field Validations

Loading…

Comments (0)

Loading comments...