Skip to content

Instantly share code, notes, and snippets.

View wbh1's full-sized avatar
💭
I may be slow to respond.

Will Hegedus wbh1

💭
I may be slow to respond.
View GitHub Profile
@wbh1
wbh1 / serverA
Created September 27, 2022 20:45
Prometheus Disk Usage
BLOCK ULID MIN TIME MAX TIME DURATION NUM SAMPLES NUM CHUNKS NUM SERIES SIZE
01GBM13DBXT6XN3ZGKJPJ2V7WR 1661536800002 1661731200000 53h59m59.998s 70112453167 601119200 12427715 148653439698
01GBSSDM8T2KVZYPKRG4JTJ2N8 1661731200002 1661925600000 53h59m59.998s 70383398509 605278955 12671976 147864644815
01GBZV1489385KQPKN089V1PT7 1661925600025 1662120000000 53h59m59.975s 70549912421 604845812 12651303 144103503098
01GC5D0FRGVF2DNK2WV0MD9C1T 1662120000027 1662314400000 53h59m59.973s 67869892593 593215701 12530552 116217062371
01GCB6D2ERZKD15MJ924BNYDWH 1662314400031 1662508800000 53h59m59.969s 70322198493 602890695 12632449 117301314338
01GCGZV8SPWJZ2A348G0ZCPDEY 1662508800031 1662703200000 53h59m59.969s 70294210625 604614308 12684735 124143212184
01GCPS876M0SF4459H4NNZSG9V 1662703200056 1662897600000 53h59m59.944s 71239262815 610539678 12644227 128263076465
01GCWJMRNWAJAN6NPHJHGMFT6Y 1662
@wbh1
wbh1 / raise.md
Last active April 6, 2022 14:12
Python Exceptions Chaining with "raise from"

Normal Chaining

def regular_chaining():
    try:
        open("file_doesnt_exist.txt")
    except Exception as e:
        raise ValueError("Couldn't open specified file!") from e
Running regular_chaining()
@wbh1
wbh1 / vector.toml
Created December 22, 2021 15:44
Vector Prometheus Exporter TLS Termination
# __ __ __
# \ \ / / / /
# \ V / / /
# \_/ \/
#
# V E C T O R
# Configuration
#
# ------------------------------------------------------------------------------
# Website: https://vector.dev
@wbh1
wbh1 / prom2csv.py
Created November 17, 2020 14:56
Create a CSV based on a Prometheus Query's results
import requests
from csv import writer
BASEURL = "http://prometheus.example.com:9090/api/v1"
s = requests.sessions.Session()
QUERY = 'windows_exporter_build_info{version!="0.15.0"}'
resp = s.get(BASEURL + '/query', params={"query": QUERY})
with open("prometheus.csv", 'w') as file:
- job_name: 'icmp'
metrics_path: /probe
params:
module: [icmp]
file_sd_configs:
- files:
- /conf/targets/lu_*.json
relabel_configs:
- source_labels: [__address__]
regex: (.*?)(:[0-9]+)?
route:
receiver: slack
receivers:
- name: 'slack'
slack_configs:
- api_url: xxx
icon_url: https://avatars3.githubusercontent.com/u/3380462
channel: '#xxx'
fields:
- title: '[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.alertname }} - {{ range .Alerts }} {{ .Labels.severity }} {{ end }}'