Gnocchi Time Series Database

repository·master·Indexed 43 days ago

https://github.com/gnocchixyz/gnocchi

An open-source time series database designed for large-scale, multi-tenant cloud environments. Gnocchi focuses on high-performance data retrieval by performing aggregations at ingestion time. It features a REST API, native multi-tenancy, and supports integrations with Grafana, collectd, and a subset of the InfluxDB REST API. It provides a Python client, a Go SDK via Gophercloud, and a dedicated AMQP 1.0 daemon (gnocchi-amqp1d) for metric processing.

Tokens
11.6K
Snippets
37
Records
70
Agent score
56%

What's inside Gnocchi

  1. Overview of Gnocchi - Metric as a Service

    master

    Gnocchi is an open-source time series database designed for the storage and indexing of time series data and resources at a large scale. It is specifically architected for modern, dynamic, and potentially multi-tenant cloud platforms.

    Key characteristics include:

    • Scalability and Fault-Tolerance: Designed to handle large amounts of aggregates while remaining performant.
    • Storage Agnostic: Built to avoid hard dependencies on complex storage systems.
    • Pre-computed Aggregations: Unlike many time series databases that compute aggregations (like average or minimum) at query time, Gnocchi aggregates data points at ingestion. This makes data retrieval extremely fast because the system simply reads back pre-computed results.
  2. Compare Gnocchi with other time series databases

    master

    Gnocchi is a 'Metric as a Service' that focuses on high availability, horizontal scalability, and multi-tenancy. Use the following comparisons to determine if Gnocchi fits your requirements compared to other popular open-source solutions:

    • Prometheus: Unlike Prometheus, Gnocchi does not handle metric polling or alerting; it expects to leverage existing collectors (like collectd). However, Gnocchi provides built-in multi-tenancy and horizontal scalability.
    • InfluxDB: While InfluxDB uses a label-based data model and its own query language (InfluxQL), Gnocchi uses a model based on resources attached to metrics. Gnocchi provides scalability and multi-tenancy out of the box, whereas InfluxDB requires a commercial version for horizontal scalability.
    • OpenTSDB: OpenTSDB relies on a heavy Hadoop/HBase stack for scaling but has simple querying capabilities. Gnocchi offers a more feature-rich query language and avoids the operational complexity of Hadoop.
    • Graphite: Graphite focuses on rendering time series stored in flat files (Whisper). Gnocchi offers superior scalability, a more efficient file format, and a data model that is not strictly tied to the current date and time.
  3. Compare Gnocchi with other metric storage systems

    master

    Gnocchi is a 'Metric as a Service' designed with a focus on resource history and multi-tenancy. Use the following comparison to determine if Gnocchi meets your requirements compared to Prometheus, InfluxDB, OpenTSDB, or Graphite:

    • Resource History: Gnocchi is the only system in this list that natively supports resource history.
    • Multi-tenancy: Gnocchi provides native multi-tenant support, whereas the others do not.
    • Query Interface: Gnocchi uses a REST API.
    • High Availability & Scalability: Gnocchi is designed to be both highly available and scalable.
    • Alerting: Gnocchi does not currently have native alerting (it is on the roadmap).
    • Integrations: Gnocchi supports Grafana and collectd just like the other major metric stores.
    | Features         | Gnocchi                                                              | Prometheus | InfluxDB         | OpenTSDB | Graphite  |
    |==================+===================================================================+============+==================+==========+===========|
    | Metric polling   | No                                                                | Yes        | No               | No       | No        |
    | Resource history | Yes                                                               | No         | No               | No       | No        |
    | Multi-tenant     | Yes                                                               | No         | No               | No       | No        |
    | Query interface  | REST API                                                           | REST API   | HTTP             | TCP      | None      |
    | High-available   | Yes                                                               | No         | With *Relay*     | Yes      | No        |
    | Scalable         | Yes                                                               | No         | Commercial only  | Yes      | No        |
    | Alerting         | No                                                                | Yes        | With *Kapacitor* | No       | No        |
    | Grafana support  | Yes                                                               | Yes        | Yes              | Yes      | Yes       |
    | collectd support  | Yes                                                               | Yes        | Yes              | Yes      | Yes       |
  4. How gnocchi-nagios works with Nagios and Icinga

    master

    The gnocchi-nagios service acts as a bridge between monitoring tools and Gnocchi. It performs the following workflow:

    1. Collects: It gathers perfdata files generated by Nagios or Icinga.
    2. Transforms: It converts the performance data into Gnocchi-compatible formats, specifically mapping them to Gnocchi |resources|, |metrics|, and |measures|.
    3. Publishes: It sends the transformed data to the Gnocchi REST API.

    For more detailed information, refer to the official Documentation or the Source Code.

  5. How the AMQP 1.0 daemon processes metrics

    master

    The gnocchi-amqp1d daemon acts as an intermediary for metrics sent over the network via the amqp1 collectd plugin (compatible with brokers like Apache Artemis or Apache Qpid Dispatch Router).

    Workflow:

    1. Metrics are published to a specific host, port, and topic via the amqp1 plugin.
    2. The gnocchi-amqp1d daemon receives these metrics.
    3. Metrics are created dynamically upon receipt.
    4. Each metric is attached to the configured Resource Name.
    5. The source hostname is automatically attached to the resource as an attribute.
  6. Scaling considerations for gnocchi-statsd

    master

    While gnocchi-statsd can be scaled, the nature of the Statsd protocol introduces specific constraints depending on the metric type used:

    • Counters (counter) and Sampling (c): You must always send these metrics to the same daemon instance. If sent to different instances, the counts will not be correctly aggregated. If you need to scale, avoid using these types or ensure sticky routing to a single daemon.
    • Timings (timing) and Gauges (gauges): These types do not suffer from the same scaling limitation, but be aware that sending the same metric to different gnocchi-statsd servers may result in more measures than expected because the cache and flush delays are not synchronized across instances.
  7. Understand Gnocchi core concepts: Resource, Metric, and Measure

    master

    To use Gnocchi effectively, you must understand the relationship between its three primary data entities:

    1. Resource: The base entity representing an infrastructure component (e.g., a virtual machine or a network interface). It is identified by a unique ID and can hold metadata via attributes. You associate metrics with resources using a name.
    2. Metric: An entity identified by a UUID that stores aggregated data. It is attached to a Resource and its storage behavior is governed by an Archive policy.
    3. Measure: The raw data input. A measure is a tuple consisting of a timestamp and a value sent to the Gnocchi API.

    In short: You send Measures to a Metric, which is attached to a Resource.

  8. Understand and define Archive Policies

    master

    Archive policies define how metrics are aggregated and how long they are stored.

    Key Concepts:

    • Definition: Expressed as a number of points over a timespan (e.g., 10 points with 1s granularity = 10s retention).
    • Expiration: Data is expired based on the timespan, not a relative timestamp.
    • Aggregation Methods: Each policy uses specific methods (default: mean, min, max, sum, std, count).
    • Performance: More definitions in a single policy increase CPU consumption.

    Example Calculation: To keep 24 hours of data with 1-minute granularity: 1440 points with a granularity of 1 minute.

  9. Configure Gnocchi authentication modes

    master

    The Gnocchi API server supports three authentication methods:

    1. basic (Default): Uses the standard HTTP Authorization header. By default, only the admin user has special permissions. The authentication password is not used.
    2. keystone: Uses OpenStack Keystone. To enable this, set api.auth_mode = keystone and configure the keystone_authtoken section in gnocchi.conf with the appropriate values.
    3. remoteuser: Gnocchi retrieves the username from the HTTP server's REMOTE_USER environment variable. Permissions follow the basic mode model.
  10. Gnocchi Architecture Overview

    master

    Gnocchi is a stateless, horizontally scalable 'Metric as a Service' system composed of several services:

    • HTTP REST API: The primary entry point for receiving data.
    • statsd-compatible daemon: An optional daemon for receiving metrics via the statsd protocol.
    • gnocchi-metricd: An asynchronous processing daemon that performs background operations such as statistics computing and metric cleanup.

    Because the services are stateless, you can scale horizontally by spawning more gnocchi-api endpoints or gnocchi-metricd daemons to handle increased load or to ensure high availability across independent servers.

  11. How Gnocchi maps Prometheus metrics to its data model

    master

    Gnocchi translates Prometheus metrics into its internal resource model using the following logic:

    1. Resource Creation: For every metric sent by Prometheus, Gnocchi creates (or identifies) a resource based on the unique combination of the job and instance labels.
    2. Resource Type: These resources are assigned the prometheus resource type.
    3. Attributes: Each resource contains two specific attributes: job and instance.
    4. Measures: The actual metric values sent by Prometheus are stored as measures attached to that specific job/instance resource.

    The /v1/prometheus/write endpoint processes these incoming metrics using the WriteRequest protobuf message.

  12. Configure Gnocchi storage and indexer drivers

    master

    Gnocchi is entirely pluggable and relies on drivers for three external components. You must configure drivers for each of these roles:

    1. Incoming and Storage Drivers

    These drivers handle the storage of incoming measures and aggregated metrics. Supported drivers include:

    • File (default): Suitable for small deployments. For scaling with the file driver, data can be shared via NFS.
    • Ceph (preferred): Recommended for scalability and consistency.
    • OpenStack Swift
    • Amazon S3
    • Redis

    Deployment Recommendation: For medium to large scale deployments, use Redis for incoming measure storage and Ceph for aggregate storage.

    2. Indexer Driver

    The indexer stores the index of all resources, archive policies, and metrics, including their definitions, types, and properties. It also manages the relationships between resources and metrics. Supported drivers include:

    • PostgreSQL (preferred)
    • MySQL (minimum version 5.6.4)