Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
teresarg opened this issue Sep 11, 2024 · 5 comments
Open
3 tasks done

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

teresarg opened this issue Sep 11, 2024 · 5 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@teresarg
Copy link

teresarg commented Sep 11, 2024

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/[email protected]

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

@teresarg teresarg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 11, 2024
@teresarg teresarg changed the title Wrong dates - GenerateAccessLogsCommand from '@aws-sdk/client-amplify' GenerateAccessLogsCommand from '@aws-sdk/client-amplify' dates range Sep 12, 2024
@zshzbh zshzbh self-assigned this Sep 13, 2024
@zshzbh zshzbh removed the needs-triage This issue or PR still needs to be triaged. label Sep 18, 2024
@zshzbh
Copy link

zshzbh commented Sep 18, 2024

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

@zshzbh zshzbh added p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Sep 18, 2024
@teresarg
Copy link
Author

teresarg commented Sep 19, 2024 via email

@zshzbh zshzbh added service-api This issue is due to a problem in a service API, not the SDK implementation. and removed response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Sep 19, 2024
@zshzbh
Copy link

zshzbh commented Sep 19, 2024

Thanks for the response!
I also tried on python SDK, it seems that the python sdk also has this issue -

import   ##boto3
import datetime
client = boto3.client('amplify')
client = boto3.client('amplify', region_name='us-west-2')

current_time = datetime.datetime.now()
end_time = current_time
start_time = current_time - datetime.timedelta(minutes=10)
print(current_time)
response = client.generate_access_logs(    
    startTime= start_time,
    endTime =  end_time,
    domainName =  'main.myDomainName.amplifyapp.com',  # required
    appId = 'myAppId'  
)
print(response["logUrl"])

The time method was called is UTC 2024-09-19 15:54:23.221632
The result I have -

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-19,15:46:56,AMS58-P6,329,45.148.10.172,GET,da4rb8osz4dow.cloudfront.net,/.env,404,-,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_12_6)%20AppleWebKit/605.1.15%20\(KHTML%20like%20Gecko)%20Version/12.1.2%20Safari/605.1.15,-,-,Error,bVkE-Vu0ZuWY2N9dZvyRbF3fK21EfHBGUMmk2g2pPSeE1i8cjXP5gQ\=\=,da4rb8osz4dow.amplifyapp.com,https,256,0.165,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Error,HTTP/1.1,-,-,51340,0.165,Error,-,0,-,-
2024-09-19,15:42:01,IAD66-C2,1794,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg,200,https://main.da4rb8osz4dow.amplifyapp.com/,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,VGC3-yqzYPND50RGmxKMANHNdjttbSLp4_3ch8vrCGlEzl323l2Fjw\=\=,main.da4rb8osz4dow.amplifyapp.com,https,523,0.119,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/3.0,-,-,49434,0.119,Miss,image/svg+xml,-,-,-
2024-09-19,15:42:02,IAD66-C2,7079,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/favicon.ico,200,https://main.da4rb8osz4dow.amplifyapp.com/,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,unPJxYTBI0a91OG558zsOsALYNNhZ05gDfR1dK13fVPVx8XOMBZNhA\=\=,main.da4rb8osz4dow.amplifyapp.com,https,454,0.158,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/3.0,-,-,49434,0.158,Miss,image/x-icon,6548,-,-
2024-09-19,15:42:02,IAD66-C2,10249,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/logo192.png,200,https://main.da4rb8osz4dow.amplifyapp.com/,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,W79Rwmo3J4R9hf-aWeF1zfQvPy7BtceLvclDpoKjqEnvXmBB6OHRrw\=\=,main.da4rb8osz4dow.amplifyapp.com,https,454,0.156,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/3.0,-,-,49434,0.156,Miss,image/png,9721,-,-
2024-09-19,15:42:01,IAD66-C2,1024,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/,200,-,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,ioXvn-9CxU-rQIKkMNVCGGEP-gz3Jjq20aVXs4pkTzbuWm2e04IfdQ\=\=,main.da4rb8osz4dow.amplifyapp.com,https,479,0.144,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/2.0,-,-,51111,0.144,Miss,text/html,644,-,-
2024-09-19,15:42:01,IAD66-C2,1158,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/static/css/main.f855e6bc.css,200,https://main.da4rb8osz4dow.amplifyapp.com/,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,XUyNJ-Bkr6GeNtQwyWWafvk4epZtHeK5UFNTuY7BzFmK3Hce_GhG9w\=\=,main.da4rb8osz4dow.amplifyapp.com,https,121,0.134,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/2.0,-,-,51111,0.134,Miss,text/css,779,-,-
2024-09-19,15:42:01,IAD66-C2,44743,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/static/js/main.d8d487c0.js,200,https://main.da4rb8osz4dow.amplifyapp.com/,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,itxjurDaom1tVA-L5ooAvnsIUKAJDt31_uTB_-ZKpmL14iuEREEgIA\=\=,main.da4rb8osz4dow.amplifyapp.com,https,54,0.284,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/2.0,-,-,51111,0.277,Miss,text/javascript,-,-,-
2024-09-19,15:42:02,IAD66-C2,1026,73.40.6.229,GET,da4rb8osz4dow.cloudfront.net,/manifest.json,200,https://main.da4rb8osz4dow.amplifyapp.com/,Mozilla/5.0%20\(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/537.36%20\(KHTML%20like%20Gecko)%20Chrome/128.0.0.0%20Safari/537.36,-,-,Miss,bOaJm58HlUyirvHBc6UsxnYAIElIpqlagZH44QC1oEFQwWCREv02wA\=\=,main.da4rb8osz4dow.amplifyapp.com,https,404,0.116,-,TLSv1.3,TLS_AES_128_GCM_SHA256,Miss,HTTP/3.0,-,-,57672,0.116,Miss,application/json,492,-,-

I can confirm that this issue is generated from service team, I will create a ticket to the service team and post the update here.

Thanks!
Maggie

@zshzbh
Copy link

zshzbh commented Sep 19, 2024

Internal Ref: V1522271556

@teresarg
Copy link
Author

teresarg commented Sep 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants