Skip to content

Instantly share code, notes, and snippets.

@chilledornaments
chilledornaments / steps.md
Last active March 22, 2023 19:02
AWS Managed Grafana + Azure AD

Overview

Information on setting up Azure AD as an IdP for AWS Managed Grafana. This explains how to set up Admin, Viewer, and

Steps

  • Perform steps 1-10 from this document
  • Under the Azure Enterprise Application, click "Single sign-on" from the left-hand nav bar
  • Edit the "Attributes & Claims"
  • Click "Add a group claim"
@chilledornaments
chilledornaments / athena_query.sql
Created May 24, 2022 20:40
Most recently updated item per bucket. Produced by consolidated S3 Inventory
SELECT DISTINCT(bucket),
MAX(last_modified_date) AS last_modified_date
FROM s3_inventory
WHERE dt = '2022-05-23'
GROUP BY bucket
ORDER BY last_modified_date DESC
limit 500
@chilledornaments
chilledornaments / elasticache-failover-alarm.tf
Created February 15, 2022 19:26
Alarm when elasticache nodes failover
```hcl
resource "aws_cloudwatch_metric_alarm" "realtime_redis_primary_failover" {
for_each = toset(module.my_cloudposse_redis_module.member_clusters[0])
alarm_name = "${each.value}-failover"
comparison_operator = "GreaterThanThreshold"
alarm_description = "Monitor for Redis failover events"
evaluation_periods = 1
threshold = 0
alarm_actions = []
@chilledornaments
chilledornaments / concat_tags.tf
Created January 20, 2022 14:50
Terraform ASG tags conversion
/*
I recently wrote a Terraform module to create an ECS Capacity Provider, ASG, Launch Template, etc.
ASG tags are a `set(map(string)))`, unlike most other resources which are simply a `map(string)`.
The `local` below converts `map(string)` tags into `set(map(string)))` tags.
*/
```hcl
@chilledornaments
chilledornaments / steps.md
Created August 7, 2020 21:45
Expanding Linux partitions

Run lsblk to confirm that the disk is correctly sized

Check the filesystem type with file -s /dev/sdX where X is the letter of the disk

If the disk is not LVM:

Run sudo growpart /dev/sdX 1 where X is the letter of the disk and 1 is the number of the partition - this grows the partition size

NOTE: If you're working with an NVMe disk, run lsblk and find the partition holding the parition you need to expand.

@chilledornaments
chilledornaments / main.go
Last active February 18, 2020 15:43
go-gelf Custom Message Example
/*
This is a very basic example of sending custom messages to Graylog with the go-gelf package
GELF Spec https://docs.graylog.org/en/3.2/pages/gelf.html#gelf-via-udp
*/
package main
import (
"fmt"
"gopkg.in/Graylog2/go-gelf.v2/gelf"
@chilledornaments
chilledornaments / gunicorn_conf.py
Created January 10, 2020 16:45
Gunicorn logging with custom values
import socket
from os import environ
hostname = socket.gethostname()
"""
Logging env vars with %({env_var}e)s hasn't worked for me in gunicorn 20.0.4
"""
@chilledornaments
chilledornaments / WatchGuard_Graylog_Grok.txt
Last active July 2, 2019 14:26
Graylog Grok Patterns for WatchGuard Syslog
######################
WatchGuard doesn't send standardized messages meaning you have to create
different extractors for different scenarios
######################
# Temporarily host blocks
# String to match: Temporarily blocking host
%{IPV4:blocked_host}
@chilledornaments
chilledornaments / Python3-CloudFront-SignedURL
Created April 1, 2019 19:02
Walkthrough of creating a CloudFront Signed URL with Python + Boto3
#!/usr/bin/env python36
import boto3, rsa, datetime
from botocore.signers import CloudFrontSigner
from datetime import timedelta
"""
First things first, sign into your AWS Root account. Per Amazon's documentation:
IAM users can't create CloudFront key pairs. You must log in using root credentials to create key pairs.
@chilledornaments
chilledornaments / TD-Agent-GELF.sh
Created March 29, 2019 21:13
Installing the GELF plugin for td-agent on CentOS 7
#!/usr/bin/env bash
# I've spent too much time banging my head against the wall trying to do this to not document it
cd /etc/td-agent/plugin/ && sudo wget https://raw.githubusercontent.com/emsearcy/fluent-plugin-gelf/master/lib/fluent/plugin/out_gelf.rb
sudo /usr/sbin/td-agent-gem install gelf
echo "Installed td-agent GELF plugin"
exit 0