Skip to content

Instantly share code, notes, and snippets.

View joemiller's full-sized avatar

joe miller joemiller

View GitHub Profile

Loki log ingestion issue

Loki stops ingesting logs from promtail. The error messages are a stream HTTP 499 errors in the gateway component which is based on nginx. Ex:

10.194.148.169 - - [17/Feb/2022:21:08:28 +0000]  499 "POST /loki/api/v1/push HTTP/1.1" 0 "-" "promtail/" "-"
10.194.90.195 - - [17/Feb/2022:21:08:28 +0000]  499 "POST /loki/api/v1/push HTTP/1.1" 0 "-" "promtail/" "-"
@joemiller
joemiller / run-all-wrapper.sh
Last active January 6, 2022 01:24
terragrunt wrapper to leverage bash/zsh shell globbing support for the run-all command set
#!/bin/bash
#
# uber simple wrapper to leverage bash/zsh shell globbing support with terragrunt's `--terragrunt-include-dir=` flag.
set -eou pipefail
[[ -n "${DEBUG:-}" ]] && set -x
if [[ "$#" -lt 2 ]]; then
echo "Usage: $0 [init|plan|apply] GLOB"
@joemiller
joemiller / Dockerfile
Last active May 6, 2026 17:37
convert RFC 3164 syslog messages to RFC 5424 for ingestion into Loki/promtail
FROM balabit/syslog-ng:3.35.1
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
#!/bin/bash
#
# Start the server in dev mode:
#
# bash setup-pki-vault-server.sh
#
# In another window, generate a cert:
#
# VAULT_ADDR=http://127.0.0.1:8200 VAULT_TOKEN=root vault write pki/issue/any common_name=foo
#
@joemiller
joemiller / renewer.go
Created June 16, 2021 15:57
demo of vault token renewer go routine from internal project
type VaultDriver struct {
vaultClient *vaultapi.Client
project string
}
func (d VaultDriver) TokenRenewer(ctx context.Context) error {
renewer, err := d.vaultClient.NewRenewer(&vaultapi.RenewerInput{
Secret: &vaultapi.Secret{
Auth: &vaultapi.SecretAuth{
ClientToken: d.vaultClient.Token(),
@joemiller
joemiller / foo.sh
Last active September 24, 2020 22:51
demo of bash vars global scope by default
#!/bin/bash
foo() {
op=$1
# local op=$1
echo "foo: op is $op"
}
main() {
op="main"
@joemiller
joemiller / installer.sh
Created May 22, 2020 21:50
install script for autotag, generated with godownloader
#!/bin/sh
set -e
# Code generated by godownloader on 2020-05-22T18:17:38Z. DO NOT EDIT.
#
usage() {
this=$1
cat <<EOF
$this: download go binaries for pantheon-systems/autotag
@joemiller
joemiller / poc.py
Last active May 7, 2020 16:44
POC getting cpu% from cgroups
#!/usr/bin/env python
# Usage:
# curl -sL https://gist.githubusercontent.com/joemiller/d89002a0d169cbb977e735df20e4ebd7/raw/poc.py | python | sort -rnk3 | head -n10
# or with a different INTERVAL:
# curl -sL https://gist.githubusercontent.com/joemiller/d89002a0d169cbb977e735df20e4ebd7/raw/poc.py | INTERVAL=60 python | sort -rnk3 | head -n10
import os
import time
def main():
@joemiller
joemiller / disable-gcp-accounts-daemon.sh
Last active April 10, 2020 20:35
disable and stop google-accounts-daemon
sed -i -e 's/accounts_daemon = true/accounts_daemon = false/' /etc/default/instance_configs.cfg.template
/bin/google_instance_setup
systemctl restart google-accounts-daemon
@joemiller
joemiller / stackdriver.json
Created February 11, 2020 15:33
stackdriver webhook payload v1.2 example
{
"incident": {
"incident_id": "0.lj2va6zdkemq",
"resource_id": "",
"resource_name": "foobar appserver",
"resource": {
"type": "gce_instance",
"labels": {
"instance_id": "8979287136362607111",
"zone": "us-central1-c"