cyqldog

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

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

Checker is a worker that executes SQLs and sends metrics.

type Config

type Config struct {
	// DB is a configuration of the database to connect.
	DB DataSourceConfig `yaml:"data_source"`
	// Notifiers are configurations of output plugins.
	Notifiers NotifiersConfig `yaml:"notifiers"`
	// Rules are a list of rules to monitor
	Rules []Rule `yaml:"rules"`
}

Config represents the structure of the configuration file.

type DB added in v0.0.2

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

DB is an implementation of DataSource.

func (*DB) Close added in v0.0.2

func (d *DB) Close() error

Close closes the database connection.

func (*DB) Get added in v0.0.2

func (d *DB) Get(rule Rule) (QueryResult, error)

Get queries the database to generate metrics.

type DataSource

type DataSource interface {
	Get(rule Rule) (QueryResult, error)
	Close() error
}

DataSource is an interface which get metrics from.

type DataSourceConfig added in v0.0.2

type DataSourceConfig struct {
	// Driver is type of the database to connect.
	// Currently suppoted databases are as follows:
	//  - postgres
	//  - mysql
	Driver string `yaml:"driver"`
	// Options is a map of options to connect.
	// These options are passed to sql.Open.
	// The supported options are depend on the database driver.
	Options DataSourceOptions `yaml:"options"`
}

DataSourceConfig is a configuration of the database to connect.

type DataSourceOptions

type DataSourceOptions map[string]string

DataSourceOptions is a map of options to connect.

type Dogstatsd

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

Dogstatsd is a configuration of the dogstatsd to connect.

func (*Dogstatsd) Event added in v0.1.0

func (d *Dogstatsd) Event(e *Event) error

Event send an event to the dogstatsd.

func (*Dogstatsd) Put added in v0.0.2

func (d *Dogstatsd) Put(qr QueryResult, rule Rule) error

Put sends metrics to the dogstatsd.

type DogstatsdConfig added in v0.0.2

type DogstatsdConfig struct {
	// Host is a hostname or IP address of the dogstatsd.
	Host string `yaml:"host"`
	// Port is a port number of the dogstatsd.
	Port string `yaml:"port"`
	// Namespace to prepend to all statsd calls
	Namespace string `yaml:"namespace"`
	// Tags are global tags to be added to every statsd call
	Tags []string `yaml:"tags"`
}

DogstatsdConfig is a configuration of the dogstatsd to connect.

type Event added in v0.1.0

type Event struct {
	// Title of the event. Required.
	Title string
	// Text is the description of the event. Required.
	Text string
	// Level is a level of the event.
	// This can be info, error, warning or success. (default: info)
	Level string
	// Tags for the event.
	Tags []string
}

An Event is an object that can be posted to the Notifier.

type Monitor

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

Monitor represents a main process of monitoring.

func NewMonitor

func NewMonitor(configPath string) *Monitor

NewMonitor returns an instance of Monitor.

func (*Monitor) Run

func (m *Monitor) Run() error

Run is a main routine of cyqldog.

type Notifier added in v0.0.2

type Notifier interface {
	Put(qr QueryResult, rule Rule) error
	Event(e *Event) error
}

Notifier is an interface which send metrics to.

type Notifiers added in v0.0.2

type Notifiers map[string]Notifier

Notifiers is a map of notifiers.

type NotifiersConfig added in v0.0.2

type NotifiersConfig struct {
	// Dogstatsd is a configuration of the dogstatsd to connect.
	Dogstatsd DogstatsdConfig `yaml:"dogstatsd"`
}

NotifiersConfig are configurations of notifiers.

type QueryResult added in v0.0.2

type QueryResult struct {
	Records []Record
}

QueryResult has multiple records.

type Record added in v0.0.2

type Record map[string]string

Record is a map of column / value pairs representing one row.

type Rule

type Rule struct {
	// Name of the rule.
	// The metic name sent to the dogstatsd is:
	//   Dogstatsd.Namespace + Rule.Name + Rule.ValueCols[*]
	Name string `yaml:"name"`
	// Interval of the monitoring.
	Interval time.Duration `yaml:"interval"`
	// Query to the database.
	Query string `yaml:"query"`
	// Notifier is a name of notifier to send metrics.
	Notifier string `yaml:"notifier"`
	// ValueCols is a list of names of the columns used as metric values.
	ValueCols []string `yaml:"value_cols"`
	// TagCols is a list of names of the columns used as metric tags.
	TagCols []string `yaml:"tag_cols"`
}

Rule represents monitoring conditions.

type Scheduler

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

Scheduler represents the schedule corresponding to the rule.

Jump to

Keyboard shortcuts

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