BanyanDB

repository·main·Indexed 43 days ago

https://github.com/apache/skywalking-banyandb

An observability-focused database optimized for storing and analyzing Metrics, Tracing, and Logging data, specifically designed for Apache SkyWalking users. Includes tools such as the banyand-migration CLI for data rewriting and verification, the bydbctl command line tool for schema and query management via the BYDBQL Agent TUI, and Canopy for web-based interaction.

Tokens
257.4K
Snippets
608
Records
1.1K
Agent score
53%

What's inside BanyanDB

  1. Overview of First Occurrence Data Collection (FODC)

    main

    First Occurrence Data Collection (FODC) is an observability and diagnostics subsystem for BanyanDB. It is designed to ensure stable DB node operation and provide structured data for capacity planning, performance analysis, and troubleshooting.

    FODC provides four main categories of data:

    1. Metric collection and short-term caching (small time window).
    2. Node topology and status, including runtime parameters and role states.
    3. Node configuration collection.
    4. On-demand performance profiling and memory snapshots.
  2. Overview of BanyanDB Observability

    main

    BanyanDB provides observability through three primary channels to monitor performance, behavior, and system health:

    • Logging: Configurable log levels, per-module granularity, and slow-query logging.
    • Metrics: A comprehensive catalog including statistics, resource usage, storage, trace plugins, inverted index, and internal queue metrics, queryable via PromQL.
    • Profiling: Access to pprof endpoints for deep performance analysis.
    • Query Tracing: Per-query execution traces to identify bottlenecks.

    For monitoring, BanyanDB follows two canonical methodologies:

    1. RED (Rate, Errors, Duration) for request paths (write and query paths).
    2. USE (Utilization, Saturation, Errors) for system resources.
  3. Introduction to BanyanDB Query Language (BydbQL)

    main

    BydbQL is a unified, SQL-like query language designed to interact with all BanyanDB data models. It abstracts underlying protobuf-based APIs, providing a consistent interface for querying different types of data.

    BydbQL supports the following primary data models:

    • Streams: Raw, time-series elements (e.g., logs, traces).
    • Measures: Aggregated numerical time-series data (metrics).
    • Properties: Metadata and key-value information.
    • Traces: Distributed tracing data containing spans.
    • Top-N: A specialized syntax for optimized Top-N queries against measures.
  4. Overview of BanyanDB

    main
    BanyanDB is an observability database designed to ingest, analyze, and store Metrics, Tracing, and Logging data. It is specifically optimized for the data patterns generated by observability platforms and APM systems, such as Apache SkyWalking. Unlike general-purpose databases, BanyanDB is engineered to balance read costs, update costs, and memory overhead by combining multiple access methods to better suit the APM data model.
  5. Understand the BanyanDB Native Inverted Index Research Plan

    main
    The BanyanDB Native Inverted Index research plan outlines a spec-first approach to replacing the existing Bluge-based indexing with a native implementation. The goal is to reduce dependencies on Bluge and ICE while maintaining strict file compatibility and performance. The plan is divided into research work packages (R0–R6) and a five-stage production rollout (NIDX-01 to NIDX-05).
  6. Understand the BanyanDB Native Inverted Index Research Plan

    main

    BanyanDB is researching a transition from using external libraries (Bluge and ICE) to a custom, lightweight, native inverted index implementation. This native engine is intended to power several core BanyanDB components:

    • Segment-level series index: Shared by time-series engines.
    • Stream element index.
    • Property storage and search.
    • index-mode Measure storage and search.
    • Maintenance workflows: Migration, repair, dump, snapshot, and external-segment workflows.

    The goal is to create a minimal, maintainable engine that preserves existing BanyanDB behaviors and ensures on-disk interoperability with existing data formats.

  7. BanyanDB Protocol Documentation Overview

    main

    The BanyanDB protocol is defined using Protocol Buffers (protobuf) and is organized into several functional domains. This documentation provides a reference for the various service definitions, request/response structures, and data models used to interact with BanyanDB.

    Key functional areas include:

    • Trace: Handling trace and span data.
    • Measure: Managing metric/measure data points and aggregations.
    • Stream: Handling stream-based data elements.
    • Property: Managing system properties and cluster state via gossip and repair services.
    • Schema: Managing entity, measure, stream, and trace schemas.
    • Database: Managing cluster state, nodes, and shards.
    • ByDBQL: Executing queries via the BydbQL language.
    • FODC: Providing diagnostics, lifecycle info, and pressure profiles for cluster health.
  8. Summary of FODC capabilities

    main

    First Occurrence Data Collection (FODC) is a foundational component for BanyanDB deployments, providing:

    • Unified, structured observability: Collects metrics, topology, and configuration for BanyanDB clusters.
    • Prometheus integration: Provides Prometheus-friendly interfaces for ecosystem integration.
    • On-demand deep diagnostics: Orchestrates profiling and memory snapshots centrally while executing them locally.
    • Lightweight architecture: Uses a Proxy + Agent model designed to respect resource constraints.
  9. What is the BanyanDB migration tool and when to use it

    main

    The BanyanDB migration tool is an operator-facing utility used to re-normalize measure (normal and index-mode, e.g., sw_metadata) and stream data. It is used when the on-disk state has drifted from what the BanyanDB runtime expects.

    Common use cases include:

    • Fixing historical segments that current BanyanDB versions cannot read cleanly.
    • Repairing botched lifecycle events (failed merges, compactions, or shard topology changes) that caused duplicated boundary rows or misaligned segments.
    • Correcting partial restores where data landed outside the active stage's SegmentInterval grid.
    • General maintenance to re-bucket source rows onto a fresh, grid-aligned target tree without losing data.

    Scope and Limitations:

    • The tool migrates measure and stream data.
    • Catalog detection is automatic via the schema-property catalog.
    • Trace and property catalogs are out of scope.
    • While index-mode measure groups are migratable, sw_metadata is considered internal cluster-startup metadata and should generally be left in place unless there is a specific reason to migrate it.
  10. What is a Block in BanyanDB TSDB?

    main

    A Block is the minimal unit of storage in the TSDB. It contains several rows of data and is spread across multiple columnar files. Blocks are globally ordered by (seriesID, minTimestamp).

    Block Constraints and Behavior:

    • Grouping: In Measure, all rows in a block share the same seriesID. In Trace, the grouping key is the trace id.
    • Sizing:
      • Measure: Bounded by 2 MiB uncompressed data OR 8192 rows.
      • Stream: Bounded by data volume only.
      • Trace: Bounded by 2 MiB opaque span volume.
    • Deduplication: In Measure, timestamps.bin stores a version next to each timestamp. If multiple rows share a timestamp, only the one with the highest version is returned.
    • Indexing: meta.bin contains primaryBlockMetadata records (40 bytes) that provide offsets and sizes for the block's data in primary.bin and the columnar files.
  11. Overview of Trace-Pipeline Sampler Plugins

    main

    BanyanDB allows the trace pipeline to retain or drop traces during in-merge or segment finalization using native Go plugins called "samplers".

    Key Concepts

    • Loading Mechanism: Plugins are loaded on demand during group-schema reconciliation. They are hosted only on data nodes (the standalone service also acts as a data node; liaison nodes never host plugins).
    • Feature Gating: The feature is disabled by default and requires two specific flags:
      • -trace-pipeline-native-plugin-enabled (bool): Enables the plugin feature.
      • -trace-pipeline-trusted-plugin-dir (string): Defines the single directory where .so files are resolved.
    • Failure Behavior: Plugin loading is fail-open and loud. If a plugin fails to load, the system emits an ERROR log, increments the sampler_load_failed{group,name,reason} metric, and the group continues using its previous sampler set (or retains all traces). It will not cause a node crash.
    • Lifecycle: Go plugins cannot be unloaded once opened; they remain mapped for the lifetime of the process.