Skip to content

Instantly share code, notes, and snippets.

View pistazie's full-sized avatar

Tom Roshko pistazie

View GitHub Profile
@pistazie
pistazie / gist:8f116cb6a3d4d7d442b5d8931f903df7
Last active July 12, 2024 19:27
Angle grinder parse operator for AWS ALB (Application load balancer) access logs
```shell
LB_PARSE='parse regex "(?P<type>[^\s]*) (?P<time>[^\s]*) (?P<elb>[^\s]*) (?P<client>[^\s]*) (?P<target>[^\s]*) (?P<request_processing_time>[^\s]*) (?P<target_processing_time>[^\s]*) (?P<response_processing_time>[^\s]*) (?P<elb_status_code>[^\s]*) (?P<target_status_code>[^\s]*) (?P<received_bytes>[^\s]*) (?P<sent_bytes>[^\s]*) (?P<request>\"[^\"]*\") (?P<user_agent>\"[^\"]*\") (?P<ssl_cipher>[^\s]*) (?P<ssl_protocol>[^\s]*) (?P<target_group_arn>[^\s]*) (?P<trace_id>\"[^\"]*\") (?P<domain_name>\"[^\"]*\") (?P<chosen_cert_arn>\"[^\"]*\") (?P<matched_rule_priority>[^\s]*) (?P<request_creation_time>[^\s]*) (?P<actions_executed>\"[^\"]*\") (?P<redirect_url>\"[^\"]*\") (?P<error_reason>\"[^\"]*\") (?P<target_port_list>\"[^\"]*\") (?P<target_status_code_list>\"[^\"]*\") (?P<classification>\"[^\"]*\") (?P<classification_reason>\"[^\"]*\") (?P<conn_trace_id>[^\s]*)"'
# usage example:
agrind -f lb.log "* | ${LB_PARSE} | where elb_status_code == 502 | count by target"
# Reference:
# * https://docs.aws.amazon.
@pistazie
pistazie / buildspec.yml
Created August 3, 2021 19:04
Adds emoji support to AWS CodeBuild - made our Cypress.js (run in Electron browser) test logs contain missing Emojis
version: 0.2
phases:
pre_build:
commands:
- yum install google-noto-emoji-color-fonts -y
@pistazie
pistazie / gist:8671c2fb83800113469b319980d451b9
Created April 7, 2020 13:55
Amazon Linux 2 EC2 User Data Initial shell script to change the SSH port the instance listens on
#!/bin/bash -ex
sed -i 's/#Port\s22/Port 8732/' /etc/ssh/sshd_config
systemctl restart sshd.service