Skip to content

Instantly share code, notes, and snippets.

@oxidizeddreams
oxidizeddreams / redshift_metadata.md
Created September 14, 2018 16:23 — forked from githoov/redshift_metadata.md
Redshift Metadata

Redshift Tables Used

pg_table_def, stl_query, stl_querytext, stl_tr_conflict, stl_explain, stl_alert_event_log, stl_ddltext, stl_scan, stl_save, stl_hashjoin, stl_hash, stl_plan_info, stl_return, and information_schema.table_constraints.

Queries to Extract Features

  • execution time
select (endtime - starttime) as execution_time_in_ms 
from stl_query 
where query = QUERY_ID;
@oxidizeddreams
oxidizeddreams / aws.sg.unused
Created September 4, 2018 16:04 — forked from thibautsacreste/aws.sg.unused
Bash: list unused AWS security groups
#!/usr/bin/env bash
# lists all unused AWS security groups.
# a group is considered unused if it's not attached to any network interface.
# requires aws-cli and jq.
# all groups
aws ec2 describe-security-groups \
| jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \
| sort > /tmp/sg.all
@oxidizeddreams
oxidizeddreams / cloudwatch_log_subscriber.py
Created August 30, 2018 10:59 — forked from bwhaley/cloudwatch_log_subscriber.py
AWS lambda function to subscribe new CloudWatch Log groups to another lambda function
# Lambda function to subscribe all new cloudwatch log groups to a log shipper function
# Used in conjunction with https://github.com/SumoLogic/sumologic-aws-lambda
import os
import logging
import json
import uuid
import boto3
from botocore.exceptions import ClientError