Skip to main content

Scripts Reference

Standalone scripts in the project root. Run with .venv/bin/python3 <script>.

Data Refresh Scripts

ScriptDescription
refresh_risk.pyRecomputes cluster risk scores using cluster_risk_rules.yaml
refresh_scores.pyRecomputes health scores using health_rules.yaml
refresh_unified.pyRuns the unified scoring pipeline (unified_rules.yaml) -- merges health + risk + alerts
seed_issues.pySeeds/rebuilds the issues table from current alerts and issue rules

Alert Pipeline Scripts

ScriptDescription
load_lark_alerts.pyParses Lark alert messages and inserts into alerts.lark_alerts. Core parser: parse_alert_card(msg) extracts fields from interactive card JSON.
process_lark_page.pyBatch processor for saved MCP result files. Usage: .venv/bin/python3 process_lark_page.py <filepath>
daily_alert_pipeline.pyOrchestrates the daily alert ingestion and processing pipeline
alert_webhook.pyWebhook receiver for real-time alert ingestion
populate_recommendations.pyGenerates daily recommendations per alert type into alerts.alert_recommendations

Reporting Scripts

ScriptDescription
build_digest_card.pyBuilds a Lark digest card summarizing daily alert activity
create_alerts_sheet.pyExports alert data to a spreadsheet format

Usage Examples

# Refresh all scores
.venv/bin/python3 refresh_unified.py

# Process a new page of Lark alerts
.venv/bin/python3 process_lark_page.py /path/to/mcp_result.json

# Run the daily pipeline
.venv/bin/python3 daily_alert_pipeline.py

# Seed issues from current alerts
.venv/bin/python3 seed_issues.py

Notes

  • All scripts require an active SSH tunnel to StarRocks (or STARROCKS_HOST=127.0.0.1 with tunnel running)
  • Scripts read connection details from .env
  • process_lark_page.py outputs a summary line: msgs=N alerts=N range=X to Y has_more=bool followed by PAGE_TOKEN=... or DONE=true