Skip to content

Instantly share code, notes, and snippets.

View drconopoima's full-sized avatar

Luis Jesús Díaz drconopoima

View GitHub Profile
@drconopoima
drconopoima / nginx_exporter.md
Created July 1, 2025 20:20 — forked from mattpr/nginx_exporter.md
using mtail and nginx access_log to export custom metrics from nginx for prometheus and other monitoring scrapers

Feedback

I'm sure I've gotten multiple things wrong here. Either flat out wrong, anti-patterns or just sub-optimal. I'm new to prometheus, grafana and mtail...so please feel free to share corrections/suggestions.

Background

There are a handful of custom nginx stats exporters.

Some are tying into internal nginx stats like the official nginx exporter: nginx-prometheus-exporter

@drconopoima
drconopoima / nginx-combined.mtail
Last active July 1, 2025 22:39
Mtail metrics exporting utilities
# This file is available under the Apache license.
# TARGET_OS=linux
# TARGET_ARCH=amd64
# mtail_latest="$(curl -qfsSL https://api.github.com/repos/google/mtail/releases | jq '.[].html_url' | grep '[0-9].[0-9].[0-9]' | grep -v '\(dev\|next\|alpha\|beta\|rc[0-9]\+\)' | awk -F'/v' '{print $NF}' | cut -d'"' -f1 | sort -V -r | head -n 1)"
# curl -qfsSL -o "mtail_${mtail_latest}_${TARGET_OS}_${TARGET_ARCH}.tar.gz" "https://github.com/google/mtail/releases/download/v${mtail_latest}/mtail_${mtail_latest}_${TARGET_OS}_${TARGET_ARCH}.tar.gz"
# [[ $? -eq 0 ]] || exit 10
# curl -qfsSL -o- "https://github.com/google/mtail/releases/download/v${mtail_latest}/checksums.txt" | grep "mtail_${mtail_latest}_${TARGET_OS}_${TARGET_ARCH}.tar.gz" | tee "mtail_${mtail_latest}_${TARGET_OS}_${TARGET_ARCH}.tar.gz.sha256" 1>/dev/null
# grep "$(sha256sum "mtail_${mtail_latest}_${TARGET_OS}_${TARGET_ARCH}.tar.gz" )" "mtail_${mtail_latest}_${TARGET_OS}_${TARGET_ARCH}.tar.gz.sha256" && tar xvzf "mtail_${mtail_latest}_${TARGET_OS}_${TARGET_
@drconopoima
drconopoima / multiprocessing_logging.py
Created January 29, 2025 10:18 — forked from gwerbin/multiprocessing_logging.py
Demo of logging in a multi-processing context.
"""Demo of logging in a multi-processing context.
Based on the Python "Logging Cookbook":
https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes
Note on `QueueListener`:
The main difference between the Cookbook example and this demo is that I use
the `QueueListener` convenience class, whereas they write a bespoke
`listener_process` function which does more or less the same thing as
@drconopoima
drconopoima / v(venv)env
Created January 29, 2025 07:56 — forked from liamcryan/v(venv)env
create venv within venv (with_pip=True)
"""
Normally to create a virtual environment, we can do so from the command prompt with::
C:\Users\me>python -m venv venv
This doesn't work when we are within a virtual environment though::
(venv) C:Users\me>python -m venv venv2
Error: Command '['C:\\Users\\me\\venv2\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3221226505.
@drconopoima
drconopoima / AttachDatabases.ps1
Created December 4, 2024 07:11 — forked from Krusen/AttachDatabases.ps1
Attach/dettach databases with powershell
# Run as Administrator
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
Set-Location $PSScriptRoot
# Load configuration XML file.
[xml]$config = Get-Content "DatabasesConfig.xml"
#Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
#Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
@drconopoima
drconopoima / signing-vbox-kernel-modules.md
Created October 25, 2023 21:50 — forked from reillysiemens/signing-vbox-kernel-modules.md
Signing VirtualBox Kernel Modules

Signing VirtualBox Kernel Modules

These are the steps I followed enable VirtualBox on my laptop without disabling UEFI Secure Boot. They're nearly identical to the process described on [Øyvind Stegard's blog][blog], save for a few key details. The images here are borrowed from the [Systemtap UEFI Secure Boot Wiki][systemtap].

  1. Install the VirtualBox package (this might be different for your platform).
    src='https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo'
@drconopoima
drconopoima / Arch Secure Laptop Install.md
Created April 30, 2023 19:09 — forked from Th3Whit3Wolf/Arch Secure Laptop Install.md
My install instruction for a secure Arch Linux (sway) laptop workstation

What's Cool

  • Encrypted root partition
    • AES-256 bit cipher
    • Argon2id variant for PBKDF
    • Sha3-512 bit hash
  • rEFInd bootloader
    • With dreary theme
    • Optimal Settings (optimized for aesthetics, and boot time)
  • Boot into backups thanks to refind-btrfs
#!/usr/bin/env bash
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
## Add sysctl config
echo 'fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
@drconopoima
drconopoima / corefonts.sha512
Created April 24, 2023 22:04
fetchmsttfonts
7099c389126d2af146ff082a840c77787f28e59cc8b5fd4147b9a45a34c649bc69ba6ec7c338703950389fce3ac3a7f118f503b7434c7ceb54c89d6210508bd4 *andale32.exe
299cb200f72f146fedfb2bb1895c36f5234aa5abd084e7c962ec7b14f087c1f582b51f5fdcb72e48b806ee02661c34766ca8a03bb0f2fadf662aaf46cc5f0e48 *arial32.exe
8a947764f2c725f2c506c12ca6f77142402174a0fadeeb72b211931136d82b541bb279b415d74032bc51b00efac9516e5cf68d8d4f172ff8549398ca28722c3a *arialb32.exe
6ad11015d568d58f6e4375e04411dd702b5c4e454b82998b5044cd8352dae27fea1df6469a05067ccc8c14f4ba87ec99e8329c104551dde1eb48be8ce2b78708 *comic32.exe
7e2425d578dd626cc2b418efec72c53e35392c60610cf5e4a99c614fa86cb673167fbcc1691fe59b99bcd19e8f261321be9ea7e30fb84c80ce0a312fd47045c5 *courie32.exe
33e623179af8a418845fed64f7b176a1e721ee4e0ece29d3135d01b81be4238454dd4eb3d2166e8587bb7cced0c258a294eb55e637855f818deb28853f006ef4 *georgi32.exe
6f9318806efbd3b3727e71170cc3ab378d6151887abcb7fad01bd4cb45c2e127f8aea81a3a99bc77c2ce2424fb1acbc230ffc6c23e390c8800710b45b1367c3b *impact32.exe
6035b971290cd0795389c2e8a
@drconopoima
drconopoima / pyenv-common-build-problems-useful.md
Last active August 1, 2025 20:46
Pyenv Wiki Common Build Problems when it was useful

Prerequisites

Make sure to follow this guidance for your platform before any troubleshooting.

  • Ubuntu/Debian:
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git cmake