Git Product home page Git Product logo

cloudwatch-logs-customize-alarms's Issues

AWS python SDK getting invoked more than once with scheduled cloudwatch event

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.

CloudWatchLogs filterLogEvents empty events

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"
}

describeMetricFilters() returns empty response


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: [] }

SMTP Option

I would love to see an SMTP option so this could be used in places where SES is not easily accessible like GovCloud.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.