AWS Kinesis Firehose lambda 如何向 ElasticSearch 发送更新和删除请求?

发布于 2025-01-11 05:39:57 字数 1394 浏览 0 评论 0原文

我没有看到 AWS Kinesis Firehose lambda 如何向 ElasticSearch(AWS OpenSearch 服务)发送更新和删除请求。

Elasticsearch 文档 API 提供 CRUD 操作: https://www.elastic.co/guide/en/ elasticsearch/reference/current/docs.html

我找到的示例涉及 Create 案例,但没有显示如何执行 deleteupdate请求。 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

输出格式示例中没有显示指定 createupdatedelete 请求的方法:

       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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤君无依 2025-01-18 05:39:57

在您的案例 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

揪着可爱 2025-01-18 05:39:57

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文