Skip to content

Instantly share code, notes, and snippets.

import logging
import requests
from requests.adapters import HTTPAdapter, Retry
from requests.exceptions import RetryError, HTTPError
# Configure basic logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def call_api_with_retries():
@erik4github
erik4github / spl
Last active January 21, 2025 16:34
| bin span=1d _time
| stats sum(count) AS daily_total by _time
| where _time < relative_time(now(), "d") // Exclude today for calculating historical metrics
| eventstats avg(daily_total) AS avg_total stdev(daily_total) AS stdev_total
| eval upper_bound = avg_total + (2 * stdev_total)
| eval lower_bound = avg_total - (2 * stdev_total)
| append [
search <your_base_search> earliest=-1d@d latest=@d
| bin span=1d _time
| stats sum(count) AS daily_total by _time
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
# -----------------------------------------------------
# Step 1: Generate Sample Data
# -----------------------------------------------------
# Create a date range for 10 days.
start_date = datetime(2025, 1, 1)
dates = [start_date + timedelta(days=i) for i in range(10)]
import psycopg2
from psycopg2 import OperationalError
from psycopg2.extras import RealDictCursor
CONNECTION = None
def _new_connection():
cfg = get_db_secrets()
return psycopg2.connect(
host=cfg.host,