有没有人创建过一个无服务器函数,让CloudWatch在本地将输出记录到ElasticSearch?我想知道是否有一种方法可以在yml中配置function方法以输出到已经存在的ES集群。
或者有没有一种方法可以将CloudWatch流(通过无服务器)连接到lambda函数,然后该函数可以将解析的日志发送到ES。
发布于 2020-07-04 17:52:03
我通过使用Serverless创建ES集群并导出ARN来实现这一点。同样的无服务器服务还创建了“解析”lambda,它将处理所有Cloudwatch输出日志并传输到ES。然后,我转到向Cloudwatch写入数据的服务,在本例中是一个ECS集群,并创建了一个写入到该lambda的SubscriptionFilter,该SubscriptionFilter随后写入到ES。下面是创建ES集群的无服务器YML文件的一部分。然后是ECS YML中的SubscriptionFilter
ElasticSearchInstance:
Type: AWS::Elasticsearch::Domain
Properties:
AdvancedOptions:
rest.action.multi.allow_explicit_index: "true"
CognitoOptions:
Enabled: True
IdentityPoolId:
Ref: CognitoIdentityPool
RoleArn:
Fn::ImportValue: CognitoAccessRoleForAmazonESArn
UserPoolId:
Ref: CognitoUserPool
DomainName: "name-of-my-es-cluster-${env:ENV}"
EBSOptions:
EBSEnabled: true
VolumeType: gp2
VolumeSize: 10
ElasticsearchClusterConfig:
InstanceType: t2.small.elasticsearch
InstanceCount: 1
DedicatedMasterEnabled: false
ZoneAwarenessEnabled: false
ElasticsearchVersion: 7.4 ECSESParsingLamba:
Type: AWS::Logs::SubscriptionFilter
Properties:
DestinationArn:
Fn::ImportValue: !Sub "parsing-lambda-name-${Environment}"
FilterPattern: "[message]"
LogGroupName: !Ref LogGroupNamehttps://stackoverflow.com/questions/62055637
复制相似问题