This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| | 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
OlderNewer