aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.04k stars 570 forks source link

GenerateAccessLogsCommand from '@aws-sdk/client-amplify' dates range #6462

Open teresarg opened 1 week ago

teresarg commented 1 week ago

Checkboxes for prior research

Describe the bug

I am using GenerateAccessLogsCommand to get the access logs from my amplify app for a specific time.

When calling GenerateAccessLogsCommand, if, for example, I send as start date: 2024-09-11T14:12:21.237Z and as end date: 2024-09-11T15:12:21.237Z, I get some logs out of this range of dates. In this case, I am getting logs from 14:22 until 15:39.

This looks a bit random, cause sometimes I also miss some logs from the date ranges, and other times I get logs previous to the dates range I send.

SDK version number

@aws-sdk/client-amplify@3.637.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v16.20.2

Reproduction Steps

const client = new AmplifyClient({ region: "[region]" });

const currentTime = new Date();

// Example for getting logs from 1.5 hours before. Range of one hour
const endTime = new Date(currentTime.getTime() - 30 * 60 * 1000);
const startTime = new Date(endTime.getTime() - 60 * 60 * 1000);

const input = {
    startTime: startTime,
    endTime: endTime,
    domainName: "[domain]",
    appId: "[amplifyApp]",
};

const command = new GenerateAccessLogsCommand(input);
const response = await client.send(command);

const logsResponse = await fetch(response.logUrl || '');
const logs = await logsResponse.text();

Observed Behavior

Getting logs out of the range

Expected Behavior

Get all logs includes in the range of dates I send to GenerateAccessLogsCommand

Possible Solution

No response

Additional Information/Context

No response

zshzbh commented 22 hours ago

Hey @teresarg,

Thanks for the feedback! I can reproduce this issue - # The code I have -

import {
  AmplifyClient,
  GenerateAccessLogsCommand,
} from "@aws-sdk/client-amplify";
const client = new AmplifyClient({ region: "us-west-2" });

const currentTime = new Date();

// Example for getting logs from 10 minutes before. 
const endTime = new Date(currentTime.getTime() );
const startTime = new Date(endTime.getTime() - 10 * 60 * 1000);

console.log(reg)
const input = {
  // GenerateAccessLogsRequest
  startTime: startTime,
  endTime: endTime,
  domainName: "main.MyDomainName.amplifyapp.com", // required
  appId: "/myappID", // required
};
const command = new GenerateAccessLogsCommand(input);
const response = await client.send(command);

const logsResponse = await fetch(response.logUrl || "");
const logs = await logsResponse.text();
console.log(response);

I want to include logs generated from 10 min ago to now, and then I got logs that are generated 17 min ago.

log I got when running the project at Wed Sep 18 18_30_18 UTC 2024 -

