AWS Kinesis Firehose lambda 如何向 ElasticSearch 发送更新和删除请求?
我没有看到 AWS Kinesis Firehose lambda 如何向 ElasticSearch(AWS OpenSearch 服务)发送更新和删除请求。
Elasticsearch 文档 API 提供 CRUD 操作: https://www.elastic.co/guide/en/ elasticsearch/reference/current/docs.html
我找到的示例涉及 Create 案例,但没有显示如何执行 delete
或 update
请求。 https://aws.amazon.com/blogs/big-data/ingest-streaming-data-into-amazon-elasticsearch-service-within-the-privacy-of-your-vpc-with-amazon-kinesis -数据-firehose/ https://github.com/amazon-archives/serverless-app-examples/blob/master/python/kinesis-firehose-process-record-python/lambda_function.py
输出格式示例中没有显示指定 create
、update
或 delete
请求的方法:
output_record = {
'recordId': record['recordId'],
'result': 'Ok',
'data': base64.b64encode(payload)
}
除了示例之外,我没有找到定义kinesis firehose lambda 处理程序应返回的输出格式。
I'm not seeing how an AWS Kinesis Firehose lambda can send update and delete requests to ElasticSearch (AWS OpenSearch service).
Elasticsearch document APIs provides for CRUD operations:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html
The examples I've found deals with the Create case, but doesn't show how to do delete
or update
requests.
https://aws.amazon.com/blogs/big-data/ingest-streaming-data-into-amazon-elasticsearch-service-within-the-privacy-of-your-vpc-with-amazon-kinesis-data-firehose/
https://github.com/amazon-archives/serverless-app-examples/blob/master/python/kinesis-firehose-process-record-python/lambda_function.py
The output format in the examples do not show a way to specify create
, update
or delete
requests:
output_record = {
'recordId': record['recordId'],
'result': 'Ok',
'data': base64.b64encode(payload)
}
Apart from the examples, I'm not finding the definition of the output format for what the kinesis firehose lambda handler should return.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在您的案例 OpenSearch(ES) 中,Firehose 使用 lambda 函数来转换记录,然后将它们传送到目的地,因此它们仅用于修改数据结构,但不能用于影响 CRUD 操作。
Firehose 只能将记录插入到特定索引中。如果您需要一个简单的选项来在一段时间后从 ES 索引中删除记录,请在为 Firehose 流指定目标时查看“索引轮换”选项。
如果您想在 ES 中使用 CRUD 操作并继续使用 Firehose,我建议以原始格式将记录发送到 S3 存储桶,然后在对象上传事件上触发 lambda 函数,该函数将根据负载中的字段执行 CRUD 操作。
从 lambda https:/ 对 ES 执行 CRUD 操作的一个很好的示例/github.com/chankh/ddb-elasticsearch/blob/master/src/lambda_function.py
这个特定示例是为了将 DynamoDB 流中的数据发送到 ES 中而构建的,但这对您来说应该是一个很好的起点
Firehose uses lambda function to transform records before they are being delivered to the destination in your case OpenSearch(ES) so they are only used to modify the structure of the data but can't be used to influence CRUD actions.
Firehose can only insert records into a specific index. If you need a simple option to remove records from ES index after a certain period of time have a look at "Index rotation" option when specifying destination for your Firehose stream.
If you want to use CRUD actions with ES and keep using Firehose I would suggest to send records to S3 bucket in the raw format and then trigger a lambda function on object upload event that will perform a CRUD action depending on fields in your payload.
A good example of performing CRUD actions against ES from lambda https://github.com/chankh/ddb-elasticsearch/blob/master/src/lambda_function.py
This particular example is built to send data from DynamoDB streams into ES but it should be a good starting point for you
Firehose 只能插入到 ES 中。它不能进行更新和删除。如果您想要执行更新和删除,则需要编写一个从 Kinesis 流上的事件触发的 lambda
https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html
Firehose can only do inserts into ES. It cannot do updates and deletes. If you want to perform updates and deletes, you will need to write a lambda that is trgerred from events on the Kinesis stream
https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html
需要在开放搜索域查找粒度访问控制中授予 Crud 权限。
查看最新的开发人员指南:https://docs.aws.amazon .com/opensearch-service/latest/developerguide/fgac.html
请参阅教程:https://catalog.us-east-1.prod.workshops.aws/workshops/32e6bc9a-5c03-416d-be7c-4d29f40e55c4/en-US/lab-4/lab4-1-os
Crud permission needs to be granted in open search domain find-grained access control.
See latest developer guid: https://docs.aws.amazon.com/opensearch-service/latest/developerguide/fgac.html
See Tutorial: https://catalog.us-east-1.prod.workshops.aws/workshops/32e6bc9a-5c03-416d-be7c-4d29f40e55c4/en-US/lab-4/lab4-1-os