config

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 20 Imported by: 15

Documentation

Index

Constants

View Source
const (
	IndexAuto     = iota
	IndexDirect   = iota
	IndexReversed = iota
)
View Source
const (
	// ContextGraphite for data tables
	ContextGraphite = "graphite"
	// ContextPrometheus for data tables
	ContextPrometheus = "prometheus"
)

Variables

View Source
var IndexReverse = map[string]uint8{
	"direct":   IndexDirect,
	"auto":     IndexAuto,
	"reversed": IndexReversed,
}

IndexReverse maps setting name to value

View Source
var IndexReverseNames = []string{"auto", "direct", "reversed"}

IndexReverseNames contains valid names for index-reverse setting

Functions

func CreateCache added in v0.13.4

func CreateCache(cacheName string, cacheConfig *CacheConfig) (cache.BytesCache, error)

func GetQueryParam added in v0.13.4

func GetQueryParam(a []QueryParam, duration time.Duration) int

search on sorted slice

func PrintDefaultConfig added in v0.3.2

func PrintDefaultConfig() error

PrintDefaultConfig prints the default config with some additions to be useful

Types

type CacheConfig added in v0.13.4

type CacheConfig struct {
	Type              string        `toml:"type" json:"type" comment:"cache type"`
	Size              int           `toml:"size-mb" json:"size-mb" comment:"cache size"`
	MemcachedServers  []string      `toml:"memcached-servers" json:"memcached-servers" comment:"memcached servers"`
	DefaultTimeoutSec int32         `toml:"default-timeout" json:"default-timeout" comment:"default cache ttl"`
	ShortTimeoutSec   int32         `toml:"short-timeout" json:"short-timeout" comment:"short-time cache ttl"`
	FindTimeoutSec    int32         `toml:"find-timeout" json:"find-timeout" comment:"finder/tags autocompleter cache ttl"`
	ShortDuration     time.Duration `toml:"short-duration" json:"short-duration" comment:"maximum diration, used with short_timeout"`
}

Cache config

type Carbonlink struct {
	Server         string        `toml:"server" json:"server"`
	Threads        int           `toml:"threads-per-request" json:"threads-per-request"`
	Retries        int           `toml:"-" json:"-"`
	ConnectTimeout time.Duration `toml:"connect-timeout" json:"connect-timeout"`
	QueryTimeout   time.Duration `toml:"query-timeout" json:"query-timeout"`
	TotalTimeout   time.Duration `toml:"total-timeout" json:"total-timeout" comment:"timeout for querying and parsing response"`
}

Carbonlink configuration

type ClickHouse

type ClickHouse struct {
	URL                  string            `` /* 134-byte string literal not displayed */
	DataTimeout          time.Duration     `toml:"data-timeout" json:"data-timeout" comment:"default total timeout to fetch data, can be overwritten with query-params"`
	QueryParams          []QueryParam      `toml:"query-params" json:"query-params" comment:"customized query params (url, data timeout) for durations greater or equal"`
	DateFormat           string            `toml:"date-format" json:"date-format" comment:"Date format (default, utc, both)"`
	IndexTable           string            `toml:"index-table" json:"index-table" comment:"see doc/index-table.md"`
	IndexUseDaily        bool              `toml:"index-use-daily" json:"index-use-daily"`
	IndexReverse         string            `toml:"index-reverse" json:"index-reverse" comment:"see doc/config.md"`
	IndexReverses        IndexReverses     `toml:"index-reverses" json:"index-reverses" comment:"see doc/config.md" commented:"true"`
	IndexTimeout         time.Duration     `toml:"index-timeout" json:"index-timeout" comment:"total timeout to fetch series list from index"`
	TaggedTable          string            `toml:"tagged-table" json:"tagged-table" comment:"'tagged' table from carbon-clickhouse, required for seriesByTag"`
	TaggedAutocompleDays int               `` /* 132-byte string literal not displayed */
	TaggedUseDaily       bool              `` /* 135-byte string literal not displayed */
	TaggedCosts          map[string]*Costs `` /* 193-byte string literal not displayed */
	TreeTable            string            `toml:"tree-table" json:"tree-table" comment:"old index table, DEPRECATED, see description in doc/config.md" commented:"true"`
	ReverseTreeTable     string            `toml:"reverse-tree-table" json:"reverse-tree-table" commented:"true"`
	DateTreeTable        string            `toml:"date-tree-table" json:"date-tree-table" commented:"true"`
	DateTreeTableVersion int               `toml:"date-tree-table-version" json:"date-tree-table-version" commented:"true"`
	TreeTimeout          time.Duration     `toml:"tree-timeout" json:"tree-timeout" commented:"true"`
	TagTable             string            `` /* 144-byte string literal not displayed */
	ExtraPrefix          string            `toml:"extra-prefix" json:"extra-prefix" comment:"add extra prefix (directory in graphite) for all metrics, w/o trailing dot"`
	ConnectTimeout       time.Duration     `toml:"connect-timeout" json:"connect-timeout" comment:"TCP connection timeout"`
	// TODO: remove in v0.14
	DataTableLegacy string `toml:"data-table" json:"data-table" comment:"will be removed in 0.14" commented:"true"`
	// TODO: remove in v0.14
	RollupConfLegacy string `toml:"rollup-conf" json:"-" commented:"true"`
	MaxDataPoints    int    `toml:"max-data-points" json:"max-data-points" comment:"max points per metric when internal-aggregation=true"`
	// InternalAggregation controls if ClickHouse itself or graphite-clickhouse aggregates points to proper retention
	InternalAggregation bool `toml:"internal-aggregation" json:"internal-aggregation" comment:"ClickHouse-side aggregation, see doc/aggregation.md"`
}

