change format logs for CloudWatch

This commit is contained in:
Alexey Bannov 2022-11-08 15:37:52 +03:00
parent dfb1509961
commit 991620468d
11 changed files with 35 additions and 43 deletions

View File

@ -54,17 +54,15 @@ var options = {
cloudWatch: {
name: 'aws',
level: "debug",
logGroupName: () => {
const hostname = os.hostname();
return logGroupName.replace("${instance-id}", hostname);
},
logStreamName: () => {
const hostname = os.hostname();
const now = new Date();
const guid = randomUUID();
const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss');
return logStreamName.replace("${guid}", guid)
return logStreamName.replace("${hostname}", hostname)
.replace("${applicationContext}", "SocketIO")
.replace("${guid}", guid)
.replace("${date}", dateAsString);
},
awsRegion: awsRegion,

View File

@ -8,7 +8,7 @@
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroupName": "/docspace/ASC.SocketIO/instances/${instance-id}/general",
"logStreamName": "${guid} - ${date}"
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
}
}

View File

@ -77,17 +77,15 @@ if (aws != null && aws.accessKeyId !== '')
transports.push(new WinstonCloudWatch({
name: 'aws',
level: "debug",
logGroupName: () => {
const hostname = os.hostname();
return logGroupName.replace("${instance-id}", hostname);
},
logStreamName: () => {
const hostname = os.hostname();
const now = new Date();
const guid = randomUUID();
const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss');
return logStreamName.replace("${guid}", guid)
return logStreamName.replace("${hostname}", hostname)
.replace("${applicationContext}", "SsoAuth")
.replace("${guid}", guid)
.replace("${date}", dateAsString);
},
awsRegion: awsRegion,

View File

@ -68,7 +68,7 @@
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroupName": "/docspace/ASC.SsoAuth/instances/${instance-id}/general",
"logStreamName": "${guid} - ${date}"
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
}
}

View File

@ -54,17 +54,15 @@ var options = {
cloudWatch: {
name: 'aws',
level: "debug",
logGroupName: () => {
const hostname = os.hostname();
return logGroupName.replace("${instance-id}", hostname);
},
logStreamName: () => {
const hostname = os.hostname();
const now = new Date();
const guid = randomUUID();
const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss');
return logStreamName.replace("${guid}", guid)
return logStreamName.replace("${hostname}", hostname)
.replace("${applicationContext}", "UrlShortener")
.replace("${guid}", guid)
.replace("${date}", dateAsString);
},
awsRegion: awsRegion,

View File

@ -8,7 +8,7 @@
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroupName": "/docspace/ASC.UrlShortener/instances/${instance-id}/general",
"logStreamName": "${guid} - ${date}"
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
}
}

View File

@ -64,17 +64,15 @@ if (aws != null && aws.accessKeyId !== '')
transports.push(new WinstonCloudWatch({
name: 'aws',
level: "debug",
logGroupName: () => {
const hostname = os.hostname();
return logGroupName.replace("${instance-id}", hostname);
},
logStreamName: () => {
const hostname = os.hostname();
const now = new Date();
const guid = randomUUID();
const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss');
return logStreamName.replace("${guid}", guid)
return logStreamName.replace("${hostname}", hostname)
.replace("${applicationContext}", "WebDav")
.replace("${guid}", guid)
.replace("${date}", dateAsString);
},
awsRegion: awsRegion,

View File

@ -57,8 +57,8 @@ module.exports = {
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroupName": "/docspace/ASC.WebDav/instances/${instance-id}/general",
"logStreamName": "${guid} - ${date}"
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
},
method: {

View File

@ -8,7 +8,7 @@
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroupName": "/docspace/ASC.WebPlugins/instances/${instance-id}/general",
"logStreamName": "${guid} - ${date}"
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
}
}

View File

@ -54,17 +54,15 @@ const options = {
cloudWatch: {
name: 'aws',
level: "debug",
logGroupName: () => {
const hostname = os.hostname();
return logGroupName.replace("${instance-id}", hostname);
},
logStreamName: () => {
const hostname = os.hostname();
const now = new Date();
const guid = randomUUID();
const dateAsString = date.format(now, 'YYYY/MM/DDTHH.mm.ss');
return logStreamName.replace("${guid}", guid)
return logStreamName.replace("${hostname}", hostname)
.replace("${applicationContext}", "WebPlugins")
.replace("${guid}", guid)
.replace("${date}", dateAsString);
},
awsRegion: awsRegion,
@ -92,7 +90,7 @@ const customFormat = winston.format(info => {
const now = new Date();
info.date = date.format(now, 'YYYY-MM-DD HH:mm:ss');
info.applicationContext = "ASC.WebPlugins";
info.applicationContext = "WebPlugins";
info.level = info.level.toUpperCase();
const hostname = os.hostname();

View File

@ -17,10 +17,11 @@
<target name="web" type="File" fileName="${var:dir}${var:name}.log" />
<target name="sql" type="File" fileName="${var:dir}${var:name}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=elapsed}|${replace:inner=${event-properties:item=commandText}:searchFor=\\r\\n|\\s:replaceWith= :regex=true}|${event-properties:item=parameters}"/>
<target name="ownFile-web" type="File" fileName="${var:dir}${var:name}.asp.log" layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
<target type="AWSTarget" name="aws" logGroup="/docspace/${var:name}/instance/instance_id/general" region="us-east-1" LibraryLogFileName="">
<target type="AWSTarget" name="aws" logGroup="/asc/docspace/cluster/cluster_name/general" region="us-east-1" LogStreamNamePrefix="${hostname} - ${application-context}">
<layout xsi:type="JsonLayout" includeAllProperties="true">
<attribute name="date" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="instanceId" layout="${hostname}"/>
<attribute name="applicationContext" layout="${application-context}"/>
<attribute name="sourceContext" layout="${logger}"/>
<attribute name="threadId" layout="${threadid}"/>
@ -28,9 +29,10 @@
<attribute name="exception" layout="${exception:format=ToString}" />
</layout>
</target>
<target type="AWSTarget" name="aws_sql" logGroup="/docspace/${var:name}/instance/instance_id/sql" region="us-east-1" LibraryLogFileName="">
<target type="AWSTarget" name="aws_sql" logGroup="/asc/docspace/cluster/cluster_name/sql" region="us-east-1" LogStreamNamePrefix="${hostname} - ${application-context}">
<layout xsi:type="JsonLayout" includeAllProperties="true">
<attribute name="date" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}" />
<attribute name="instanceId" layout="${hostname}"/>
<attribute name="applicationContext" layout="${application-context}"/>
<attribute name="sourceContext" layout="${logger}"/>
<attribute name="threadId" layout="${threadid}"/>