繁体   English   中英

如何使用 Fluentbit 将 AWS ECS 连接到 ElasticSearch?

[英]How do I connect AWS ECS to ElasticSearch with Fluentbit?

我想将我的 AWS ECS 与 Elasticsearch 连接。我编写了一个 Pulumi 脚本,其中我 > shuold 使用 fluentbit docker 组件作为我的前端和后端应用程序组件前端和后端的边车。 Pulumi 脚本如下所示:

import * as awsx from "@pulumi/awsx";
export const backendLb = new awsx.lb.ApplicationListener("backend-loadbalance", { port: 80 });
export const frontendLb = new awsx.lb.ApplicationListener("frontend-loadbalance", { port: 80, protocol:"HTTP" });
 export const service = new awsx.ecs.FargateService("backend", {
    taskDefinitionArgs: {   
                          containers: {  
                                         logRuter: {          
                                         
                                           image: "docker.io/amazon/aws-for-fluent-bit:latest",
                                           essential: true,
                                           firelensConfiguration: {
                                                                    "type": "fluentbit",
                                                                    "options":{
                                                                                 "enable-ecs-log-metadata":"true"
                                                                               }
                                                                   },
                                           logConfiguration: {
                                                                logDriver: "awslogs",
                                                                options: {
                                                                            "awslogs-create-group": "true",
                                                                            "awslogs-group": "fluent-bit-cloudwatch",
                                                                            "awslogs-region": "eu-north-1",
                                                                            "awslogs-stream-prefix": "ecs"
                                                                         }
                                                              },
                                            memoryReservation: 50
                                            },
                                           backend: { 
                                                       image: 'steinko/helloworld-backend',
                                                       portMappings: [ backendLb ],
                                                       logConfiguration: {
                                                                            logDriver: "awsfirelens",
                                                                            options: { 
                                                                                         "Name":"es",
                                                                                         "Port": "9243",
                                                                                         "Cloud_ID": "xxxxxxxxxx",
                                                                                         "Cloud_Auth":"elastic:xxxxxxxxxx",
                                                                                         "match":"*",
                                                                                         "Index": "backend",
                                                                                         "Type":"doc",
                                                                                         "tls": "On",
                                                                                         "tls.verify": "Off"
                                                                                         
                                                                                     }..............

的 CloudWatch 日志

2个

022-03-04T16:30:14.971+01:00    [1mFluent Bit v1.8.12[0m

2022-03-04T16:30:14.971+01:00   * [1m[93mCopyright (C) 2019-2021 The Fluent Bit Authors[0m

2022-03-04T16:30:14.971+01:00   * [1m[93mCopyright (C) 2015-2018 Treasure Data[0m

2022-03-04T16:30:14.971+01:00   * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd

2022-03-04T16:30:14.971+01:00   * https://fluentbit.io

2022-03-04T16:30:14.982+01:00   [2022/03/04 15:30:14] [ info] [engine] started (pid=1)

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [storage] version=1.1.5, initializing...

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [storage] in-memory

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [cmetrics] version=0.2.2

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [input:tcp:tcp.0] listening on 127.0.0.1:8877

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [input:forward:forward.1] listening on unix:///var/run/fluent.sock

2022-03-04T16:30:15.063+01:00   [2022/03/04 15:30:14] [ info] [input:forward:forward.2] listening on 127.0.0.1:24224

2022-03-04T16:30:15.164+01:00   [2022/03/04 15:30:15] [ info] [sp] stream processor started

2022-03-04T16:30:19.942+01:00   [2022/03/04 15:30:19] [error] [output:es:es.1] HTTP status=400 URI=/_bulk, response:

2022-03-04T16:30:19.942+01:00   {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_type]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_type]"},"status":400}

2022-03-04T16:30:19.942+01:00   [2022/03/04 15:30:19] [ warn] [engine] failed to flush chunk '1-1646407816.588524885.flb', retry in 7 seconds: task_id=0, input=forward.1 > output=es.1 (out_id=1)

2022-03-04T16:30:26.486+01:00   [2022/03/04 15:30:26] [error] [output:es:es.1] HTTP status=400 URI=/_bulk, response:

2022-03-04T16:30:26.486+01:00   {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_type]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_type]"},"status":400}

2022-03-04T16:30:26.486+01:00   [2022/03/04 15:30:26] [ warn] [engine] chunk '1-1646407816.588524885.flb' cannot be retried:

详细错误消息如下所示:

[2022/03/04 13:04:33] [error] [output:es:es.1] HTTP status=400 URI=/_bulk, response:


{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Action/metadata line [1] contains an unknown parameter [_type]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Action/metadata line [1] contains an unknown parameter [_type]"
    },
    "status": 400
}

我该如何解决这个错误

更新你的 fluent.conf 集

[OUTPUT]
    Name             es
    Match            *
    Host             efk-elastic
    Port             9200
    Logstash_format  on
    Replace_dots     on
    Retry_limit      false
    Type             doc
    Suppress_Type_Name On

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM