aws lambda: how to get console.log logs from real request (not test)?
I've read this doc: https://docs.aws.amazon.com/en_us/lambda/latest/dg/nodejs-prog-model-logging.html and made this lambda:
exports.handler = async (event) => {
// TODO implement
// const response = {
// statusCode: 200,
// body: JSON.stringify('Hello from Lambda!'),
// };
console.log(123321);
console.log(event.Records[0].cf.response);
console.log(event.Records[0].cf.request);
console.log(JSON.stringify(event.Records[0].cf));
console.log(event);
console.log(arguments);
//Get contents of response
const response = event.Records[0].cf.response;
//Return modified response
return response;
};
It works (logs sends to CloudWatch) when I use "test" with fake model, but when I add CloudFront trigger and send request logs isn't send to any CloudWatch.
- how to get real (from production)
event
object from lambda - how to send/get logs from lambda which triggers by CloudFront?
amazon-web-services amazon-cloudfront amazon-cloudwatch
|
show 2 more comments
I've read this doc: https://docs.aws.amazon.com/en_us/lambda/latest/dg/nodejs-prog-model-logging.html and made this lambda:
exports.handler = async (event) => {
// TODO implement
// const response = {
// statusCode: 200,
// body: JSON.stringify('Hello from Lambda!'),
// };
console.log(123321);
console.log(event.Records[0].cf.response);
console.log(event.Records[0].cf.request);
console.log(JSON.stringify(event.Records[0].cf));
console.log(event);
console.log(arguments);
//Get contents of response
const response = event.Records[0].cf.response;
//Return modified response
return response;
};
It works (logs sends to CloudWatch) when I use "test" with fake model, but when I add CloudFront trigger and send request logs isn't send to any CloudWatch.
- how to get real (from production)
event
object from lambda - how to send/get logs from lambda which triggers by CloudFront?
amazon-web-services amazon-cloudfront amazon-cloudwatch
Is your lambda getting called at all? I mean, do you see your other console.logs in CloudWatch when you are using CloudFront?
– AlexK
Nov 20 '18 at 12:56
@TenorFlyy, yes it called, because I see response in urlxxx.cloudfront.net/test1.html
. And I don't have any logs by calling it not with "Test" button.
– MixerOID
Nov 20 '18 at 12:58
No, I mean when it is behind CloudFront, does it get called then. I understand it is getting called when testing.
– AlexK
Nov 20 '18 at 12:59
@TenorFlyy now to check it?
– MixerOID
Nov 20 '18 at 13:01
When you try to call the lambda through CloudFront, it should log something, if it doesn't, then it isn't even being called. In order to make it easier and clear for debugging, change the code, e.g. add anotherconsole.log
and save it, so next time your lambda gets called it will create new CloudWatch Log Stream. If no stream is created, then lambda wasn't called.
– AlexK
Nov 20 '18 at 13:04
|
show 2 more comments
I've read this doc: https://docs.aws.amazon.com/en_us/lambda/latest/dg/nodejs-prog-model-logging.html and made this lambda:
exports.handler = async (event) => {
// TODO implement
// const response = {
// statusCode: 200,
// body: JSON.stringify('Hello from Lambda!'),
// };
console.log(123321);
console.log(event.Records[0].cf.response);
console.log(event.Records[0].cf.request);
console.log(JSON.stringify(event.Records[0].cf));
console.log(event);
console.log(arguments);
//Get contents of response
const response = event.Records[0].cf.response;
//Return modified response
return response;
};
It works (logs sends to CloudWatch) when I use "test" with fake model, but when I add CloudFront trigger and send request logs isn't send to any CloudWatch.
- how to get real (from production)
event
object from lambda - how to send/get logs from lambda which triggers by CloudFront?
amazon-web-services amazon-cloudfront amazon-cloudwatch
I've read this doc: https://docs.aws.amazon.com/en_us/lambda/latest/dg/nodejs-prog-model-logging.html and made this lambda:
exports.handler = async (event) => {
// TODO implement
// const response = {
// statusCode: 200,
// body: JSON.stringify('Hello from Lambda!'),
// };
console.log(123321);
console.log(event.Records[0].cf.response);
console.log(event.Records[0].cf.request);
console.log(JSON.stringify(event.Records[0].cf));
console.log(event);
console.log(arguments);
//Get contents of response
const response = event.Records[0].cf.response;
//Return modified response
return response;
};
It works (logs sends to CloudWatch) when I use "test" with fake model, but when I add CloudFront trigger and send request logs isn't send to any CloudWatch.
- how to get real (from production)
event
object from lambda - how to send/get logs from lambda which triggers by CloudFront?
amazon-web-services amazon-cloudfront amazon-cloudwatch
amazon-web-services amazon-cloudfront amazon-cloudwatch
edited Nov 20 '18 at 12:42
MixerOID
asked Nov 20 '18 at 12:35
MixerOIDMixerOID
945823
945823
Is your lambda getting called at all? I mean, do you see your other console.logs in CloudWatch when you are using CloudFront?
– AlexK
Nov 20 '18 at 12:56
@TenorFlyy, yes it called, because I see response in urlxxx.cloudfront.net/test1.html
. And I don't have any logs by calling it not with "Test" button.
– MixerOID
Nov 20 '18 at 12:58
No, I mean when it is behind CloudFront, does it get called then. I understand it is getting called when testing.
– AlexK
Nov 20 '18 at 12:59
@TenorFlyy now to check it?
– MixerOID
Nov 20 '18 at 13:01
When you try to call the lambda through CloudFront, it should log something, if it doesn't, then it isn't even being called. In order to make it easier and clear for debugging, change the code, e.g. add anotherconsole.log
and save it, so next time your lambda gets called it will create new CloudWatch Log Stream. If no stream is created, then lambda wasn't called.
– AlexK
Nov 20 '18 at 13:04
|
show 2 more comments
Is your lambda getting called at all? I mean, do you see your other console.logs in CloudWatch when you are using CloudFront?
– AlexK
Nov 20 '18 at 12:56
@TenorFlyy, yes it called, because I see response in urlxxx.cloudfront.net/test1.html
. And I don't have any logs by calling it not with "Test" button.
– MixerOID
Nov 20 '18 at 12:58
No, I mean when it is behind CloudFront, does it get called then. I understand it is getting called when testing.
– AlexK
Nov 20 '18 at 12:59
@TenorFlyy now to check it?
– MixerOID
Nov 20 '18 at 13:01
When you try to call the lambda through CloudFront, it should log something, if it doesn't, then it isn't even being called. In order to make it easier and clear for debugging, change the code, e.g. add anotherconsole.log
and save it, so next time your lambda gets called it will create new CloudWatch Log Stream. If no stream is created, then lambda wasn't called.
– AlexK
Nov 20 '18 at 13:04
Is your lambda getting called at all? I mean, do you see your other console.logs in CloudWatch when you are using CloudFront?
– AlexK
Nov 20 '18 at 12:56
Is your lambda getting called at all? I mean, do you see your other console.logs in CloudWatch when you are using CloudFront?
– AlexK
Nov 20 '18 at 12:56
@TenorFlyy, yes it called, because I see response in url
xxx.cloudfront.net/test1.html
. And I don't have any logs by calling it not with "Test" button.– MixerOID
Nov 20 '18 at 12:58
@TenorFlyy, yes it called, because I see response in url
xxx.cloudfront.net/test1.html
. And I don't have any logs by calling it not with "Test" button.– MixerOID
Nov 20 '18 at 12:58
No, I mean when it is behind CloudFront, does it get called then. I understand it is getting called when testing.
– AlexK
Nov 20 '18 at 12:59
No, I mean when it is behind CloudFront, does it get called then. I understand it is getting called when testing.
– AlexK
Nov 20 '18 at 12:59
@TenorFlyy now to check it?
– MixerOID
Nov 20 '18 at 13:01
@TenorFlyy now to check it?
– MixerOID
Nov 20 '18 at 13:01
When you try to call the lambda through CloudFront, it should log something, if it doesn't, then it isn't even being called. In order to make it easier and clear for debugging, change the code, e.g. add another
console.log
and save it, so next time your lambda gets called it will create new CloudWatch Log Stream. If no stream is created, then lambda wasn't called.– AlexK
Nov 20 '18 at 13:04
When you try to call the lambda through CloudFront, it should log something, if it doesn't, then it isn't even being called. In order to make it easier and clear for debugging, change the code, e.g. add another
console.log
and save it, so next time your lambda gets called it will create new CloudWatch Log Stream. If no stream is created, then lambda wasn't called.– AlexK
Nov 20 '18 at 13:04
|
show 2 more comments
1 Answer
1
active
oldest
votes
Due to Lambda being triggered by CloudFront, it now becomes a Lambda@Edge, so the CloudWatch Log streams are created in the region where the Lambda instance is called(that's decided by CloudFront).
So following the AWS Lambda@Edge Docs for Troubleshooting, the specific region could be easily determined with the provided shell script.
You can switch the region using dropdown at the header:
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393121%2faws-lambda-how-to-get-console-log-logs-from-real-request-not-test%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Due to Lambda being triggered by CloudFront, it now becomes a Lambda@Edge, so the CloudWatch Log streams are created in the region where the Lambda instance is called(that's decided by CloudFront).
So following the AWS Lambda@Edge Docs for Troubleshooting, the specific region could be easily determined with the provided shell script.
You can switch the region using dropdown at the header:
add a comment |
Due to Lambda being triggered by CloudFront, it now becomes a Lambda@Edge, so the CloudWatch Log streams are created in the region where the Lambda instance is called(that's decided by CloudFront).
So following the AWS Lambda@Edge Docs for Troubleshooting, the specific region could be easily determined with the provided shell script.
You can switch the region using dropdown at the header:
add a comment |
Due to Lambda being triggered by CloudFront, it now becomes a Lambda@Edge, so the CloudWatch Log streams are created in the region where the Lambda instance is called(that's decided by CloudFront).
So following the AWS Lambda@Edge Docs for Troubleshooting, the specific region could be easily determined with the provided shell script.
You can switch the region using dropdown at the header:
Due to Lambda being triggered by CloudFront, it now becomes a Lambda@Edge, so the CloudWatch Log streams are created in the region where the Lambda instance is called(that's decided by CloudFront).
So following the AWS Lambda@Edge Docs for Troubleshooting, the specific region could be easily determined with the provided shell script.
You can switch the region using dropdown at the header:
edited Nov 20 '18 at 13:51
answered Nov 20 '18 at 13:44
AlexKAlexK
869513
869513
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393121%2faws-lambda-how-to-get-console-log-logs-from-real-request-not-test%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Is your lambda getting called at all? I mean, do you see your other console.logs in CloudWatch when you are using CloudFront?
– AlexK
Nov 20 '18 at 12:56
@TenorFlyy, yes it called, because I see response in url
xxx.cloudfront.net/test1.html
. And I don't have any logs by calling it not with "Test" button.– MixerOID
Nov 20 '18 at 12:58
No, I mean when it is behind CloudFront, does it get called then. I understand it is getting called when testing.
– AlexK
Nov 20 '18 at 12:59
@TenorFlyy now to check it?
– MixerOID
Nov 20 '18 at 13:01
When you try to call the lambda through CloudFront, it should log something, if it doesn't, then it isn't even being called. In order to make it easier and clear for debugging, change the code, e.g. add another
console.log
and save it, so next time your lambda gets called it will create new CloudWatch Log Stream. If no stream is created, then lambda wasn't called.– AlexK
Nov 20 '18 at 13:04