config

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 27 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"`
	DefaultTimeoutStr   string        `toml:"-"                 json:"-"`
	ShortTimeoutSec     int32         `toml:"short-timeout"     json:"short-timeout"     comment:"short-time cache ttl"`
	ShortTimeoutStr     string        `toml:"-"                 json:"-"`
	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"`
	ShortUntilOffsetSec int64         `toml:"short-offset"      json:"short-offset"      comment:"offset beetween now and until for select short cache 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        `` /* 176-byte string literal not displayed */
	DataTimeout time.Duration `` /* 147-byte string literal not displayed */
	QueryParams []QueryParam  `` /* 158-byte string literal not displayed */

	RenderMaxQueries        int `toml:"render-max-queries" json:"render-max-queries" comment:"Max queries to render queiries"`
	RenderConcurrentQueries int `toml:"render-concurrent-queries" json:"render-concurrent-queries" comment:"Concurrent queries to render queiries"`
	RenderAdaptiveQueries   int `` /* 160-byte string literal not displayed */

	FindMaxQueries        int                   `toml:"find-max-queries" json:"find-max-queries" comment:"Max queries for find queries"`
	FindConcurrentQueries int                   `toml:"find-concurrent-queries" json:"find-concurrent-queries" comment:"Find concurrent queries for find queries"`
	FindAdaptiveQueries   int                   `` /* 154-byte string literal not displayed */
	FindLimiter           limiter.ServerLimiter `toml:"-"                        json:"-"`

	TagsMaxQueries        int                   `toml:"tags-max-queries" json:"tags-max-queries" comment:"Max queries for tags queries"`
	TagsConcurrentQueries int                   `toml:"tags-concurrent-queries" json:"tags-concurrent-queries" comment:"Concurrent queries for tags queries"`
	TagsAdaptiveQueries   int                   `` /* 154-byte string literal not displayed */
	TagsLimiter           limiter.ServerLimiter `toml:"-"                        json:"-"`

	TagsMinInQuery        int `toml:"tags-min-in-query" json:"tags-min-in-query" comment:"Minimum tags in seriesByTag query"`
	TagsMinInAutocomplete int `toml:"tags-min-in-autocomplete" json:"tags-min-in-autocomplete" comment:"Minimum tags in autocomplete query"`

	UserLimits           map[string]UserLimits `` /* 217-byte string literal not displayed */
	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         `` /* 217-byte string literal not displayed */
	IndexTimeout         time.Duration         `toml:"index-timeout"            json:"index-timeout"            comment:"total timeout to fetch series list from index"`
	TaggedTable          string                `` /* 137-byte string literal not displayed */
	TaggedAutocompleDays int                   `` /* 132-byte string literal not displayed */
	TaggedUseDaily       bool                  `` /* 151-byte string literal not displayed */
	TaggedCosts          map[string]*Costs     `` /* 217-byte string literal not displayed */
	TreeTable            string                `` /* 217-byte string literal not displayed */
	ReverseTreeTable     string                `` /* 217-byte string literal not displayed */
	DateTreeTable        string                `` /* 217-byte string literal not displayed */
	DateTreeTableVersion int                   `` /* 217-byte string literal not displayed */
	TreeTimeout          time.Duration         `` /* 217-byte string literal not displayed */
	TagTable             string                `` /* 217-byte string literal not displayed */
	ExtraPrefix          string                `` /* 148-byte string literal not displayed */
	ConnectTimeout       time.Duration         `toml:"connect-timeout"          json:"connect-timeout"          comment:"TCP connection timeout"`
	// TODO: remove in v0.14
	DataTableLegacy string `` /* 217-byte string literal not displayed */
	// TODO: remove in v0.14
	RollupConfLegacy string `` /* 217-byte string literal not displayed */
	MaxDataPoints    int    `` /* 126-byte string literal not displayed */
	// 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"`

	TLSParams config.TLS  `` /* 223-byte string literal not displayed */
	TLSConfig *tls.Config `toml:"-"                        json:"-"`
}

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           `` /* 149-byte string literal not displayed */
	MaxCPU                 int              `toml:"max-cpu"                    json:"max-cpu"`
	MaxMetricsInFindAnswer int              ``                                           /* 130-byte string literal not displayed */
	MaxMetricsPerTarget    int              ``                                           /* 168-byte string literal not displayed */
	AppendEmptySeries      bool             ``                                           /* 165-byte string literal not displayed */
	TargetBlacklist        []string         ``                                           /* 185-byte string literal not displayed */
	Blacklist              []*regexp.Regexp `toml:"-"                          json:"-"` // compiled TargetBlacklist
	MemoryReturnInterval   time.Duration    ``                                           /* 133-byte string literal not displayed */
	HeadersToLog           []string         `toml:"headers-to-log"             json:"headers-to-log"             comment:"additional request headers to log"`

	BaseWeight       int           `toml:"base_weight"            json:"base_weight"            comment:"service discovery base weight (on idle)"`
	DegragedMultiply float64       `` /* 187-byte string literal not displayed */
	DegragedLoad     float64       `` /* 148-byte string literal not displayed */
	SDType           SDType        `toml:"service-discovery-type" json:"service-discovery-type" comment:"service discovery type"`
	SD               string        `toml:"service-discovery"      json:"service-discovery"      comment:"service discovery address (consul)"`
	SDNamespace      string        `toml:"service-discovery-ns"   json:"service-discovery-ns"   comment:"service discovery namespace (graphite by default)"`
	SDDc             []string      `` /* 149-byte string literal not displayed */
	SDExpire         time.Duration `` /* 152-byte string literal not displayed */

	FindCacheConfig CacheConfig `toml:"find-cache"      json:"find-cache"             comment:"find/tags cache config"`

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

