metricdb

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package metricdb handles the metrics storage.

The DB contains multiple leveldb instances, a new leveldb instance would be created and also an old instance would be expired every day.

File Structure

Example file structure for period=1day, expiration=7days:

storage/       (period=1day, expiration=7days)
  |- admindb
  |- indexdb/
  |- metricdb/
        |- 16912 -- Outdated
        |- 16913 -- -7
        |- 16914 -- -6
        |- 16915 -- -5
        |- 16916 -- -4
        |- 16917 -- -3
        |- 16918 -- -2
        |- 16919 -- -1
        |- 16920 -- Active

Entry Format

Key-Value design in leveldb:

|------- Key (8) ------|-------------- Value (24) -----------|
+----------+-----------+-----------+-----------+-------------+
| Link (4) | Stamp (4) | Value (8) | Score (8) | Average (8) |
+----------+-----------+-----------+-----------+-------------+

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when requested data not found.
	ErrNotFound = errors.New("metricdb: not found")
	// ErrCorrupted is returned when corrupted data found.
	ErrCorrupted = errors.New("metricdb: corrupted data found")
	// ErrNoLink is returned when the metric to put has no link.
	ErrNoLink = errors.New("metricdb: no link")
	// ErrNoStorage is returned when no storage is able to serve, which
	// indicates that given stamp or stamp range may be invalid.
	ErrNoStorage = errors.New("metricdb: no storage")
)

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is the top level metric storage handler.

func Open

func Open(fileName string, opts *Options) (*DB, error)

Open a DB by filename.

func (*DB) Close

func (db *DB) Close() (err error)

Close the DB.

func (*DB) Get

func (db *DB) Get(name string, link, start, end uint32) ([]*models.Metric, error)

Get metrics in a timestamp range, the range is left open and right closed.

func (*DB) Put

func (db *DB) Put(m *models.Metric) (err error)

Put a metric into db. Returns ErrNoStorage if no storage is available.

type Options added in v0.1.4

type Options struct {
	Period     uint32
	Expiration uint32
}

Options is to open DB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL