model

package
v0.0.0-...-c1b23f5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputTypePrometheus1RemoteWrite = "prometheusv1_remote_write"
	InputTypePrometheus2RemoteWrite = "prometheusv2_remote_write"
	InputTypeNatsStreaming          = "nats_streaming"
	InputTypeInfluxDB               = "influxdb"
)

Valid types for input.

View Source
const (
	OutputTypePrometheus2RemoteWrite = "prometheusv2_remote_write"
	OutputTypeInfluxDB               = "influxdb"
	OutputTypeNatsStreaming          = "nats_streaming"
	OutputTypeOpenTSDB               = "opentsdb"
)

Valid types for output.

View Source
const (
	MatchEq = iota
	MatchNotEq
	MatchReg
	MatchNotReg
)

These are the LabelOp operators.

View Source
const (
	APITypePrometheusHTTP = "prometheus_http"
)

Valid types for API.

Variables

View Source
var (
	MatchOpString = [4]string{"=", "!=", "=~", "!~"}
	RxLabel       = regexp.MustCompile(`^[a-zA-Z_:][a-zA-Z0-9_:]{0,254}`)

	// MetricNameLabel is the label name indicating the metric name of a
	// timeseries.
	MetricNameLabel = "__name__"
)

Functions

func FilterExclude

func FilterExclude(metric Metric, exprs []LabelExpr) bool

func FilterInclude

func FilterInclude(metric Metric, exprs []LabelExpr) bool

func FilterMatch

func FilterMatch(metric Metric, includes, excludes []LabelExpr) bool

func IsValidMetricName

func IsValidMetricName(n string) bool

IsValidMetricName checks if the given string is a valid metric name or not.

func PrintExampleConfig

func PrintExampleConfig()

func SortSamples

func SortSamples(samples []Sample)

SortSamples sorts a slice of samples in the canonical way -- in the increasing order of timestamp.

Types

type APIConfig

type APIConfig struct {
	Type             string            `toml:"type"`
	Listen           string            `toml:"listen"`
	FederationLabels map[string]string `toml:"federation_labels"`
}

type Config

type Config struct {
	General GeneralConfig  `toml:"general"`
	Input   []InputConfig  `toml:"input"`
	Output  []OutputConfig `toml:"output"`
	API     []APIConfig    `toml:"api"`
}

func (*Config) Load

func (c *Config) Load(file string) error

type Filter

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

func (*Filter) Compile

func (f *Filter) Compile(includes, excludes []string) error

func (*Filter) Match

func (f *Filter) Match(metric Metric) bool

type GeneralConfig

type GeneralConfig struct {
	DataPath         string `toml:"data_path"`
	DownsampleSec    uint   `toml:"downsample_seconds"`
	TTLSec           uint   `toml:"ttl_seconds"`
	RetentionDays    uint   `toml:"retention_days"`
	RetentionGCHours uint   `toml:"retention_gc_hours"`
}

type InputConfig

type InputConfig struct {
	Type            string   `toml:"type"`
	Listen          string   `toml:"listen"`
	FilterInclude   []string `toml:"filter_include"`
	FilterExclude   []string `toml:"filter_exclude"`
	NATSURL         string   `toml:"nats_url"`
	STANCluster     string   `toml:"stan_cluster"`
	STANClientID    string   `toml:"stan_clientid"`
	STANDurableName string   `toml:"stan_durablename"`
	Subject         string   `toml:"subject"`
}

type Label

type Label struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Label represents a key-value pair that qualifies a time series.

func (Label) String

func (l Label) String() string

type LabelExpr

type LabelExpr struct {
	Terms []LabelOp
	Res   []*regexp.Regexp
}

LabelExpr is an expression consisting of zero or more LabelOp terms. The expression is an implicit AND condition.

func (*LabelExpr) CompileFromLabels

func (le *LabelExpr) CompileFromLabels(labels []Label) error

CompileFromLabels is similar to CompileFromTerms, expect that each label is treated as a LabelOp with the = operator.

func (*LabelExpr) CompileFromString

func (le *LabelExpr) CompileFromString(input string) error

func (*LabelExpr) CompileFromTerms

func (le *LabelExpr) CompileFromTerms(terms []LabelOp) error

CompileFromTerms compiles a LabelExpr from a set of LabelOp entries.

func (*LabelExpr) Match

func (le *LabelExpr) Match(metric Metric) bool

func (LabelExpr) String

func (le LabelExpr) String() string

type LabelOp

type LabelOp struct {
	Name  string
	Op    int
	Value string
}

LabelOp represents a label name, an operator (one of =, !=, =~, !~) and a value. A LabelOp forms part of an expression to select time series.

func (LabelOp) String

func (lop LabelOp) String() string

type Metric

type Metric []Label

Metric is a qualified time series name, like 'up{job="node", instance="server1:9000"}'.

func (Metric) Copy

func (m Metric) Copy() Metric

func (*Metric) Decode

func (m *Metric) Decode(b []byte) error

func (Metric) Encode

func (m Metric) Encode() ([]byte, error)

func (Metric) IsValid

func (m Metric) IsValid() bool

func (Metric) Name

func (m Metric) Name() string

func (Metric) Sort

func (m Metric) Sort()

func (Metric) String

func (m Metric) String() string

type OutputConfig

type OutputConfig struct {
	Type            string   `toml:"type"`
	Address         string   `toml:"address"`
	Username        string   `toml:"username"`
	Password        string   `toml:"password"`
	TimeoutSec      uint     `toml:"timeout_seconds"`
	NoCertCheck     bool     `toml:"no_cert_check"`
	Database        string   `toml:"database"`
	RetentionPolicy string   `toml:"retention_policy"`
	Protocol        string   `toml:"protocol"`
	FilterInclude   []string `toml:"filter_include"`
	FilterExclude   []string `toml:"filter_exclude"`
	NATSURL         string   `toml:"nats_url"`
	STANCluster     string   `toml:"stan_cluster"`
	STANClientID    string   `toml:"stan_clientid"`
	Subject         string   `toml:"subject"`
	URL             string   `toml:"url"`
}

type Sample

type Sample struct {
	Timestamp uint64
	Value     float64
}

Sample is a single datapoint of a time series.

Jump to

Keyboard shortcuts

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