Skip to main content

Time series anomaly detection using Redis TimeSeries and Luminol

Project description

Potoos

Potoos is a lightweight Python library for time series anomaly detection using Redis Time Series and Luminol. Monitor your time series data for anomalies with minimal configuration.

Overview

Potoos combines the power of:

  • Redis Time Series for efficient time series data storage and retrieval
  • Luminol for robust anomaly detection algorithms

This makes it ideal for monitoring metrics, detecting unusual patterns, and identifying outliers in your time series data.

Features

  • 🔄 Seamless Redis TimeSeries Integration: Automatically verifies Redis module availability
  • 🔍 Configurable Time Series Retrieval: Forward or reverse order, with flexible query options
  • 🚨 Anomaly Detection: Uses Luminol's advanced algorithms to identify anomalies
  • 🛠️ Highly Configurable: Customize both time series retrieval and anomaly detection parameters

Requirements

  • Python 3.10+
  • Redis server with the RedisTimeSeries module installed
  • Dependencies:
    • redis-py
    • luminol

Installation (Soon !)

pip install potoos

Ensure your Redis server has the TimeSeries module installed:

# Check if module is installed
redis-cli MODULE LIST | grep timeseries

# If not found, install using Redis Stack or Redis modules

Quick Start

Here's a simple example of how to use Potoos:

from redis import Redis
from potoos.client import PotoosClient
from potoos.models.config import TimeSeriesConfig, AnomalyDetectionConfig

# Connect to Redis
redis_client = Redis(host='localhost', port=6379)

# Initialize Potoos client with default configurations
client = PotoosClient(redis_client)

# Or with custom configurations
client = PotoosClient(
    redis_client=redis_client,
    time_series_config=TimeSeriesConfig(reversed=False, count=1000),
    anomaly_config=AnomalyDetectionConfig(algorithm_name='bitmap_detector')
)

# Monitor a time series key for anomalies
results = client.monitor('metrics:cpu:usage')

# Process the results
if results:
    print(f"Analysis complete. Found {results.meta_data.anomalies_found} anomalies")
    print(f"Analyzed {results.meta_data.data_points_analyzed} data points")
    
    # Print information about each anomaly
    for anomaly in results.anomalies:
        print(f"Anomaly at {anomaly.exact_timestamp}")
        print(f"Anomaly score: {anomaly.anomaly_score}")
        
    # Or access anomaly score in TimeSeries object
    print(f"Anomaly scores: {results.scores}")

    # Access time range analyzed
    time_range = results.meta_data.time_range_analyzed
    print(f"Time range analyzed: {time_range.start} to {time_range.end}")

Configuration

Time Series Configuration

from potoos.models.config import TimeSeriesConfig

# Default values shown
config = TimeSeriesConfig(
    count=None,         # Maximum number of samples to return
    aggregation=None,   # Aggregation type (e.g., 'avg', 'sum', 'min', 'max')
    bucket_size=None,   # Time bucket for aggregation in milliseconds
    filter_by=None,     # Filtering options for labels
    align=None,         # Timestamp alignment control
    start=None,         # Start timestamp
    end=None,           # End timestamp
    reversed=False      # Return results in reverse order when True
)

Anomaly Detection Configuration

from potoos.models.config import AnomalyDetectionConfig

# Default values shown
config = AnomalyDetectionConfig(
    algorithm_name='bitmap_detector',  # Algorithm to use
    score_threshold=None,              # Threshold for anomaly detection
    score_percentile_threshold=None,   # Percentile threshold
    algorithm_params={}                # Additional algorithm parameters
)

How It Works

  1. Initialization: PotoosClient connects to your Redis instance and verifies the TimeSeries module is available
  2. Data Retrieval: When monitoring, it fetches time series data according to your configuration
  3. Anomaly Detection: The retrieved data is analyzed using Luminol's algorithms
  4. Results: You receive detailed information about detected anomalies and analysis metadata

Note on Dependencies

Potoos requires NumPy 1.22.4 or earlier due to Luminol's dependency on the numpy.asscalar() function, which was removed in later versions of NumPy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

potoos-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

potoos-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file potoos-0.1.0.tar.gz.

File metadata

  • Download URL: potoos-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for potoos-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e9cc30a019fd70e11649c022618c25d8ea1eec18bfc861da2e2d053aaef738c9
MD5 7e9e56ac8186c2b77c565627367d518d
BLAKE2b-256 e1ce9b9ea0e653ab0577a0f68b843a72f68ed32e7f5af2783b3900a5141cc395

See more details on using hashes here.

Provenance

The following attestation bundles were made for potoos-0.1.0.tar.gz:

Publisher: python-publish.yml on afranche7/Potoos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file potoos-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: potoos-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for potoos-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a0dd2ad4bbd7787d1736bd0b71951955f6feb26fbfc75dcd22ad10b45b4f949
MD5 da0919d87e073ba6fc74bd08a345027b
BLAKE2b-256 65f9eda1688395ad5142c9d5f42f27c25ebc4ffbf4a79c17fe215f1854cc3c49

See more details on using hashes here.

Provenance

The following attestation bundles were made for potoos-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on afranche7/Potoos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page