Skip to content

Instantly share code, notes, and snippets.

Brian Akins bakins

Block or report user

Report or block bakins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bakins
bakins / escape_test.go
Created Apr 2, 2019
compare escapeMetricName
View escape_test.go
package main
import (
"regexp"
"testing"
)
var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
func regexVersion(metricName string) string {
@bakins
bakins / x.diff
Created Apr 2, 2019
stastd_exporter speed up
View x.diff
diff --git a/exporter.go b/exporter.go
index 15c01b7..c225fcf 100644
--- a/exporter.go
+++ b/exporter.go
@@ -21,7 +21,6 @@ import (
"hash/fnv"
"io"
"net"
- "regexp"
"sort"
@bakins
bakins / alecton.proto
Last active Aug 17, 2017
Deployment API backed by helm charts and tiller
View alecton.proto
// API for a deployment service.
// It's easier for me to express an API as protobuf/service
// definitions. grpc-gateway would be used, so HTTP/1.1 and
// json would work. A simple browser API could be provided.
// This API is meant for users - both systems and humans -
// to easily deploy images.
//
// The envisioned flow is that the build system would push
// images to a registry and notify this service using CreateImage.
// Another step in the pipeline would then use DeployApplication
@bakins
bakins / gist:5bf7d4e719f36c1c555d81134d8887eb
Last active Sep 4, 2019
prometheus - scrape multiple containers in a pod
View gist:5bf7d4e719f36c1c555d81134d8887eb
# Example scrape config for pods
#
# The relabeling allows the actual pod scrape endpoint to be configured via the
# following annotations:
#
# * `prometheus.io/scrape`: Only scrape pods that have a value of `true`
# * `prometheus.io/path`: If the metrics path is not `/metrics` override this. This
# will be the same for every container in the pod that is scraped.
# * this will scrape every container in a pod with `prometheus.io/scrape` set to true and the
port is name `metrics` in the container
View kubernetes.sh
# get our hostip if running under kubernetes
if [[ -n "${KUBERNETES_NAMESPACE}" && -n "${KUBERNETES_PODNAME}" ]] ; then
KUBERNETES_HOSTIP=""
while true; do
KUBERNETES_HOSTIP=`kubectl get pods --namespace=${KUBERNETES_NAMESPACE} ${KUBERNETES_PODNAME} -o json | jq -r .status.hostIP`
if [ -n "${KUBERNETES_HOSTIP}" ] && [ "${KUBERNETES_HOSTIP}" != "null" ]; then
break
fi
sleep 1
done
@bakins
bakins / datadog.diff
Created Dec 9, 2015
datadog 5.6.2 patch
View datadog.diff
diff --git a/utils/dockerutil.py b/utils/dockerutil.py
index 975b260..d8e0868 100644
--- a/utils/dockerutil.py
+++ b/utils/dockerutil.py
@@ -82,6 +82,7 @@ def find_cgroup_filename_pattern(mountpoints, container_id):
stat_file_path_coreos = os.path.join(mountpoint, "system.slice")
stat_file_path_kubernetes = os.path.join(mountpoint, container_id)
stat_file_path_kubernetes_docker = os.path.join(mountpoint, "system", "docker", container_id)
+ stat_file_path_docker_daemon = os.path.join(mountpoint, "docker-daemon", "docker", container_id)
View kubernetes cert generation
#!/bin/bash
set -e
set -x
# create certs for a kubernetes cluster
usage() {
echo $0 [cluster_name] [service_ip] [additional_names]
echo additional name is generally the dns name
exit -1
}
View kube-proxy.json
#!/bin/bash
set -e
KUBERNETES_VERSION=0.19.0
RELEASE=${KUBERNETES_VERSION}-1
ETCD_VERSION=2.0.11
DOCKER_VERSION=1.6.2
WORKDIR=$(mktemp -d k8s.XXXXXXXXXX)
trap "rm -rf '${WORKDIR}'" EXIT
View gist:18ea6d23f72ecda03d96
cat terraform.tfstate | jq -r '.modules[0].resources | map(select(.type == "google_compute_instance")) | map([.primary.id, " ansible_ssh_host=", .primary.attributes["network_interface.0.access_config.0.nat_ip"]] | join("")) | sort | .[]'
View error.sh
#!/bin/sh
cd /tmp
curl -L -O https://github.com/coreos/rkt/releases/download/v0.5.4/rkt-v0.5.4.tar.gz
tar -zxvf rkt-v0.5.4.tar.gz
cd rkt-v0.5.4
echo yes | ./rkt trust --prefix coreos.com/etcd
./rkt fetch coreos.com/etcd:v2.0.4
You can’t perform that action at this time.