gpt4 book ai didi

amazon-web-services - AWS ElasticSearch 不接受某些 CloudTrail 文档

转载 作者:行者123 更新时间:2023-12-03 01:10:15 24 4
gpt4 key购买 nike

更新2
我被指出了这个项目。我会按照我喜欢的解决方案来实现它。
https://github.com/chariotsolutions/aws-examples/tree/trunk/cloudtrail_to_elasticsearch

原问题:
某些类型的 AWS CloudTrail 事件不会到达 AWS ElasticSearch。最后,我缩小到一个非常简化的失败的 JSON 文档,在这一点上,我可以使用一些见解。
所以尽管如此,我还是 POST some-random-index-every-time/_doc

POST ddd/_doc
{
"eventVersion": "1.05",
"eventTime": "2020-10-21T00:37:26Z",
"eventSource": "s3.amazonaws.com",
"eventName": "PutBucketPolicy",
"awsRegion": "eu-central-1",
"errorCode": "AccessDenied",
"errorMessage": "Access Denied",
"requestParameters": {
"bucketPolicy": {
"Version": "2012-10-17",
"Statement": [
{
"Principal": {
"Service": "logs.eu-central-1.amazonaws.com"
}
},
{
"Principal": {
"Service": "logs.eu-central-1.amazonaws.com"
}
},
{
"Principal": {
"AWS": [
"arn:aws:iam::1234567890:root"
]
}
},
{
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::1234567890:root"
]
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::whatever/*"
},
{
"Sid": "ProtectLogs",
"Effect": "Deny",
"Principal": "*"
}
]
}
}
}
我一直收到同样的错误:
{
"type": "illegal_argument_exception",
"reason": "mapper [requestParameters.bucketPolicy.Statement.Principal] of different type, current_type [text], merged_type [ObjectMapper]"
}
如果我从 JSON 中删除此 block - 文档被接受:
{
"Sid": "ProtectLogs",
"Effect": "Deny",
"Principal": "*"
}
更新 1 :
我想我应该创建一个模板并为这个字段定义一个映射,这样 ES 就不会混淆

最佳答案

问题是由于 Principal存在于同一级别但在您的第一个 block 中其类型为 object 的字段像下面

   {
"Principal": {
"Service": "logs.eu-central-1.amazonaws.com"
}
},
在最后一个 block 中,当您删除它时,它的类型为 text ,这会导致问题和错误消息也非常清晰,并提示合并类型不兼容, textobject类型。
您可以尝试将字段重命名为 Principal_new,而不是删除 block 。它会起作用,否则为所有索引字段创建一个静态映射/模板,这样这些字段就不会混淆,您已经猜到了

关于amazon-web-services - AWS ElasticSearch 不接受某些 CloudTrail 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64455425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com