我根据这位医生创建了ECS集群
我使用的是CloudFormation模板:
AWSTemplateFormatVersion: "2010-09-09"
Resources:
# ...
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Sub "${Application}-${Env}"
ExecutionRoleArn:
Fn::ImportValue:
!Sub "${Env}-TaskExecutionRole"
Cpu: 256
Memory: 256
ContainerDefinitions:
- Name: nextjs
Image: nextjs
DependsOn:
- containerName: log_router
condition: START
Essential: true
LogConfiguration:
LogDriver: awsfirelens
Options:
Name: loki
Url: "http://loki.xxx.com/loki/api/v1/push"
Labels: "{job=\"firelens\"}"
RemoveKeys: "container_id,ecs_task_arn"
LabelKeys: "container_name,ecs_task_definition,source,ecs_cluster"
LineFormat: key_value
Links:
- log_router
- Name: nginx
Image: nginx
DependsOn:
- containerName: nextjs
condition: START
Essential: true
PortMappings:
- ContainerPort: 80
LogConfiguration:
LogDriver: awsfirelens
Options:
Name: loki
Url: "http://loki.xxx.com/loki/api/v1/push"
Labels: "{job=\"firelens\"}"
RemoveKeys: "container_id,ecs_task_arn"
LabelKeys: "container_name,ecs_task_definition,source,ecs_cluster"
LineFormat: key_value
Links:
- nextjs
- log_router
- Name: log_router
Image: grafana/fluent-bit-plugin-loki:latest
Essential: true
FirelensConfiguration:
Type: fluentbit
Options:
enable-ecs-log-metadata: true
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: firelens-container
awslogs-region: us-east-1
awslogs-create-group: true
awslogs-stream-prefix: firelens
memoryReservation: 50所有三个容器都已启动并正在运行,但我在CloudWatch中得到了以下错误消息:
无法加载输出插件“loki”
屏幕截图(对不起,但是当我把它作为图像添加时,它失败了):https://imgur.com/qnE0Cjd
而Grafana Loki是空的
哪里出错了?它是否与DependsOn或Links有关?
发布于 2021-02-25 15:59:39
因为同样的问题而挣扎。结果证明那些医生是错的。插件的名字是"grafana-loki",而不是像文档中所说的"loki“。也许这改变了一些时间,而文档只是过时了。
"logConfiguration": {
"logDriver": "awsfirelens",
"options": {
"Name": "grafana-loki",
"Url": "https://[...]/loki/api/v1/push",
"Labels": "{job=\"firelens\"}",
"RemoveKeys": "container_id,ecs_task_arn",
"LabelKeys": "container_name,ecs_task_definition,source,ecs_cluster",
"LineFormat": "key_value"
}
},https://stackoverflow.com/questions/65238675
复制相似问题