Skip to content

Instantly share code, notes, and snippets.

@bakins
bakins / escape_test.go
Created April 2, 2019 21:39
compare escapeMetricName
package main
import (
"regexp"
"testing"
)
var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
func regexVersion(metricName string) string {
@bakins
bakins / x.diff
Created April 2, 2019 21:19
stastd_exporter speed up
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 August 17, 2017 19:34
Deployment API backed by helm charts and tiller
// 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 April 2, 2024 13:27
prometheus - scrape multiple containers in a pod
# 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
# 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 December 9, 2015 13:20
datadog 5.6.2 patch
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)
#!/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
}
@bakins
bakins / kube-proxy.json
Last active August 29, 2015 14:23
k8s build
#!/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
@bakins
bakins / gist:18ea6d23f72ecda03d96
Created June 4, 2015 21:01
terraform jq example
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 | .[]'
#!/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