from logs-aws_bedrock.invocation-*
// Expand multivalued policy names
| mv_expand gen_ai.policy.name
// Filter for blocked profanity-related policy violations
| where
gen_ai.policy.action == "BLOCKED"
and gen_ai.compliance.violation_detected == "true"
and gen_ai.policy.name == "word_policy"
// keep relevant user field
| keep user.id
// count blocked profanity attempts per user
| stats
Esql.ml_policy_blocked_profanity_count = count()
by user.id
// Filter for excessive policy violations
| where Esql.ml_policy_blocked_profanity_count > 5
// sort by violation volume
| sort Esql.ml_policy_blocked_profanity_count desc
Install detection rules in Elastic Security
Detect Unusual High Word Policy Blocks Detected in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(opens in a new tab or window).