Skip to content

Commit

Permalink
Merge pull request #2968 from transcom/cg_add_download_alb_logs
Browse files Browse the repository at this point in the history
Add missing script to checking alb logs
  • Loading branch information
Chris Gilmer committed Nov 7, 2019
2 parents 5cd5875 + 3d7a001 commit ff5d6fc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/README.md
Expand Up @@ -16,6 +16,15 @@ environment.
| `check-hosts-file` | Script helps ensure that /etc/hosts has all the correct entries in it |
| `prereqs` | validate if all prerequisite programs have been installed |

## Operations Scripts

These scripts are used to operate the system.

| Script Name | Description |
| --- | --- |
| `download-alb-logs` | Download alb logs for the given environment and dates to a local folder |
| `scan-alb-logs` | Scan alb logs for specific http codes. |

## Pre-commit Scripts

These scripts are used primarily to check our code before
Expand Down
26 changes: 26 additions & 0 deletions scripts/download-alb-logs
@@ -0,0 +1,26 @@
#! /usr/bin/env bash

set -eu -o pipefail

#
# Download alb logs for the given environment and dates to a local folder
#
# Requires a environment and http code but can also include a date.
# When a date is not given the current UTC date is used.
#
# Example:
# ../scripts/download-alb-logs tmp prod 2019/02/14,2019/02/16
#
# Note: Must run from transcom-ppp/ directory
#

[[ $# -ne 3 ]] && echo "Usage: download-alb-logs <dest> <environment:prod|staging|experimental> [<day:YYYY/mm/dd>[,<day:YYYY/mm/dd>]]" && exit 1

readonly dest=$1
readonly environment=$2
IFS=', ' read -r -a dates <<< "$3"

mkdir -p "${dest}"
for date in "${dates[@]}"; do
aws s3 sync --quiet "s3://transcom-ppp-aws-logs/alb/app-${environment}/AWSLogs/923914045601/elasticloadbalancing/us-west-2/${date}/" "$dest"
done

0 comments on commit ff5d6fc

Please sign in to comment.