How can I read cloudwatch logs using aws-sdkin nodejs?
I don't know how to init my config, where can I find any keys/endpoints to my cloudwatch ?
Can someone provide me some example?
import AWS from 'aws-sdk';
const cwInstance = new AWS.CloudWatchLogs({
.....?
})
import AWS from 'aws-sdk';
const cloudwatchlogs = new AWS.CloudWatchLogs({apiVersion: '2014-03-28'});
const params = {
logGroupName: 'STRING_VALUE', /* required */
logStreamName: 'STRING_VALUE', /* required */
endTime: 'NUMBER_VALUE',
limit: 'NUMBER_VALUE',
nextToken: 'STRING_VALUE',
startFromHead: true || false,
startTime: 'NUMBER_VALUE'
};
cloudwatchlogs.getLogEvents(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
For the more information check AWS documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With