from logs-aws_bedrock.invocation-*
// Filter for access denied errors from GenAI responses
| where gen_ai.response.error_code == "AccessDeniedException"
// keep ECS and response fields
| keep
user.id,
gen_ai.request.model.id,
cloud.account.id,
gen_ai.response.error_code
// count total denials per user/model/account
| stats
Esql.ml_response_access_denied_count = count(*)
by
user.id,
gen_ai.request.model.id,
cloud.account.id
// Filter for users with repeated denials
| where Esql.ml_response_access_denied_count > 3
// sort by volume of denials
| sort Esql.ml_response_access_denied_count desc
Install detection rules in Elastic Security
Detect AWS Bedrock Detected Multiple Attempts to use Denied Models by a Single User 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).