awslabs / cloudwatch-logs-customize-alarms Goto Github PK
View Code? Open in Web Editor NEWA Lambda function that helps customize alarms from Amazon CloudWatch to fit your specific needs.
License: MIT No Attribution
A Lambda function that helps customize alarms from Amazon CloudWatch to fit your specific needs.
License: MIT No Attribution
This issue is with respect to another issue I had logged a few days ago [https://github.com//issues/292].
I am invoking a lambda from another lambda using python SDK. Both the lambdas belong to the same VPC. The trigger lambda only contains a python script that invokes the second lambda (loader_development) and the code for that is as under:
from __future__ import print_function
import json
import logging
import os
from urllib2 import urlopen,Request,HTTPError
import boto3
import botocore.config
logger = logging.getLogger()
logger.setLevel(logging.INFO)
region = os.environ['AWS_REGION']
cfg = botocore.config.Config(retries={'max_attempts': 0})
def lambda_handler(event, context):
logger.info('starting loading')
invokeLambda = boto3.client('lambda', region_name = 'us-east-1', config=cfg)
request = {'resource':'/bucketstatus/latest','path':'/bucketstatus/latest','httpMethod':'GET', 'requestContext': {'requestId': context.aws_request_id,'identity': {'userArn': context.invoked_function_arn}}}
invoke_response = invokeLambda.invoke(FunctionName='loader_development',
InvocationType='RequestResponse',
Payload=json.dumps(request))
print(invoke_response['Payload'].read())
logger.info('Process Complete')
But, "starting loading" is printing thrice so I think this script is getting invoked thrice. Previously only the loader_development lambda was being retried for which I set the value of max retry attempts to 0. (FYI: I have a cloudwatch event enabled for my trigger cron(0/30 7-9 * * ? *) so does the cloudwatch event also have a retry mechanism?) How do I disable this cloudwatch event from triggering my script more than once?
P.S. This code works if I don't have a scheduled cloudwatch event.
Getting the below error while executing lambda.
TypeError: Cannot read property '0' of undefined
at exports.handler (/var/task/index.js:8:43)
however we used the same index.js file and updated the mail IDs in SES section. Please suggest, for the error.
I am trying to get CloudWatchLogs filterLogEvents by sending parameters. some times it work and sends me the exact logs in that time, but for the different lambda function it returns empty events with next token.
parameters = {
'logGroupName' : metricFilter.logGroupName, 'filterPattern' : metricFilter.filterPattern ? metricFilter.filterPattern : "", 'startTime' : timestamp - offset, 'endTime' : timestamp };
i am retrying by sending parameters with next token but its still getting empty events. Does anyone has idea about it?
{
"events": [],
"searchedLogStreams": [],
"nextToken": "long text"
}
import * as AWS from 'aws-sdk';
var cwl = new AWS.CloudWatchLogs();
....
var requestParams = {
metricName: message.Trigger.MetricName,
metricNamespace: message.Trigger.Namespace
};
console.log('describeMetricFilters', requestParams);
const logEvents = await cwl.describeMetricFilters(requestParams, function(err, data) {
if(err) {
console.log('Error is:', err);
} else {
console.log('Metric Filter data is:', data);
getLogsAndSendEmail(message, data);
}
}).promise();
console.log("logEvents...", logEvents);
Log in CloudWatch
INFO Metric Filter data is: { metricFilters: [] }
I would love to see an SMTP option so this could be used in places where SES is not easily accessible like GovCloud.
TypeError: Cannot read property 'MetricName' of undefined at exports.handler (/var/task/index.js:14:36)
please suggest with this error when executing the script
Thanks
VJ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.