本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Fluentd是一个开源数据收集生态系统,它提供了 SDKs 不同的语言和子项目,例如Fluent Bit。此示例 Fluentd 配置文件
请注意以下几点:
-
endpoint
值必须是管道端点。例如
。pipeline-endpoint
.us-east-1.osis.amazonaws.com/apache-log-pipeline/logs -
aws_service
值必须为osis
。 -
该
aws_role_arn
值是 AWS IAM 角色的 ARN,供客户端代入并用于签名版本 4 身份验证。
<source> @type tail path logs/sample.log path_key log tag apache <parse> @type none </parse> </source> <filter apache> @type record_transformer <record> log ${record["message"]} </record> </filter> <filter apache> @type record_transformer remove_keys message </filter> <match apache> @type http endpoint
pipeline-endpoint
.us-east-1
.osis.amazonaws.com/apache-log-pipeline/logs json_array true <auth> method aws_sigv4 aws_service osis aws_regionus-east-1
aws_role_arn arn:aws:iam::account-id
:role/ingestion-role
</auth> <format> @type json </format> <buffer> flush_interval 1s </buffer> </match>
然后,您可以配置如下所示的 OpenSearch 采集管道,该管道以 HTTP 为源:
version: "2"
apache-log-pipeline:
source:
http:
path: "/${pipelineName}/logs"
processor:
- grok:
match:
log:
- "%{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:network_node} %{NOTSPACE:network_host} %{IPORHOST:source_ip}:%{NUMBER:source_port:int} -> %{IPORHOST:destination_ip}:%{NUMBER:destination_port:int} %{GREEDYDATA:details}"
sink:
- opensearch:
hosts: ["https://search-domain-endpoint
.us-east-1
.es.amazonaws.com"]
index: "index_name
"
aws_sts_role_arn: "arn:aws:iam::account-id
:role/pipeline-role
"
aws_region: "us-east-1
"
aws_sigv4: true