diff --git a/packages/signed-api/deployment/cloudformation-template.json b/packages/signed-api/deployment/cloudformation-template.json index 22b45fb7..5c70c12a 100644 --- a/packages/signed-api/deployment/cloudformation-template.json +++ b/packages/signed-api/deployment/cloudformation-template.json @@ -11,6 +11,21 @@ "Type": "String", "MinLength": 5, "Description": "Auth token for Airnode feed." + }, + "grafanaLokiUser": { + "Type": "String", + "MinLength": 2, + "Description": "Username for authenticating Loki API" + }, + "grafanaLokiToken": { + "Type": "String", + "MinLength": 10, + "Description": "Token for authenticating Loki API" + }, + "grafanaLokiEndpoint": { + "Type": "String", + "MinLength": 10, + "Description": "Loki endpoint" } }, "Outputs": { @@ -40,6 +55,31 @@ "RequiresCompatibilities": ["FARGATE"], "ExecutionRoleArn": { "Ref": "ECSTaskRole" }, "ContainerDefinitions": [ + { + "Essential": true, + "Image": "grafana/fluent-bit-plugin-loki:2.9.1-amd64", + "Name": "SignedApiLogForwarder", + "FirelensConfiguration": { + "Type": "fluentbit", + "Options": { + "enable-ecs-log-metadata": "true" + } + }, + "LogConfiguration": { + "LogDriver": "awslogs", + "Options": { + "awslogs-group": { + "Ref": "SignedApiLogsGroup" + }, + "awslogs-region": { + "Ref": "AWS::Region" + }, + "awslogs-create-group": "true", + "awslogs-stream-prefix": "firelens" + } + }, + "MemoryReservation": 50 + }, { "Name": "signed-api-container", "Image": "", @@ -86,11 +126,33 @@ } ], "LogConfiguration": { - "LogDriver": "awslogs", + "LogDriver": "awsfirelens", "Options": { - "awslogs-group": { "Ref": "SignedApiLogsGroup" }, - "awslogs-region": { "Ref": "AWS::Region" }, - "awslogs-stream-prefix": "ecs" + "Name": "grafana-loki", + "Url": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "grafanaLokiUser" + }, + ":", + { + "Ref": "grafanaLokiToken" + }, + "@", + { + "Ref": "grafanaLokiEndpoint" + }, + "/loki/api/v1/push" + ] + ] + }, + "Labels": "{app=\"signed-api\",airnode=\"\"}", + "RemoveKeys": "container_id,container_name,ecs_task_definition,source,ecs_cluster", + "LabelKeys": "ecs_task_arn", + "LineFormat": "json" } } }