ClickHouse config

func (*ClickHouse) MarshalJSON added in v0.9.0

func (c *ClickHouse) MarshalJSON() ([]byte, error)

type Common

type Common struct {
	Listen                 string           `toml:"listen" json:"listen" comment:"general listener"`
	PprofListen            string           `toml:"pprof-listen" json:"pprof-listen" comment:"listener to serve /debug/pprof requests. '-pprof' argument overrides it"`
	MaxCPU                 int              `toml:"max-cpu" json:"max-cpu"`
	MaxMetricsInFindAnswer int              ``                  /* 130-byte string literal not displayed */
	MaxMetricsPerTarget    int              ``                  /* 160-byte string literal not displayed */
	TargetBlacklist        []string         ``                  /* 148-byte string literal not displayed */
	Blacklist              []*regexp.Regexp `toml:"-" json:"-"` // compiled TargetBlacklist
	MemoryReturnInterval   time.Duration    `toml:"memory-return-interval" json:"memory-return-interval" comment:"daemon will return the freed memory to the OS when it>0"`
	HeadersToLog           []string         `toml:"headers-to-log" json:"headers-to-log" comment:"additional request headers to log"`
	FindCacheConfig        CacheConfig      `toml:"find-cache" json:"find-cache" comment:"find cache config"`

	FindCache   cache.BytesCache `toml:"-" json:"-"`
	TaggedCache cache.BytesCache `toml:"-" json:"-"`
}

Common config

type Config

type Config struct {
	Common     Common             `toml:"common" json:"common"`
	Metrics    metrics.Config     `toml:"metrics" json:"metrics"`
	ClickHouse ClickHouse         `toml:"clickhouse" json:"clickhouse"`
	DataTable  []DataTable        `toml:"data-table" json:"data-table" comment:"data tables, see doc/config.md for additional info"`
	Tags       Tags               `` /* 134-byte string literal not displayed */
	Carbonlink Carbonlink         `toml:"carbonlink" json:"carbonlink"`
	Prometheus Prometheus         `toml:"prometheus" json:"prometheus"`
	Debug      Debug              `toml:"debug" json:"debug" comment:"see doc/debugging.md"`
	Logging    []zapwriter.Config `toml:"logging" json:"logging"`
}

Config is the daemon configuration

func DefaultConfig added in v0.13.4

func DefaultConfig() (*Config, error)

func New

func New() *Config

New returns *Config with default values

func ReadConfig added in v0.3.2

func ReadConfig(filename string, noLog bool) (*Config, error)

ReadConfig reads the content of the file with given name and process it to the *Config

func Unmarshal added in v0.13.0

func Unmarshal(body []byte, noLog bool) (*Config, error)

Unmarshal process the body to *Config

func (*Config) ProcessDataTables added in v0.13.0

func (c *Config) ProcessDataTables() (err error)

ProcessDataTables checks if legacy `data`-table config is used, compiles regexps for `target-match-any` and `target-match-all` parameters, sets the rollup configuration and proper context.

type Costs added in v0.13.4

type Costs struct {
	Cost       *int           `toml:"cost" json:"cost" comment:"default cost (for wildcarded equalence or matched with regex, or if no value cost set)"`
	ValuesCost map[string]int `` /* 142-byte string literal not displayed */
}

type DataTable added in v0.4.0

