-
Notifications
You must be signed in to change notification settings - Fork 46
Update logs grepping scripts and add a script to find the first API log entry in AWS logs #4880
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
Conversation
…og entry in AWS logs Signed-off-by: Lukasz Gryglicki <[email protected]> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughTwo shell utilities for CloudWatch logs: Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
utils/calculate_api_stats.sh (1)
20-20: Refactor JSON parsing to use jq instead of grep.Extracting JSON field values using grep is fragile and inefficient. Use jq for consistency and robustness.
- cat "api-logs-${STAGE}.json" | grep '"logGroupName": "' | sort | uniq + jq -r '.[] | .logGroupName' "api-logs-${STAGE}.json" | sort -uNote: This assumes the JSON structure has a logGroupName field at the top level or appropriately adjusted based on the actual structure.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
utils/calculate_api_stats.sh(1 hunks)utils/find_1st_log_entry.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Agent
- GitHub Check: cypress-functional
- GitHub Check: build-test-lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new utility script to find the first API log entry across multiple AWS Lambda log groups and updates the API stats calculation script to explicitly filter specific log groups using the INCL_LOGS variable.
Key changes:
- New script
find_1st_log_entry.shto query the first API request log entry from AWS CloudWatch logs across multiple Lambda functions - Modified
calculate_api_stats.shto explicitly specify which log groups to include for each region using theINCL_LOGSenvironment variable - Added diagnostic output to show which log groups were processed
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| utils/find_1st_log_entry.sh | New script that queries AWS CloudWatch logs to find the first API log entry across multiple Lambda functions in us-east-1 and us-east-2 regions |
| utils/calculate_api_stats.sh | Updated to explicitly filter log groups using INCL_LOGS variable and added diagnostic output showing which log groups were processed |
Co-authored-by: Copilot <[email protected]> Signed-off-by: Łukasz Gryglicki <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Łukasz Gryglicki <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
utils/find_1st_log_entry.sh (1)
1-7: Add critical error handling directives (set -eandset -o pipefail).The script invokes multiple external commands (AWS CLI, jq, awk) but lacks shell safety options to halt on failures. Missing
set -eandset -o pipefailmeans the script will continue even if intermediate commands fail, potentially masking errors or producing incomplete output.Apply this diff to add robust error handling at the top:
#!/bin/bash + set -e + set -o pipefail + # Copyright The Linux Foundation and each contributor to LFX. # SPDX-License-Identifier: MIT + # + # find_1st_log_entry.sh + # + # Purpose: + # Finds and prints the timestamp of the first log entry containing "LG:api-request-path" + # for several AWS Lambda log groups related to CLA backend services. + # + # Environment Variables: + # STAGE - (optional) The deployment stage (e.g., dev, prod, staging). Defaults to "dev" if unset. + # + # Usage: + # STAGE=prod ./find_1st_log_entry.sh + # ./find_1st_log_entry.sh # uses STAGE=dev by default + # if [ -z "${STAGE}" ]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
utils/find_1st_log_entry.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cypress-functional
- GitHub Check: build-test-lint
🔇 Additional comments (1)
utils/find_1st_log_entry.sh (1)
8-16: Array structure effectively addresses DRY principle.The log_groups array is a clean refactor compared to the previous repetitive commands. This approach improves maintainability.
cc @mlehotskylf @ahmedomosanya
Signed-off-by: Lukasz Gryglicki [email protected]
Assisted by OpenAI
Assisted by GitHub Copilot