Overview
This guide demonstrates anomaly detection across multiple time series using local and global methods. You will learn: • How to detect anomalies in each time series independently (local). • How to detect anomalies across multiple correlated time series (global). If you want to run this notebook interactively, click the badge below:Both local and global methods rely on the Nixtla API for anomaly detection. The main difference is how anomalies are identified: individually per time series vs. collectively across multiple series at the same timestamp.
Setup
1
1. Install and Import Dependencies
If you haven’t already, install Nixtla and import your dependencies.
2
2. Connect to the Nixtla API
Create a NixtlaClient instance. Replace ‘my_api_key_provided_by_nixtla’ with your actual API key.
Use an Azure AI Endpoint
To use an Azure AI endpoint, set the
To use an Azure AI endpoint, set the
base_url
argument explicitly:1. Dataset
We use an example from the SMD dataset (SMD: Server Machine Dataset). This dataset is a benchmark for anomaly detection across correlated server-performance metrics (CPU, memory, disk I/O, network throughput, etc.).File Used:
Data Size: 38 unique time series
Frequency: Hourly (freq=‘h’)
2. local vs. Global Methods
- local Method
- Global Method
Definition: local anomaly detection analyzes each time series in isolation. It flags anomalies based on each series’ individual deviation from its expected behavior.Pros: Efficient for individual metrics or when correlations between metrics are not relevant.Cons: May miss large-scale, system-wide anomalies that are only apparent when multiple series deviate simultaneously.
2.1.1 Example Usage
2.1.1 Example Usage
local detection code:Sample output logs:
local Method Log Output
local Method Log Output
Univariate Anomaly Detection Logs
2.1.2 Visualization
2.1.2 Visualization
This figure highlights anomalies detected in four selected metrics. Each metric is analyzed independently, so anomalies reflect unusual behavior within that series alone.


local Anomaly Detection Results
Summary
Local:
Best for detecting anomalies in a single metric or uncorrelated metrics. Low computational overhead, but may overlook cross-series patterns.
Global:
Considers correlations across metrics, capturing system-wide issues. More complex and computationally intensive than local methods.