date,time,x-edge-location,sc-bytes,c-ip,cs-method,cs\(Host),cs-uri-stem,sc-status,cs\(Referer),cs\(User-Agent),cs-uri-query,cs\(Cookie),x-edge-result-type,x-edge-request-id,x-host-header,cs-protocol,cs-bytes,time-taken,x-forwarded-for,ssl-protocol,ssl-cipher,x-edge-response-result-type,cs-protocol-version,fle-status,fle-encrypted-fields,c-port,time-to-first-byte,x-edge-detailed-result-type,sc-content-type,sc-content-len,sc-range-start,sc-range-end
2024-09-18,18:13:04,DUB56-P2,334,34.248.137.227,GET,da4rb8osz4dow.cloudfront.net,/,404,-,Mozilla/5.0%20\(X11;%20Linux%20x86_64;%20rv:83.0)%20Gecko/20100101%20Firefox/83.0,-,-,Error,-ZmnKBz1_GHSKI4bzAKA45RvY0j_-Njzf2ZjrwftB1uBa5KAHNki9g\=\=,da4rb8osz4dow.amplifyapp.com,https,209,0.145,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/1.1,-,-,40144,0.145,Error,-,0,-,-
2024-09-18,18:13:04,DUB56-P2,608,34.248.137.227,GET,da4rb8osz4dow.cloudfront.net,/,301,-,Mozilla/5.0%20\(X11;%20Linux%20x86_64;%20rv:83.0)%20Gecko/20100101%20Firefox/83.0,-,-,Redirect,NWm9Q2deKXOQ8yo_CraU-4yQKNSB4cWu0U85Sg9JVOulyLb5jrFWJw\=\=,da4rb8osz4dow.amplifyapp.com,http,209,0.001,-,-,-,Redirect,HTTP/1.1,-,-,52486,0.001,Redirect,text/html,167,-,-
2024-09-18,18:13:04,DUB56-P2,334,34.248.137.227,GET,da4rb8osz4dow.cloudfront.net,/,404,-,Mozilla/5.0%20\(X11;%20Linux%20x86_64;%20rv:83.0)%20Gecko/20100101%20Firefox/83.0,-,-,Error,N74PzJY1wDmtsMmPV53KROopV1AL2I7f7S0iveT_qExdaPaBT9J43Q\=\=,da4rb8osz4dow.amplifyapp.com,https,209,0.141,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/1.1,-,-,40140,0.141,Error,-,0,-,-
2024-09-18,18:01:36,HIO52-P1,334,54.184.162.186,GET,da4rb8osz4dow.cloudfront.net,/status.html,404,-,Java/17.0.11,-,-,Error,aInQu1H3NAk6ik8oPXKGXa94B_Gpfv-7krpUjZu2lELVMHLxYEO6-Q\=\=,awshealthcheck.da4rb8osz4dow.amplifyapp.com,https,192,0.019,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/1.1,-,-,33530,0.019,Error,-,0,-,-
2024-09-18,18:02:34,CDG52-P2,219,151.115.77.26,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,LqZ4EcxwOPpT3Qn6vOLTTUNWSzd0Fu325QEIH5F7sBYNxTvnPe-0Pw\=\=,da4rb8osz4dow.amplifyapp.com,https,68,0.166,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,56538,0.166,Error,-,0,-,-
2024-09-18,18:02:34,CDG52-P2,218,151.115.77.26,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,rmDS-pdLRN2ypunz5hVAusepDR5XbmNKsqdQXgjNuyPmKWWktXpb_g\=\=,da4rb8osz4dow.amplifyapp.com,https,15,0.168,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,56538,0.168,Error,-,0,-,-
2024-09-18,18:02:34,CDG52-P2,218,151.115.77.26,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,bnGtb2UKnqAX98Wn_brUxNnVSOEzdDs0-I8yA6ikHBbR2bgYBJTrPQ\=\=,da4rb8osz4dow.amplifyapp.com,https,15,0.169,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,56538,0.169,Error,-,0,-,-
2024-09-18,18:02:38,CDG52-P2,217,51.158.161.239,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,DG4wIqAVr-HTBhJw6mjyrAc-V4WkKmym3qGNyrmczoeUb4Ki8YG7mQ\=\=,da4rb8osz4dow.amplifyapp.com,https,15,0.168,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,48866,0.168,Error,-,0,-,-
2024-09-18,18:02:38,CDG52-P2,218,51.158.161.239,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,gERuy3B5kGqv8Z1gdU37nCA7g7s4OWbXvwpKrvfV1AXHRTaQYN84Xg\=\=,da4rb8osz4dow.amplifyapp.com,https,68,0.173,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,48866,0.173,Error,-,0,-,-
2024-09-18,18:02:38,CDG52-P2,216,51.158.161.239,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,IQSyoOC5a-aGc3dYTavhe58cX3gD8iH03lfbFm-CxrLhZPjSVSogIg\=\=,da4rb8osz4dow.amplifyapp.com,https,15,0.163,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,48866,0.163,Error,-,0,-,-
2024-09-18,18:02:38,CDG52-P2,218,51.158.161.239,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,rNe-cVNjYiyF-fgMGVnW7hDRhN2hQ_RqjrRLqhQM8j6HgT2qHF_Y_w\=\=,da4rb8osz4dow.amplifyapp.com,https,15,0.182,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,48866,0.182,Error,-,0,-,-
2024-09-18,18:02:43,CDG52-P2,217,151.115.77.26,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,404,-,Go-http-client/2.0,-,-,Error,2pZ4PEkuJxoVEQodiup2_K8OTvortae8jTst3rg0_sXXp-fX9Ja0BA\=\=,da4rb8osz4dow.amplifyapp.com,https,68,0.210,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,21364,0.210,Error,-,0,-,-
2024-09-18,18:21:36,IAD66-C2,219,69.171.249.38,GET,da4rb8osz4dow.cloudfront.net,/,404,-,facebookexternalhit/1.1%20\(+http://www.facebook.com/externalhit_uatext.php),-,-,Error,pqkjaGNb7K0RoA2MAe6iEd3azzcDRCbnyBIYFsHt4KhG_3ZpVWuJbQ\=\=,da4rb8osz4dow.amplifyapp.com,https,96,0.095,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,48798,0.095,Error,-,0,-,-
2024-09-18,18:21:28,ATL56-C3,219,173.252.127.7,GET,da4rb8osz4dow.cloudfront.net,/,404,-,Mozilla/5.0%20\(Linux;%20Android%2010;%20K)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Mobile%20Safari/537.36,fbclid\=IwZXh0bgNhZW0CMTEAAR2knvGCodI08YQQKBMTvIbftS6hPYQznbaYFt2ifhxXdNyxcIlEtFDeTNs_aem_jbqtsneL2HJtwuXL3a2aDg,-,Error,borbzaYLoT3EtL0m-Fbj8VKMnjXOGQMQWGFV9A_Gr8_8rZZcki2e8A\=\=,da4rb8osz4dow.amplifyapp.com,https,534,0.099,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,45034,0.099,Error,-,0,-,-
2024-09-18,18:18:00,IAD66-C2,334,135.148.100.196,GET,da4rb8osz4dow.cloudfront.net,/,404,-,-,-,-,Error,et5el3c342W6KcBWP_xfjLAkivIwrVLhLZxrSM1ApHWsKiJvCuCCkw\=\=,da4rb8osz4dow.amplifyapp.com,https,128,0.085,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/1.1,-,-,47060,0.085,Error,-,0,-,-
2024-09-18,18:20:36,DFW56-P3,608,173.252.83.43,GET,da4rb8osz4dow.cloudfront.net,/,301,-,facebookexternalhit/1.1%20\(+http://www.facebook.com/externalhit_uatext.php),-,-,Redirect,EyvZSLyM3Wk6S6bJ1iTnpF4RcU_9hqZLtc4a51San2Gz_WeFfaZdhQ\=\=,da4rb8osz4dow.amplifyapp.com,http,178,0.001,-,-,-,Redirect,HTTP/1.1,-,-,59602,0.001,Redirect,text/html,167,-,-
2024-09-18,18:20:37,DFW56-P3,219,173.252.83.55,GET,da4rb8osz4dow.cloudfront.net,/,404,-,facebookexternalhit/1.1%20\(+http://www.facebook.com/externalhit_uatext.php),-,-,Error,Gz0JdsF47rooqKJ_dbFtLGLLFB77QgLlp463v4RDTX_vpjneHit5dA\=\=,da4rb8osz4dow.amplifyapp.com,https,96,0.089,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/2.0,-,-,41110,0.089,Error,-,0,-,-

I will bring it up to the team and I will get back to you when I get an update.

Thanks! Maggie

teresarg commented 6 hours ago

Hi Maggie,

It happens repeatedly. I provide you the request id: x-amz-id-2: vwDuFzLii9mv0b5oTU+2WnCYY0vMq15ZkbeJb3BpjGUJ5N/Dxk17Cti4/IMygMsbOSD+sCqdQhM= x-amz-request-id: C32VRYGDCCYZWWH0

Thanks!

Teresa

El mié, 18 sept 2024 a las 18:57, Maggie Ma @.***>) escribió:

Hey @teresarg https://github.com/teresarg,

I have forwarded this issue to service team, and they are investigating this issue. I'd also like to know if this is one time thing or it happens repeatedly? Could you please provide the request id?

Thanks! Maggie

— Reply to this email directly, view it on GitHub https://github.com/aws/aws-sdk-js-v3/issues/6462#issuecomment-2358979549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEG5ZVU4UFQU2CTITO3HBHLZXGWI3AVCNFSM6AAAAABOBJJZBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJYHE3TSNJUHE . You are receiving this because you were mentioned.Message ID: @.***>