AWS Lambda gets executed 3 times The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceHow to pass a querystring or route parameter to AWS Lambda from Amazon API GatewayCan an AWS Lambda function call anotherCan't add s3 notification for lambda using boto3AWS lambda function ConnectionError when configured with VPCAWS IoT and Lambda RuleAWS Lambda recursive invocation works too good?S3 copy inside lambda function timing outAWS Lambda Timeouts randomlyAWS node.js lambda request dynamodb but no response (no err, no return data)Send Cloudwatch logs matching a pattern to SQS queue

Keeping a retro style to sci-fi spaceships?

Is this wall load bearing? Blueprints and photos attached

different output for groups and groups USERNAME after adding a username to a group

Word to describe a time interval

Is 'stolen' appropriate word?

What do I do when my TA workload is more than expected?

Am I ethically obligated to go into work on an off day if the reason is sudden?

Can the DM override racial traits?

Sort list of array linked objects by keys and values

How do spell lists change if the party levels up without taking a long rest?

Is there a writing software that you can sort scenes like slides in PowerPoint?

Match Roman Numerals

Working through the single responsibility principle (SRP) in Python when calls are expensive

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

US Healthcare consultation for visitors

How do I design a circuit to convert a 100 mV and 50 Hz sine wave to a square wave?

Are there continuous functions who are the same in an interval but differ in at least one other point?

Can we generate random numbers using irrational numbers like π and e?

1960s short story making fun of James Bond-style spy fiction

How to type a long/em dash `—`

60's-70's movie: home appliances revolting against the owners

What is the padding with red substance inside of steak packaging?



AWS Lambda gets executed 3 times



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceHow to pass a querystring or route parameter to AWS Lambda from Amazon API GatewayCan an AWS Lambda function call anotherCan't add s3 notification for lambda using boto3AWS lambda function ConnectionError when configured with VPCAWS IoT and Lambda RuleAWS Lambda recursive invocation works too good?S3 copy inside lambda function timing outAWS Lambda Timeouts randomlyAWS node.js lambda request dynamodb but no response (no err, no return data)Send Cloudwatch logs matching a pattern to SQS queue



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have created a Lambda that subscribes to a specific log group and gets triggered everytime the log group is updated.



However, for some reason the Lambda gets triggered three times instead of just one. The Lambda is supposed to export log files to a S3 Bucket, and since it's triggered three times it exports the same logs three times. My first thought was that the Lambda was timing out and therefor was triggered multiple times but I've checked the logs and the execution is successful every time, and every execution has a unique RequestId.



Any thoughts about this? Any help is appreciated.



This is what my Lambda looks like:



import boto3
from datetime import timedelta, datetime

def lambda_handler(event, context):
startTime = datetime.utcnow() - timedelta(hours = 2)
endTime = datetime.utcnow()
cloudwatch = boto3.client('logs')
response = cloudwatch.create_export_task(
taskName = 'LogExport',
logGroupName = '/aws/lambda/logGroupName',
fromTime = int(round(startTime.timestamp() * 1000)),
to = int(round(endTime.timestamp() * 1000)),
destination='s3Bucket')

return
'status': 200,
'body': 'Lambda executed succesfully!'










share|improve this question
























  • It would be helpful if you also shared your deployment configurations

    – Kalev
    Mar 8 at 13:28











  • Does this happen for every Lambda invocation, or just some? Does it always invoke exactly 3 times? Obviously this is a distributed system and has at-least-once semantics but I'd be surprised if it's duplicating invocations a lot.

    – jarmod
    Mar 8 at 15:29











  • What I experienced it always invokes three times when the lambda is triggered by an update in the log stream. When I run it manually it only invoke one time.

    – Andpej
    Mar 8 at 16:46












  • Can you share your Lambda's triggers from the console?

    – Deiv
    Mar 8 at 20:21

















1















I have created a Lambda that subscribes to a specific log group and gets triggered everytime the log group is updated.



However, for some reason the Lambda gets triggered three times instead of just one. The Lambda is supposed to export log files to a S3 Bucket, and since it's triggered three times it exports the same logs three times. My first thought was that the Lambda was timing out and therefor was triggered multiple times but I've checked the logs and the execution is successful every time, and every execution has a unique RequestId.



Any thoughts about this? Any help is appreciated.



This is what my Lambda looks like:



import boto3
from datetime import timedelta, datetime

def lambda_handler(event, context):
startTime = datetime.utcnow() - timedelta(hours = 2)
endTime = datetime.utcnow()
cloudwatch = boto3.client('logs')
response = cloudwatch.create_export_task(
taskName = 'LogExport',
logGroupName = '/aws/lambda/logGroupName',
fromTime = int(round(startTime.timestamp() * 1000)),
to = int(round(endTime.timestamp() * 1000)),
destination='s3Bucket')

return
'status': 200,
'body': 'Lambda executed succesfully!'










