Skip to content

Instantly share code, notes, and snippets.

View FUSAKLA's full-sized avatar
🧦

Martin Chodur FUSAKLA

🧦
View GitHub Profile
@FUSAKLA
FUSAKLA / validation.out
Last active November 23, 2020 06:47
promruval validation output
$ promruval validate --config-file validation.yaml rules.yaml
Validation rules used:
check-severity-label:
- has labels: `severity`
- label `severity` has one of the allowed values: `info`,`warning`,`critical`
check-playbook-annotation:
- has all of these annotations: `playbook`,`title`
- Annotation `playbook` is a valid URL and does not return HTTP status 404
@FUSAKLA
FUSAKLA / rules.yaml
Last active November 23, 2020 06:47
promruval example Prometheus rules
groups:
- name: test-group
rules:
- alert: TrafficDifference1w
expr: |
abs(
rate(http_requests_total{dc="us-west"}[5m])
-
rate(http_requests_total{dc="us-west"}[5m] offset 7d)
) > 1000
@FUSAKLA
FUSAKLA / validation.yaml
Last active November 23, 2020 06:44
promruval severity example
validationRules:
- name: check-severity-label
scope: Alert # Defines which rule types should be validated by this rule.
validations:
- type: hasLabels # Name of the validation check.
params: # Each validation check has its own params depending on the type.
labels: [ "severity" ]
- type: labelHasAllowedValue
params:
label: "severity"
@FUSAKLA
FUSAKLA / posthog_cleanup.py
Last active November 7, 2022 11:05
PostHog data retention cleanup job
#!/usr/bin/python
import logging
import os
from datetime import datetime, timedelta
import django
django.setup()
@FUSAKLA
FUSAKLA / debugging-slow-grafana-dashboard.md
Last active April 25, 2024 12:45
Speeding up Grafana dashboard

Intro

So your dashboard is slow? We are doing our best but maybe it's time to think if the issue isn't on your side.

Some of our dashboards looks like https://www.theworldsworstwebsiteever.com/. Are you sure you really need to see all the time all the data? Or do you really need to see data for last week or month all the time? How often do you use filtering by some of those variables in your dashboard?

Let's not end up as your mother saying:

But.. but.. I might need this in future so let's leave this icon on the Desktop.

@FUSAKLA
FUSAKLA / alertmanager-configmap.yaml
Created March 9, 2018 20:56
Fixed example of configmap containing alertmanager config
apiVersion: v1
kind: ConfigMap
metadata:
name: alertmanager-conf
labels:
name: alertmanager-conf
namespace: monitoring
data:
alertmanager.yml: |-
global:
@FUSAKLA
FUSAKLA / prometheus-rules-configmap.yaml
Created March 9, 2018 20:56
Fixed example of configmap containing prometheus rules and alerts config
apiVersion: v1
data:
prometheus.rules: |
# TODO add rules
prometheus.alerts: |
# host rules
ALERT high_node_load
IF node_load1 > 20
FOR 10s
LABELS { severity = "critical" }