Common config

type Config

type Config struct {
	Common       Common             `toml:"common"        json:"common"`
	FeatureFlags FeatureFlags       `toml:"feature-flags" json:"feature-flags"`
	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               `` /* 149-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, exactConfig bool) (*Config, []zap.Field, 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, exactConfig bool) (cfg *Config, warns []zap.Field, err error)

Unmarshal process the body to *Config

func (*Config) GetUserFindLimiter added in v0.14.0

func (c *Config) GetUserFindLimiter(username string) limiter.ServerLimiter

func (*Config) GetUserTagsLimiter added in v0.14.0

func (c *Config) GetUserTagsLimiter(username string) limiter.ServerLimiter

func (*Config) NeedLoadAvgColect added in v0.14.0

func (c *Config) NeedLoadAvgColect() bool

NeedLoadAvgColect check if load avg collect is neeeded

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           `` /* 134-byte string literal not displayed */
	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                `` /* 132-byte string literal not displayed */
	TargetMatchAll         string                `` /* 132-byte string literal not displayed */
	TargetMatchAnyRegexp   *regexp.Regexp        `toml:"-"                        json:"-"`
	TargetMatchAllRegexp   *regexp.Regexp        `toml:"-"                        json:"-"`
	RollupConf             string                `` /* 145-byte string literal not displayed */
	RollupAutoTable        string                `` /* 144-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                  `` /* 165-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 FeatureFlags added in v0.14.0

type FeatureFlags struct {
	UseCarbonBehavior    bool `toml:"use-carbon-behaviour" json:"use-carbon-behaviour" comment:"if true, prefers carbon's behaviour on how tags are treated"`
	DontMatchMissingTags bool `` /* 187-byte string literal not displayed */
}

FeatureFlags contains feature flags that significantly change how gch responds to some requests

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 {
	Listen                     string        `toml:"listen"                        json:"listen"                        comment:"listen addr for prometheus ui and api"`
	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"`
	LookbackDelta              time.Duration `toml:"lookback-delta"                json:"lookback-delta"`
	RemoteReadConcurrencyLimit int           `toml:"remote-read-concurrency-limit" json:"remote-read-concurrency-limit" comment:"concurrently handled remote read requests"`
}

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"`

	MaxQueries        int `toml:"max-queries" json:"max-queries" comment:"Max queries to fetch data"`
	ConcurrentQueries int `toml:"concurrent-queries" json:"concurrent-queries" comment:"Concurrent queries to fetch data"`
	AdaptiveQueries   int `` /* 139-byte string literal not displayed */

	Limiter limiter.ServerLimiter `toml:"-" json:"-"`
}

type SDType added in v0.14.0

type SDType uint8

func (*SDType) MarshalJSON added in v0.14.0

func (a *SDType) MarshalJSON() ([]byte, error)

func (*SDType) MarshalText added in v0.14.0

func (a *SDType) MarshalText() ([]byte, error)

func (*SDType) Set added in v0.14.0

func (a *SDType) Set(value string) error

func (*SDType) String added in v0.14.0

func (a *SDType) String() string

func (*SDType) Type added in v0.14.0

func (a *SDType) Type() string

func (*SDType) UnmarshalJSON added in v0.14.0

func (a *SDType) UnmarshalJSON(data []byte) error

func (*SDType) UnmarshalText added in v0.14.0

func (a *SDType) UnmarshalText(data []byte) error

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"`
	Threads           int                        `` /* 130-byte string literal not displayed */
	Compression       clickhouse.ContentEncoding `` /* 178-byte string literal not displayed */
	Version           uint32                     `` /* 163-byte string literal not displayed */
	SelectChunksCount int                        `` /* 135-byte string literal not displayed */
}

Tags config

type UserLimits added in v0.14.0

type UserLimits struct {
	MaxQueries        int `toml:"max-queries"      json:"max-queries"  comment:"Max queries to fetch data"`
	ConcurrentQueries int `toml:"concurrent-queries" json:"concurrent-queries" comment:"Concurrent queries to fetch data"`
	AdaptiveQueries   int `` /* 139-byte string literal not displayed */

	Limiter limiter.ServerLimiter `toml:"-" json:"-"`
}

Jump to

Keyboard shortcuts

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