Amazon bietet diese Readymade-Dateien zum Senden von Tomcat/Apache/nginx-Logs an Cloudwatch Logs, die großartig funktionieren.Wie können Sie node.js-Protokolle von der Anwendung "Elastic Beanstalk Docker" an Cloudwatch-Protokolle senden?
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.cloudwatchlogs.html
aber für meine Zwecke senden sie nur nginx Protokolle, die nicht wirklich ausreichend ist und leider auch Null-Dokumentation auf dem Dateiformat sie bieten. Ich versuche, node.js-Protokolle von meiner Docker-Anwendung an Cloudwatch zu senden (da Autoscaling Instanzen kommen und gehen lässt).
So haben Dateien wie /var/log/eb-docker/containers/eb-current-app/add839a3b599-stdouterr.log
in Cloudwatch erscheinen.
Also, was ich bisher versucht, ist die webrequests anpassen Config aus den obigen Link:
##############################################################################
## Sends docker logs to CloudWatch Logs
##############################################################################
Mappings:
CWLogs:
ApplicationLogGroup:
LogFile: "/var/log/eb-docker/containers/eb-current-app/*-stdouterr.log"
TimestampFormat: "%Y-%m-%d %H:%M:%S"
Outputs:
ApplicationLogGroup:
Description: "The name of the Cloudwatch Logs Log Group created for this environments web server access logs. You can specify this by setting the value for the environment variable: WebRequestCWLogGroup. Please note: if you update this value, then you will need to go and clear out the old cloudwatch logs group and delete it through Cloudwatch Logs."
Value: { "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0ApplicationLogGroup"}
Resources :
AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0ApplicationLogGroup: ## Must have prefix: AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0
Type: "AWS::Logs::LogGroup"
DependsOn: AWSEBBeanstalkMetadata
DeletionPolicy: Retain ## this is required
Properties:
LogGroupName:
"Fn::GetOptionSetting":
Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: ApplicationLogGroup
DefaultValue: {"Fn::Join":["-", [{ "Ref":"AWSEBEnvironmentName" }, "stdouterr"]]}
RetentionInDays: 14
## Register the files/log groups for monitoring
AWSEBAutoScalingGroup:
Metadata:
"AWS::CloudFormation::Init":
CWLogsAgentConfigSetup:
files:
## any .conf file put into /tmp/cwlogs/conf.d will be added to the cwlogs config (see cwl-agent.config)
"/tmp/cwlogs/conf.d/stdouterr.conf":
content : |
[stdouterr]
file = `{"Fn::FindInMap":["CWLogs", "ApplicationLogGroup", "LogFile"]}`
log_group_name = `{ "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0ApplicationLogGroup" }`
log_stream_name = {instance_id}
datetime_format = `{"Fn::FindInMap":["CWLogs", "ApplicationLogGroup", "TimestampFormat"]}`
mode : "000400"
owner : root
group : root
Leider ist dieses nicht zu funktionieren scheinen. :/
Hat auch jemand eine Idee, wenn Protokolle überhaupt erscheinen, wenn fe. Das Timestamp-Format ist falsch? Besonders wichtig, da Ausnahmen standardmäßig keine Zeitstempel haben, so dass die tatsächlichen Fehler einfach verschwinden würden.
Meine Anwendung Protokollzeilen sehen zur Zeit wie folgt aus: 2016-07-05 09:11:31 ::1 - GET/200 (5.107 ms)
es ist eine große Frage, und es ist wirklich absurd, dass Amazon macht dieses Gehirn nicht einfach zu machen, oder warum sie Standard-Nginx oder Proxy-Logs standardmäßig in ihrem Beispiel gewählt. Danke für die Bestätigung, dass ich nicht verrückt bin, dasselbe zu wollen und zu erwarten ;-) – wkhatch