Skip to content

Instantly share code, notes, and snippets.

View chicagobuss's full-sized avatar

Joshua Buss chicagobuss

  • TRM Labs
  • Chicago
View GitHub Profile
@chicagobuss
chicagobuss / query.py
Last active July 25, 2023 17:49
boto3 dynamodb query with filter
#!/usr/bin/env python
import boto3
import json
from boto3.dynamodb.conditions import Key, Attr
from datetime import datetime
DIMENSION = 'logicalCpuCount'
TABLE_NAME = 'ms-usage-metering'
@chicagobuss
chicagobuss / cc-viz.py
Last active November 6, 2019 23:20
for helping customers use our metrics firehose
#!/usr/bin/env python3
#
# cc-viz.py
#
# A hastily-thrown together collection of functions that gets confluent cloud metrics into datadog, graphite, or prometheus (or any combination of those)
#
GRAPHITE_HOST = '10.1.2.3'
GRAPHITE_PORT = 2003
GRAPHITE_METRIC_PREFIX = 'confluent.cloud.kafka'
@chicagobuss
chicagobuss / costs.txt
Created August 2, 2019 21:56
cost_structs
FIXED_HOURLY_COSTS = {
'DISKS': {
'aws': {
'us-east-1': {
'io1': 0.125 / 30 / 24,
'gp2': 0.1 / 30 / 24,
'st1': 0.045 / 30 / 24,
'sc1': 0.025 / 30 / 24
},
'us-east-2': {
@chicagobuss
chicagobuss / bash_to_gist.sh
Created February 28, 2019 14:06
make a gist from the shell
### how to upload to gist with bash / curl
DESC="file that I'm uploading"
FNAME="file_to_upload"
FPATH="/tmp/file_to_upload"
# 1. Somehow sanitize the file content
# Remove \r (from Windows end-of-lines),
# Replace tabs by \t
# Replace " by \"
@chicagobuss
chicagobuss / match_jmx_metrics
Created February 26, 2019 02:28
matched jmx metrics
#####################################
Instance: 10.74.147.10:7203
#####################################
Matching: 1/350. Bean name: kafka.network:type=RequestMetrics,name=RequestsPerSec,request=OffsetCommit,version=6 - Attribute name: Count - Attribute type: long
Matching: 2/350. Bean name: kafka.network:type=RequestMetrics,name=ResponseSendTimeMs,request=FetchConsumer - Attribute name: 50thPercentile - Attribute type: double
Matching: 3/350. Bean name: kafka.network:type=RequestMetrics,name=ResponseSendTimeMs,request=FetchConsumer - Attribute name: Mean - Attribute type: double
Matching: 4/350. Bean name: kafka.network:type=RequestMetrics,name=ResponseSendTimeMs,request=FetchConsumer - Attribute name: 99thPercentile - Attribute type: double
Matching: 5/350. Bean name: kafka.network:type=RequestMetrics,name=ResponseSendTimeMs,request=FetchConsumer - Attribute name: 999thPercentile - Attribute type: double
@chicagobuss
chicagobuss / all_jmx_metrics
Created February 26, 2019 02:25
all jmx metrics
This file has been truncated, but you can view the full file.
#####################################
Instance: 10.74.147.10:7203
#####################################
Not Matching: Bean name: kafka.log:type=Log,name=Size,topic=lkc-4vndj__confluent-ksql-ksql-prodtransient_5013047390911865834_1548275444821-KSTREAM-AGGREGATE-STATE-STORE-0000000006-repartition,partition=1 - Attribute name: Value - Attribute type: java.lang.Object
Not Matching: Bean name: kafka.cluster:type=Partition,name=InSyncReplicasCount,topic=__consumer_offsets,partition=37 - Attribute name: Value - Attribute type: java.lang.Object
Not Matching: Bean name: kafka.network:type=RequestMetrics,name=ResponseQueueTimeMs,request=ListGroups - Attribute name: Count - Attribute type: long
Not Matching: Bean name: kafka.network:type=RequestMetrics,name=ResponseQueueTimeMs,request=ListGroups - Attribute name: Min - Attribute type: double
Not Matching: Bean name: kafka.network:type=RequestMetrics,name=ResponseQueueTimeMs,request=ListGroups - Attribute name: 50thPercentile - A
@chicagobuss
chicagobuss / metric-consumer.go
Last active May 15, 2018 18:19
metric-consumer
package main
import (
"encoding/json"
"fmt"
"time"
"github.com/confluentinc/confluent-kafka-go/kafka"
"github.com/prometheus/common/model"
)
@chicagobuss
chicagobuss / policy.json
Created February 12, 2018 21:39
example s3 bucket policy with kms enforced
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyUnEncryptedObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::prod-secrets/*",
"Condition": {
@chicagobuss
chicagobuss / export.py
Created February 2, 2018 22:04
github export
```#!/usr/bin/env python
"""
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
"""
import csv
import requests
import sys
@chicagobuss
chicagobuss / k8s-gke-perms.txt
Created January 31, 2018 14:06
perms in gke k8s 1.8
# If you're having problems creating an admin role binding in k8s on GKE,
# make sure you're a project owner first in the project the cluster is in
# Then you can do this:
~$ kubectl create clusterrolebinding foo-cluster-admin-binding --clusterrole=cluster-admin --user="foo@gmail.com"
clusterrolebinding "foo-cluster-admin-binding" created