Skip to main content

An Sentry NodeStorage backend for OpenSearch

Project description

sentry-opensearch-nodestore

PyPI Version License: MIT

Sentry NodeStore backend powered by OpenSearch.

Supported Sentry 24.x / 25.x and OpenSearch 2.x / 3.x.

Use an OpenSearch cluster to store Sentry NodeStore payloads for better scalability and simpler retention (delete old indices) compared to PostgreSQL.

  • Stores payloads as compressed, non-indexed data
  • Daily indices with optional prefix (e.g., sentry-YYYY-MM-DD or sentry-<prefix>-YYYY-MM-DD)
  • Reads/deletes via alias (default: sentry)
  • Composable index templates (/_index_template)

Why OpenSearch for NodeStore

  • Horizontal scalability by adding data nodes
  • Sharding and replication for throughput and resilience
  • Automatic rebalancing when cluster grows
  • Cleanup is fast and reliable by dropping old daily indices (vs. large PostgreSQL tables)

Installation

Install the package for your Sentry deployment.

Option A: From PyPI

pip install sentry-opensearch-nodestore

Option B: Rebuild Sentry image with this backend

FROM getsentry/sentry:25.8.0
RUN pip install sentry-opensearch-nodestore

Environment variables

Variable Default Required Notes
SENTRY_NODESTORE_OPENSEARCH_NUMBER_OF_SHARDS 3 No Number of primary shards per daily index. Must be an integer.
SENTRY_NODESTORE_OPENSEARCH_NUMBER_OF_REPLICA 1 No Number of replicas per daily index. Must be an integer.
SENTRY_NODESTORE_OPENSEARCH_INDEX_PATTERN sentry-* No Must be a single value (one pattern). Accepts a plain string, a JSON array with exactly one item, or a comma-separated list that resolves to exactly one item. Used for the composable index template.
SENTRY_NODESTORE_OPENSEARCH_INDEX_CODEC zstd No Index codec. Use best_compression if your cluster doesn’t support zstd.
SENTRY_NODESTORE_OPENSEARCH_INDEX_PREFIX No Optional prefix for index names. If set (e.g., dev), indices become sentry-<prefix>-YYYY-MM-DD (e.g., sentry-dev-2025-08-29). If not set, indices are sentry-YYYY-MM-DD.

Configuration

Set the Sentry NodeStore backend and provide an OpenSearch client. The backend reads its settings from uppercase environment variables (see “Environment variables” below).

Option A: Use method self-hosted

# sentry.conf.py
import os
from opensearchpy import OpenSearch

# Option 1 (preferred): set these in your process environment (Docker/Compose, systemd, shell)
# Option 2: set here before Sentry constructs the NodeStore:
os.environ["SENTRY_NODESTORE_OPENSEARCH_INDEX_PREFIX"] = "dev"          # optional
os.environ["SENTRY_NODESTORE_OPENSEARCH_NUMBER_OF_SHARDS"] = "1"        # default: 3
os.environ["SENTRY_NODESTORE_OPENSEARCH_NUMBER_OF_REPLICA"] = "0"       # default: 1
os.environ["SENTRY_NODESTORE_OPENSEARCH_INDEX_PATTERN"] = "sentry-dev-*"  # single value
# Optional (default: zstd). Use best_compression for broad compatibility across cluster versions:
os.environ["SENTRY_NODESTORE_OPENSEARCH_INDEX_CODEC"] = "best_compression"

os_client = OpenSearch(
    ["https://admin:myStrongPassword123!@opensearch:9200"],
    http_compress=True,
    verify_certs=False,   # demo TLS only; in production, verify with a real CA/fingerprint
    timeout=60,
    ssl_show_warn=False,
    # For production TLS, prefer certificate verification or fingerprint pinning:
    # ssl_assert_fingerprint="AA:BB:CC:...:ZZ"
)

SENTRY_NODESTORE = "sentry_opensearch_nodestore.backend.OpenSearchNodeStorage"
SENTRY_NODESTORE_OPTIONS = {
    "es": os_client,
    # Optional overrides:
    # "alias_name": "sentry",
    # "template_name": "sentry",
    # "index": "sentry-{prefix}-{date}",  # default; resolved by env INDEX_PREFIX -> "sentry-<prefix>-{date}" or "sentry-{date}"
    # "refresh": False,  # default; set True only if you require read-after-write in-line
}

# Keep Sentry defaults
from sentry.conf.server import *  # noqa

# Ensure the app is importable (if needed for Django discovery)
INSTALLED_APPS = list(INSTALLED_APPS)
INSTALLED_APPS.append("sentry_opensearch_nodestore")
INSTALLED_APPS = tuple(INSTALLED_APPS)

Option B: Use helm chart sentry

  sentryConfPy: |
    # No Python Extension Config Given
    from opensearchpy import OpenSearch
    os.environ["SENTRY_NODESTORE_OPENSEARCH_INDEX_PREFIX"] = "dev"
    os.environ["SENTRY_NODESTORE_OPENSEARCH_NUMBER_OF_REPLICA"] = "0"
    os.environ["SENTRY_NODESTORE_OPENSEARCH_NUMBER_OF_SHARDS"] = "1"
    os.environ["SENTRY_NODESTORE_OPENSEARCH_INDEX_PATTERN"] = "sentry-dev-*"
    # Optional (default is zstd):
    os.environ["SENTRY_NODESTORE_OPENSEARCH_INDEX_CODEC"] = "best_compression"
    os_client = OpenSearch(
          ['https://admin:myStrongPassword123!@10.129.0.36:9200'],
          http_compress=True,
          verify_certs=False,
          timeout=60,
          ssl_show_warn=False  
      )
    SENTRY_NODESTORE = 'sentry_opensearch_nodestore.OpenSearchNodeStorage'
    SENTRY_NODESTORE_OPTIONS = {
        'es': os_client,
        'refresh': False
    }

    INSTALLED_APPS = list(INSTALLED_APPS)
    INSTALLED_APPS.append('sentry_opensearch_nodestore')
    INSTALLED_APPS = tuple(INSTALLED_APPS)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sentry_opensearch_nodestore-1.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file sentry_opensearch_nodestore-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentry_opensearch_nodestore-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a36c183b8cd4d8dff9112a4cbf87f79dcc727927dac7bb267f5dc1c8f5ce040
MD5 490cb3227c3dbc52a1f4cb674c8c9638
BLAKE2b-256 91a35fd4d42e952142924ab54d7769679b519f887b776dab6a03ba368376656c

See more details on using hashes here.

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