Install
openclaw skills install @kwdb/kwdb-ts-anomaly-detectionAutomates end-to-end anomaly detection for time-series data stored in KaiwuDB / KWDB. Use this skill whenever the user mentions: - anomaly detection, outliers, or unusual patterns in KWDB / KaiwuDB time-series data - inspecting sensor metrics, IoT telemetry, or monitoring data for spikes, dips, or drift - "find anomalies", "detect outliers", "3-sigma check", "STL decomposition", or "time-series anomaly" - analyzing historical trends, abnormal points, or data quality issues in TS tables Even if the user does not explicitly say "anomaly", trigger this skill when they ask to inspect, validate, or flag unusual values in time-series columns (integer, float, double).
openclaw skills install @kwdb/kwdb-ts-anomaly-detectionDetect anomalies in KaiwuDB / KWDB time-series data by following the workflow below exactly and in order.
scripts/kwdb_sql_execute.py. Do NOT use kwdb-mcp-server MCP tools.references/constraints.md for the full list of rules and forbidden behaviors.python scripts/kwdb_sql_execute.py <host> <port> <username> <password> "<sql>" [output_file]
Omit output_file for metadata queries; include it for data queries to persist results in /tmp/.
Execute the following steps in strict order. MUST See references/workflow.md for full details on each step at first.
0. Security Confirmation (MANDATORY) — Before any operation, MUST display the security confirmation prompt and wait for the user to type "I AGREE". STOP permanently if consent is not obtained. See references/workflow.md Section 0 for the mandatory confirmation prompt.
Precondition Validation — Verify script availability, collect connection params (host, port, username, password), test connection, confirm target table/columns. If the user has not specified table/columns, query metadata via references/metadata-query.md and ask the user.
Intent Analysis & SQL Generation — Analyze user intent, generate SQL following references/ts-select.md, validate names against metadata. Stop if names don't exist.
Database-Type Validation — Stop if target DB is not TIME SERIES or all filtered columns are non-numeric.
Primary-Tag Check & Scope — If SQL filters by a specific primary tag → proceed (single tag). Otherwise, query all distinct primary tag values and repeat steps 5–13 per value (all tags).
SQL Refinement — Keep only timestamp + numeric columns, ensure ORDER BY <timestamp> DESC, MUST add LIMIT 1000 if no time filter conditions in where clause.
Final SQL Wrapper — Wrap as SELECT * FROM (<refined_sql>) AS anomaly_subquery ORDER BY <timestamp_column> ASC.
MUST Show SQL to User — Display the final SQL before execution.
Data Count Check (Conditional) — ONLY skip this step if refined_sql_limited contains a LIMIT clause (indicating data volume is already constrained by Step 5). If there is no LIMIT clause, execute COUNT query on refined_sql_limited. If count > 100,000, stop and inform user: "数据量过大({count} 条),无法执行异常检测。建议先对数据进行时间范围筛选或降采样后再试。"
Execute SQL — Run via kwdb_sql_execute.py, save result to /tmp/sql-result-*.
Validate Result — Stop if no data rows (single tag) or all tags empty.
Run Anomaly Detection — Execute python scripts/3-sigma-detection.py --input <result> --output <detect-result>.
Load Column Rules — Query column comments via references/column-comment.md to extract validation rules.
Filter by Rules — Remove anomalies that don't violate declared column-comment rules.
Generate Report — MUST Ask user for format (direct / Markdown / PDF / HTML) before.
references/report-template.md.references/workflow.md (Step 14):
references/report-template-html.md JSON template with detection results/tmp/report-json-<YYYYMMDDHHmmss>.jsonpython scripts/html-report-gen.py --input <json-file> --output /tmp/dt-report-<YYYYMMDDHHmmss>.htmlConsult references/error-handling.md for error codes, root causes, and recovery actions.