database

package
v0.0.0-...-0df215e Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package database implements all persistent data access for bosun. Internally it runs ledisdb locally, but uses a redis client to access all data. Thus it should be able to migrate to a remote redis instance with minimal effort.

Index

Constants

View Source
const Search_All = "__all__"

Variables

This section is empty.

Functions

func StartLedis

func StartLedis(dataDir string, bind string) (stop func(), err error)

Start in-process ledis server. Data will go in the specified directory and it will bind to the given port. Return value is a function you can call to stop the server.

Types

type Connector

type Connector interface {
	GetConnection() redis.Conn
}

interface so things can get a raw connection (mostly tests), but still discourage it.

type DataAccess

type DataAccess interface {
	Metadata() MetadataDataAccess
	Search() SearchDataAccess
	Errors() ErrorDataAccess
	Silence() SilenceDataAccess
	Incidents() IncidentDataAccess
}

Core data access interface for everything sched needs

func NewDataAccess

func NewDataAccess(addr string, isRedis bool) DataAccess

Create a new data access object pointed at the specified address. isRedis parameter used to distinguish true redis from ledis in-proc.

type ErrorDataAccess

type ErrorDataAccess interface {
	MarkAlertSuccess(name string) error
	MarkAlertFailure(name string, msg string) error
	GetFailingAlertCounts() (int, int, error)

	GetFailingAlerts() (map[string]bool, error)
	IsAlertFailing(name string) (bool, error)

	GetFullErrorHistory() (map[string][]*models.AlertError, error)
	ClearAlert(name string) error
	ClearAll() error
}

type IncidentDataAccess

type IncidentDataAccess interface {
	GetIncident(id uint64) (*models.Incident, error)
	CreateIncident(ak models.AlertKey, start time.Time) (*models.Incident, error)
	UpdateIncident(id uint64, i *models.Incident) error

	GetIncidentsStartingInRange(start, end time.Time) ([]*models.Incident, error)

	// should only be used by initial import
	SetMaxId(id uint64) error
}

type LastInfo

type LastInfo struct {
	LastVal      float64
	DiffFromPrev float64
	Timestamp    int64
}

type MetadataDataAccess

type MetadataDataAccess interface {
	// Insert Metric Metadata. Field must be one of "desc", "rate", or "unit".
	PutMetricMetadata(metric string, field string, value string) error
	// Get Metric Metadata for given metric.
	GetMetricMetadata(metric string) (*MetricMetadata, error)

	PutTagMetadata(tags opentsdb.TagSet, name string, value string, updated time.Time) error
	GetTagMetadata(tags opentsdb.TagSet, name string) ([]*TagMetadata, error)
	DeleteTagMetadata(tags opentsdb.TagSet, name string) error
}

type MetricMetadata

type MetricMetadata struct {
	Desc        string `redis:"desc" json:",omitempty"`
	Unit        string `redis:"unit" json:",omitempty"`
	Rate        string `redis:"rate" json:",omitempty"`
	LastTouched int64  `redis:"lastTouched"`
}

type SearchDataAccess

type SearchDataAccess interface {
	AddMetricForTag(tagK, tagV, metric string, time int64) error
	GetMetricsForTag(tagK, tagV string) (map[string]int64, error)

	AddTagKeyForMetric(metric, tagK string, time int64) error
	GetTagKeysForMetric(metric string) (map[string]int64, error)

	AddMetric(metric string, time int64) error
	GetAllMetrics() (map[string]int64, error)

	AddTagValue(metric, tagK, tagV string, time int64) error
	GetTagValues(metric, tagK string) (map[string]int64, error)

	AddMetricTagSet(metric, tagSet string, time int64) error
	GetMetricTagSets(metric string, tags opentsdb.TagSet) (map[string]int64, error)

	BackupLastInfos(map[string]map[string]*LastInfo) error
	LoadLastInfos() (map[string]map[string]*LastInfo, error)
}

type SilenceDataAccess

type SilenceDataAccess interface {
	GetActiveSilences() ([]*models.Silence, error)
	AddSilence(*models.Silence) error
	DeleteSilence(id string) error

	ListSilences(endingAfter int64) (map[string]*models.Silence, error)
}

type TagMetadata

type TagMetadata struct {
	Tags        opentsdb.TagSet
	Name        string
	Value       string
	LastTouched int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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