CloudWatch LogGroups Not Getting Created
See original GitHub issueMy lambda function is not attached to any VPC, Still It is not posting logs to cloudwatch.
Here is my code.
var exports = (module.exports = {});
const winston = require('winston');
const { createLogger, transports, format, error } = require('winston');
const WinstonCloudwatch = require('winston-cloudwatch');
const loggerFormat = format.combine(
format.errors({ stack: true }),
format.timestamp(),
format.metadata(),
format.json()
)
const consoleFormat = {
format: format.combine(
format.splat(),
format.simple(),
format.errors({ stack: true })
),
level: 'info',
handleExceptions: true,
json: false,
colorize: true
}
let S3StreamLogger = require('s3-streamlogger-daily').S3StreamLogger;
let date = new Date().toISOString().split('T')[0];
let s3_stream_access = new S3StreamLogger({
bucket: process.env.LOG_BUCKET,
folder: userID,
rotate_every: 'day',
name_format: '%Y-%m-%d-%H-%M-keylogs.log'
});
const logger = winston.createLogger({
level: 'info',
format: loggerFormat,
transports: [
//
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
//
new transports.Stream({
stream: s3_stream_access,
level: 'error'
}),
new WinstonCloudwatch({
logGroupName: 'stepp-application-logs',
exitOnError: false,
logStreamName: `${date}/test`,
createLogGroup: true,
createLogStream: true,
awsAccessKeyId : process.env.AWS_ACCESS_KEY_ID,
awsSecretKey: process.env.AWS_SECRET_ACCESS_KEY,
awsRegion: process.env.AWS_REGION,
jsonMessage: false,
awsOptions: {
logStreamName: process.env.AWS_REGION
},
retentionInDays: 365,
errorHandler: (err) => {
console.log(err);
},
level: 'info'
}),
new winston.transports.Console(consoleFormat)
]
})
winston.add(logger)
winston.debug('Hey man, I am here!')
exports.logger = logger;
```
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Why isn't the unified CloudWatch agent pushing log events?
If there's no log group or log stream, the CloudWatch agent creates them. Add any missing IAM permissions to the user policy or...
Read more >CloudWatch Log Group not automagically created #38 - GitHub
There's a small problem I'm having when using the module: The CloudWatch Log Group is only created when the Lambda Function tries to...
Read more >AWS CloudWatch - Log group does not exist - Stack Overflow
1 Answer 1 · The AWS Region specified in the Amazon Resource Name (ARN) is the same as your Lambda function's Region. ·...
Read more >How do I fix "Log group does not exist" errors for Lambda ...
How do I fix " Log group does not exist" errors for Lambda function logs in the CloudWatch console?
Read more >Lambda logging to CloudWatch seems to be broken?
I tried creating the group manually, but now I'm back where I was -- the lambda runs, I get local log output, but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok I see. I will close this ticket then, unless you’re willing to give more details, because this module is working on AWS Lambda for other users.
No. It did not work. I had to use this package “winston-aws-cloudwatch” to make it work.