type DataTable struct {
	Table                  string                `toml:"table" json:"table" comment:"data table from carbon-clickhouse"`
	Reverse                bool                  `toml:"reverse" json:"reverse" comment:"if it stores direct or reversed metrics"`
	MaxAge                 time.Duration         `toml:"max-age" json:"max-age" comment:"maximum age stored in the table"`
	MinAge                 time.Duration         `toml:"min-age" json:"min-age" comment:"minimum age stored in the table"`
	MaxInterval            time.Duration         `toml:"max-interval" json:"max-interval" comment:"maximum until-from interval allowed for the table"`
	MinInterval            time.Duration         `toml:"min-interval" json:"min-interval" comment:"minimum until-from interval allowed for the table"`
	TargetMatchAny         string                `toml:"target-match-any" json:"target-match-any" comment:"table allowed only if any metrics in target matches regexp"`
	TargetMatchAll         string                `toml:"target-match-all" json:"target-match-all" comment:"table allowed only if all metrics in target matches regexp"`
	TargetMatchAnyRegexp   *regexp.Regexp        `toml:"-" json:"-"`
	TargetMatchAllRegexp   *regexp.Regexp        `toml:"-" json:"-"`
	RollupConf             string                `toml:"rollup-conf" json:"-" comment:"custom rollup.xml file for table, 'auto' and 'none' are allowed as well"`
	RollupAutoTable        string                `` /* 130-byte string literal not displayed */
	RollupAutoInterval     *time.Duration        `toml:"rollup-auto-interval" json:"rollup-auto-interval" comment:"rollup update interval for 'rollup-conf=auto'"`
	RollupDefaultPrecision uint32                `toml:"rollup-default-precision" json:"rollup-default-precision" comment:"is used when none of rules match"`
	RollupDefaultFunction  string                `toml:"rollup-default-function" json:"rollup-default-function" comment:"is used when none of rules match"`
	RollupUseReverted      bool                  `` /* 155-byte string literal not displayed */
	Context                []string              `toml:"context" json:"context" comment:"valid values are 'graphite' of 'prometheus'"`
	ContextMap             map[string]bool       `toml:"-" json:"-"`
	Rollup                 *rollup.Rollup        `toml:"-" json:"rollup-conf"`
	QueryMetrics           *metrics.QueryMetrics `toml:"-" json:"-"`
}

DataTable configs

type Debug added in v0.13.0

type Debug struct {
	Directory     string      `toml:"directory" json:"directory" comment:"the directory for additional debug output"`
	DirectoryPerm os.FileMode `toml:"directory-perm" json:"directory-perm" comment:"permissions for directory, octal value is set as 0o755"`
	// If ExternalDataPerm > 0 and X-Gch-Debug-Ext-Data HTTP header is set, the external data used in the query
	// will be saved in the DebugDir directory
	ExternalDataPerm os.FileMode `toml:"external-data-perm" json:"external-data-perm" comment:"permissions for directory, octal value is set as 0o640"`
}

Debug config

type IndexReverseRule added in v0.13.0

type IndexReverseRule struct {
	Suffix   string         `toml:"suffix,omitempty" json:"suffix" comment:"rule is used when the target suffix is matched"`
	Prefix   string         `toml:"prefix,omitempty" json:"prefix" comment:"rule is used when the target prefix is matched"`
	RegexStr string         `toml:"regex,omitempty" json:"regex" comment:"rule is used when the target regex is matched"`
	Regex    *regexp.Regexp `toml:"-" json:"-"`
	Reverse  string         `toml:"reverse" json:"reverse" comment:"same as index-reverse"`
}

IndexReverseRule contains rules to use direct or reversed request to index table

type IndexReverses added in v0.13.0

type IndexReverses []*IndexReverseRule

IndexReverses is a slise of ptrs to IndexReverseRule

func (IndexReverses) Compile added in v0.13.0

func (ir IndexReverses) Compile() error

Compile checks if IndexReverseRule are valid in the IndexReverses and compiles regexps if set

type Prometheus added in v0.11.0

type Prometheus struct {
	ExternalURLRaw string   `toml:"external-url" json:"external-url" comment:"allows to set URL for redirect manually"`
	ExternalURL    *url.URL `toml:"-" json:"-"`
	PageTitle      string   `toml:"page-title" json:"page-title"`
}

Prometheus configuration

type QueryParam added in v0.13.4

type QueryParam struct {
	Duration    time.Duration `toml:"duration" json:"duration" comment:"minimal duration (beetween from/until) for select query params"`
	URL         string        `toml:"url" json:"url" comment:"url for queries with durations greater or equal than"`
	DataTimeout time.Duration `toml:"data-timeout" json:"data-timeout" comment:"total timeout to fetch data"`
}

type Tags added in v0.3.0

type Tags struct {
	Rules      string `toml:"rules" json:"rules"`
	Date       string `toml:"date" json:"date"`
	ExtraWhere string `toml:"extra-where" json:"extra-where"`
	InputFile  string `toml:"input-file" json:"input-file"`
	OutputFile string `toml:"output-file" json:"output-file"`
}

Tags config

Jump to

Keyboard shortcuts

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