share|improve this question
























  • It would be helpful if you also shared your deployment configurations

    – Kalev
    Mar 8 at 13:28











  • Does this happen for every Lambda invocation, or just some? Does it always invoke exactly 3 times? Obviously this is a distributed system and has at-least-once semantics but I'd be surprised if it's duplicating invocations a lot.

    – jarmod
    Mar 8 at 15:29











  • What I experienced it always invokes three times when the lambda is triggered by an update in the log stream. When I run it manually it only invoke one time.

    – Andpej
    Mar 8 at 16:46












  • Can you share your Lambda's triggers from the console?

    – Deiv
    Mar 8 at 20:21













1












1








1








I have created a Lambda that subscribes to a specific log group and gets triggered everytime the log group is updated.



However, for some reason the Lambda gets triggered three times instead of just one. The Lambda is supposed to export log files to a S3 Bucket, and since it's triggered three times it exports the same logs three times. My first thought was that the Lambda was timing out and therefor was triggered multiple times but I've checked the logs and the execution is successful every time, and every execution has a unique RequestId.



Any thoughts about this? Any help is appreciated.



This is what my Lambda looks like:



import boto3
from datetime import timedelta, datetime

def lambda_handler(event, context):
startTime = datetime.utcnow() - timedelta(hours = 2)
endTime = datetime.utcnow()
cloudwatch = boto3.client('logs')
response = cloudwatch.create_export_task(
taskName = 'LogExport',
logGroupName = '/aws/lambda/logGroupName',
fromTime = int(round(startTime.timestamp() * 1000)),
to = int(round(endTime.timestamp() * 1000)),
destination='s3Bucket')

return
'status': 200,
'body': 'Lambda executed succesfully!'










share|improve this question
















I have created a Lambda that subscribes to a specific log group and gets triggered everytime the log group is updated.



However, for some reason the Lambda gets triggered three times instead of just one. The Lambda is supposed to export log files to a S3 Bucket, and since it's triggered three times it exports the same logs three times. My first thought was that the Lambda was timing out and therefor was triggered multiple times but I've checked the logs and the execution is successful every time, and every execution has a unique RequestId.



Any thoughts about this? Any help is appreciated.



This is what my Lambda looks like:



import boto3
from datetime import timedelta, datetime

def lambda_handler(event, context):
startTime = datetime.utcnow() - timedelta(hours = 2)
endTime = datetime.utcnow()
cloudwatch = boto3.client('logs')
response = cloudwatch.create_export_task(
taskName = 'LogExport',
logGroupName = '/aws/lambda/logGroupName',
fromTime = int(round(startTime.timestamp() * 1000)),
to = int(round(endTime.timestamp() * 1000)),
destination='s3Bucket')

return
'status': 200,
'body': 'Lambda executed succesfully!'







amazon-web-services amazon-s3 aws-lambda export boto3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 14:16









Kalev

425312




425312










asked Mar 8 at 12:22









AndpejAndpej

298




298












  • It would be helpful if you also shared your deployment configurations

    – Kalev
    Mar 8 at 13:28











  • Does this happen for every Lambda invocation, or just some? Does it always invoke exactly 3 times? Obviously this is a distributed system and has at-least-once semantics but I'd be surprised if it's duplicating invocations a lot.

    – jarmod
    Mar 8 at 15:29











  • What I experienced it always invokes three times when the lambda is triggered by an update in the log stream. When I run it manually it only invoke one time.

    – Andpej
    Mar 8 at 16:46












  • Can you share your Lambda's triggers from the console?

    – Deiv
    Mar 8 at 20:21

















  • It would be helpful if you also shared your deployment configurations

    – Kalev
    Mar 8 at 13:28











  • Does this happen for every Lambda invocation, or just some? Does it always invoke exactly 3 times? Obviously this is a distributed system and has at-least-once semantics but I'd be surprised if it's duplicating invocations a lot.

    – jarmod
    Mar 8 at 15:29











  • What I experienced it always invokes three times when the lambda is triggered by an update in the log stream. When I run it manually it only invoke one time.

    – Andpej
    Mar 8 at 16:46












  • Can you share your Lambda's triggers from the console?

    – Deiv
    Mar 8 at 20:21
















It would be helpful if you also shared your deployment configurations

– Kalev
Mar 8 at 13:28





It would be helpful if you also shared your deployment configurations

– Kalev
Mar 8 at 13:28













Does this happen for every Lambda invocation, or just some? Does it always invoke exactly 3 times? Obviously this is a distributed system and has at-least-once semantics but I'd be surprised if it's duplicating invocations a lot.

– jarmod
Mar 8 at 15:29





Does this happen for every Lambda invocation, or just some? Does it always invoke exactly 3 times? Obviously this is a distributed system and has at-least-once semantics but I'd be surprised if it's duplicating invocations a lot.

– jarmod
Mar 8 at 15:29













What I experienced it always invokes three times when the lambda is triggered by an update in the log stream. When I run it manually it only invoke one time.

– Andpej
Mar 8 at 16:46






What I experienced it always invokes three times when the lambda is triggered by an update in the log stream. When I run it manually it only invoke one time.

– Andpej
Mar 8 at 16:46














Can you share your Lambda's triggers from the console?

– Deiv
Mar 8 at 20:21





Can you share your Lambda's triggers from the console?

– Deiv
Mar 8 at 20:21












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063163%2faws-lambda-gets-executed-3-times%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063163%2faws-lambda-gets-executed-3-times%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved