Anomaly
Find outliers, discords, repeated motifs and change points in numeric series from SQL
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available Β· $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/anomaly/index.md to help me query Anomaly with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Find outliers in a time series
Example output Β· captured
- Connector release
- v0.6.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT "index"
FROM anomaly.main.zscore_anomalies((SELECT CASE WHEN i = 19 THEN 100.0 ELSE 0.0 END FROM range(20) t(i) ORDER BY i))
| index |
|---|
| 19 |
Quick start
Choose where to run Anomaly, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'anomaly' AS anomaly (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-anomaly-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'anomaly' AS anomaly (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-anomaly:0.6.0'
);
3. Run a query
SELECT "index"
FROM anomaly.main.zscore_anomalies((SELECT CASE WHEN i = 19 THEN 100.0 ELSE 0.0 END FROM range(20) t(i) ORDER BY i))
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connectorβs deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'anomaly' AS anomaly
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT "index"
FROM anomaly.main.zscore_anomalies((SELECT CASE WHEN i = 19 THEN 100.0 ELSE 0.0 END FROM range(20) t(i) ORDER BY i))
Query Farm operates Anomaly for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use anomaly as the catalog alias for the query below.
4. Run a query
SELECT "index"
FROM anomaly.main.zscore_anomalies((SELECT CASE WHEN i = 19 THEN 100.0 ELSE 0.0 END FROM range(20) t(i) ORDER BY i))
Technical details
- Verified connector release
- v0.6.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until youβre ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'anomaly' AS anomaly (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-anomaly-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'anomaly' AS anomaly (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-anomaly:0.6.0'
);
Overview
Time-series anomaly detection: matrix profile, change points, z-score for SQL.

Find anomalies, motifs, discords, and regime changes in time-series data directly in DuckDB SQL β no Python notebook, no data export, no round trip to a separate data-science stack.
What it is
The anomaly extension brings industrial-strength time-series anomaly detection to your SQL queries. It is for data engineers, analysts, and SREs who keep their metrics, sensor readings, financial ticks, and log volumes in DuckDB and want to spot the unusual subsequence, the repeated pattern, the structural break, or the single outlier without leaving the database. Every detector runs server-side inside a VGI worker that DuckDB attaches over Apache Arrow, so the same analysis that normally lives in a data-science script becomes an ordinary, composable SQL function.
Key concepts
- Matrix profile β for every fixed-length subsequence, its z-normalized distance to its nearest neighbour. The largest distances are discords (anomalies); the smallest are motifs (repeated patterns). This is the modern foundation for shape-based anomaly and pattern discovery.
- Change points β structural breaks where a series shifts from one regime to another (a level shift, a variance change), found by penalized segmentation.
- Point outliers β individual samples that sit far from the series mean, a light first pass that needs no subsequence analysis.
When to use it
Reach for this worker for outlier detection on metrics and IoT sensor data, motif/discord discovery in financial or operational series, segmentation of telemetry into stable regimes, and general series quality checks β all expressed as plain SQL over an ordered input query, or an array assembled with array_agg.
Built on
Under the hood the extension stands on three best-in-class scientific Python libraries. Matrix-profile analysis is powered by STUMPY (documentation), whose numba-accelerated implementation of the Matrix Profile computes the distance from every subsequence to its nearest neighbour. Change-point (regime-shift) detection uses ruptures (documentation) with its PELT and dynamic-programming search algorithms, and the lightweight point-outlier check is plain NumPy (documentation) z-scoring.
Catalog
Everything anomaly exposes once attached β read straight from the worker's
released build.
main 5 functions
Time-series anomaly detection: matrix profile, change points, z-score for SQL
Schema examples (5)
Full matrix profile of a 10-point series with window 4 (7 nearest-neighbour distances).
SELECT anomaly.main.matrix_profile([1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0]::DOUBLE[], 4);
Start index of the top discord (the most anomalous window-4 subsequence) β the spike at 18 gives 16.
SELECT anomaly.main.discord_index([1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0,3.0,2.0,50.0,2.0,3.0,4.0,3.0,2.0,1.0]::DOUBLE[], 4);
Start index of the top motif (the most repeated window-5 subsequence) β the two triangles give 0.
SELECT anomaly.main.motif_index([0.0,2.0,4.0,2.0,0.0,0.1,0.116,0.133,0.15,0.166,0.183,0.2,0.0,2.0,4.0,2.0,0.0,0.3,0.4,0.5]::DOUBLE[], 5);
Automatically detect regime changes on a single step β the level shift at index 8 gives [8].
SELECT anomaly.main.change_points([1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0]::DOUBLE[]);
1 more example
Flag z-score point outliers beyond 2 sigma β the 40.0 spike is index 5, so the result is [5].
SELECT anomaly.main.zscore_anomalies([10.0,10.0,11.0,9.0,10.0,40.0,10.0,9.0,11.0]::DOUBLE[], 2.0);
change_points (data TABLE, n_bkps := BIGINT) +2 overloads
Regime-change indices from an ordered numeric table; optional n_bkps selects an exact count.
change_points(data TABLE, n_bkps BIGINT)change_points(values DOUBLE[]) β BIGINT[]change_points(values DOUBLE[], n_bkps BIGINT) β BIGINT[]
Change point rows
SELECT "index"
FROM anomaly.change_points((SELECT CASE WHEN i < 8 THEN 1.0 ELSE 9.0 END FROM range(16) t(i) ORDER BY i));
Auto-detect change points on a single step at index 8 -> [8].
SELECT anomaly.main.change_points([1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0]::DOUBLE[]);
Detect exactly one change point on a single step -> [8].
SELECT anomaly.main.change_points([1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0]::DOUBLE[], 1);
discord_index (data TABLE, window_size := BIGINT) +1 overload
Most anomalous window's zero-based start index from an ordered numeric table.
discord_index(data TABLE, window_size BIGINT)discord_index(values DOUBLE[], window BIGINT) β BIGINT
Discord index row
SELECT "index"
FROM anomaly.discord_index((SELECT i::DOUBLE FROM range(10) t(i) ORDER BY i), window_size := 4);
Index of the most anomalous window (a spike at 18 -> 16).
SELECT anomaly.main.discord_index([1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0,3.0,2.0,50.0,2.0,3.0,4.0,3.0,2.0,1.0]::DOUBLE[], 4);
matrix_profile (data TABLE, window_size := BIGINT) +1 overload
Matrix-profile distances as rows from an ordered numeric table.
matrix_profile(data TABLE, window_size BIGINT)matrix_profile(values DOUBLE[], window BIGINT) β DOUBLE[]
Matrix profile rows
SELECT "index", distance
FROM anomaly.matrix_profile((SELECT i::DOUBLE FROM range(10) t(i) ORDER BY i), window_size := 4);
Matrix profile of a 10-point series with window 4 (7 distances).
SELECT anomaly.main.matrix_profile([1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0]::DOUBLE[], 4);
motif_index (data TABLE, window_size := BIGINT) +1 overload
Most repeated window's zero-based start index from an ordered numeric table.
motif_index(data TABLE, window_size BIGINT)motif_index(values DOUBLE[], window BIGINT) β BIGINT
Motif index row
SELECT "index"
FROM anomaly.motif_index((SELECT i::DOUBLE FROM range(10) t(i) ORDER BY i), window_size := 4);
Index of the most repeated window (two triangles -> 0).
SELECT anomaly.main.motif_index([0.0,2.0,4.0,2.0,0.0,0.1,0.116,0.133,0.15,0.166,0.183,0.2,0.0,2.0,4.0,2.0,0.0,0.3,0.4,0.5]::DOUBLE[], 5);
zscore_anomalies (data TABLE, threshold := DOUBLE) +2 overloads
Point-outlier indices from an ordered numeric table; threshold defaults to 3 sigma.
zscore_anomalies(data TABLE, threshold DOUBLE)zscore_anomalies(values DOUBLE[], threshold DOUBLE) β BIGINT[]zscore_anomalies(values DOUBLE[]) β BIGINT[]
Z-score outlier rows
SELECT "index"
FROM anomaly.zscore_anomalies((SELECT CASE WHEN i = 19 THEN 100.0 ELSE 0.0 END FROM range(20) t(i) ORDER BY i));
Flag point outliers at the default 3-sigma cutoff β the lone 100.0 among zeros is index 19.
SELECT anomaly.main.zscore_anomalies([0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,100.0]::DOUBLE[]);
Flag samples beyond 2 sigma (an outlier at index 5).
SELECT anomaly.main.zscore_anomalies([10.0,10.0,11.0,9.0,10.0,40.0,10.0,9.0,11.0]::DOUBLE[], 2.0);
2 more examples
SELECT anomaly.main.change_points([1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0]::DOUBLE[]);
SELECT anomaly.main.change_points([1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0]::DOUBLE[], 1);
Try these queries
Full matrix profile of a 10-point series with window 4 (7 nearest-neighbour distances).
SELECT anomaly.main.matrix_profile([1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0]::DOUBLE[], 4)
Uses matrix_profile
Start index of the top discord (the most anomalous window-4 subsequence) β the spike at 18 gives 16.
SELECT anomaly.main.discord_index([1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0,3.0,2.0,1.0,2.0,3.0,4.0,3.0,2.0,50.0,2.0,3.0,4.0,3.0,2.0,1.0]::DOUBLE[], 4)
Uses discord_index
Start index of the top motif (the most repeated window-5 subsequence) β the two triangles give 0.
SELECT anomaly.main.motif_index([0.0,2.0,4.0,2.0,0.0,0.1,0.116,0.133,0.15,0.166,0.183,0.2,0.0,2.0,4.0,2.0,0.0,0.3,0.4,0.5]::DOUBLE[], 5)
Uses motif_index
Automatically detect regime changes on a single step β the level shift at index 8 gives [8].
SELECT anomaly.main.change_points([1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0]::DOUBLE[])
Uses change_points
Flag z-score point outliers beyond 2 sigma β the 40.0 spike is index 5, so the result is [5].
SELECT anomaly.main.zscore_anomalies([10.0,10.0,11.0,9.0,10.0,40.0,10.0,9.0,11.0]::DOUBLE[], 2.0)
Uses zscore_anomalies
Motif index row
SELECT "index"
FROM anomaly.motif_index((SELECT i::DOUBLE FROM range(10) t(i) ORDER BY i), window_size := 4)
Uses motif_index
6 more examples in the Catalog, each listed under the table or function it uses.
Anomaly is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Causal
Statistics & ML
Estimate treatment effects (ATE, ATT) and propensity scores from observational data with IPW, regression adjustment, and AIPW
Explain
Statistics & ML
Explain scikit-learn and XGBoost model predictions with per-row SHAP values and global feature importance
LightGBM
Statistics & ML
Train, tune, evaluate, and explain gradient-boosted classifiers and regressors, with a saved-model registry