6
是否有任何可能的解決方案將運行在Elastic Beanstalk上的應用程序的Node.JS日誌流式傳輸到Amazon CloudWatch?AWS EB Node.JS登錄到CloudWatch
我確實看到了cwl-webrequest-metrics.config文件,但沒有關於格式的信息我無法格式化它以將Node.JS日誌(僅)傳送到CloudWatch。
那你提前發表您的意見!
是否有任何可能的解決方案將運行在Elastic Beanstalk上的應用程序的Node.JS日誌流式傳輸到Amazon CloudWatch?AWS EB Node.JS登錄到CloudWatch
我確實看到了cwl-webrequest-metrics.config文件,但沒有關於格式的信息我無法格式化它以將Node.JS日誌(僅)傳送到CloudWatch。
那你提前發表您的意見!
問題是有點老了,但對於那些你從谷歌的到來,這裏是爲Node.js的工作.ebextension配置日誌灑進的CloudWatch:
# Store Node.JS Application Logs in Cloudwatch
Mappings:
CWLogs:
NodeJSLogGroup:
LogFile: "/var/log/nodejs/nodejs.log"
TimestampFormat: "%d/%b/%Y:%H:%M:%S %z"
Outputs:
NodeJSCWLogGroup:
Description: "Node.JS Application Logs"
Value: { "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0NodeJSLogGroup"}
Resources :
AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0NodeJSLogGroup: ## 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: NodeJSCWLogGroup
DefaultValue: {"Fn::Join":["-", [{ "Ref":"AWSEBEnvironmentName" }, "nodejs"]]}
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/nodejs.conf":
content : |
[nodjs-log]
file = `{"Fn::FindInMap":["CWLogs", "NodeJSLogGroup", "LogFile"]}`
log_group_name = `{ "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0NodeJSLogGroup" }`
log_stream_name = {instance_id}
datetime_format = `{"Fn::FindInMap":["CWLogs", "NodeJSLogGroup", "TimestampFormat"]}`
mode : "000400"
owner : root
group : root
看起來http://serebrov.github.io/html/2015-05-20-cloudwatch-setup.html可能是一個很好的參考,以及。
可以請您詳細闡述一下流,你想像我們做「tail -f/logs」嗎? – abaid778
我只想將/var/log/nodejs/nodejs.log從EB自動流式傳輸到CloudWatch,那就是它。 – Alexey
這裏有什麼進展? – user1791139