config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClickHouse

type ClickHouse struct {
	DSN      string            `yaml:"dsn" validate:"uri" default:"http://127.0.0.1:8123/?async_insert=1&wait_for_async_insert=1"`
	Params   map[string]string `yaml:"params"`
	QueryLog struct {
		ConfigWhen `yaml:",inline"`
	} `yaml:"query_log"`
}

type Config

type Config struct {
	ClickHouse ClickHouse `yaml:"clickhouse"`

	Insert struct {
		Enabled          bool   `yaml:"enabled" default:"true"`
		Listen           string `yaml:"listen" default:"0.0.0.0:9095" validate:"hostname_port"`
		CloseConnections bool   `yaml:"close-connections" default:"false"`
		Table            string `yaml:"table" default:"samples_null"`
		IDFunc           string `yaml:"id_func" default:"name_with_sha256" validate:"oneof=name_with_sha256"`
	} `yaml:"insert"`

	Select struct {
		TableSeries          string        `yaml:"table_series"  default:"series"`
		TableSamples         string        `yaml:"table_samples" default:"samples"`
		AutocompleteLookback time.Duration `yaml:"autocomplete_lookback" default:"168h"`
		SeriesPartitionMs    int64         `yaml:"series_partition_ms" default:"86400000"`
		// https://clickhouse.com/docs/knowledgebase/improve-map-performance
		// column names should be label_<label_name>
		SeriesMaterializedLabels []string `yaml:"series_materialize_labels"`
		SamplesTimestampUInt32   bool     `yaml:"samples_timestamp_uint32"`
	} `yaml:"select"`

	Prometheus struct {
		Enabled                    bool          `yaml:"enabled" default:"true"`
		Listen                     string        `yaml:"listen" default:"0.0.0.0:9096" comment:"listen addr for prometheus ui and api"`
		ExternalURL                string        `yaml:"external_url" default:"http://127.0.0.1:9096" comment:"allows to set URL for redirect manually"`
		PageTitle                  string        `yaml:"page_title" default:"Pluto"`
		LookbackDelta              time.Duration `yaml:"lookback_delta" default:"5m"`
		RemoteReadConcurrencyLimit int           `yaml:"remote_read_concurrency_limit" default:"10" comment:"concurrently handled remote read requests"`
	} `yaml:"prometheus"`

	Debug struct {
		Enabled bool   `yaml:"enabled" default:"true"`
		Listen  string `yaml:"listen" default:"0.0.0.0:9095"`
		Pprof   bool   `yaml:"pprof" default:"true"`
		Metrics bool   `yaml:"metrics" default:"true"`
	} `yaml:"debug"`

	Logging zap.Config `yaml:"logging"`

	OverrideInsert []struct {
		ConfigInsert `yaml:",inline"`
		ConfigWhen   `yaml:",inline"`
	} `yaml:"override_insert"`

	OverrideSeries []struct {
		ConfigSeries `yaml:",inline"`
		ConfigWhen   `yaml:",inline"`
	} `yaml:"override_series"`

	OverrideSamples []struct {
		ConfigSamples `yaml:",inline"`
		ConfigWhen    `yaml:",inline"`
	} `yaml:"override_samples"`
}

func LoadFromFile

func LoadFromFile(filename string, development bool) (*Config, error)

func (*Config) GetInsert

func (cfg *Config) GetInsert(values *EnvInsert) (ConfigInsert, error)

func (*Config) GetSamples

func (cfg *Config) GetSamples(values *EnvSamples) (ConfigSamples, error)

func (*Config) GetSeries

func (cfg *Config) GetSeries(values *EnvSeries) (ConfigSeries, error)

type ConfigInsert

type ConfigInsert struct {
	Table      string      `yaml:"table"`
	IDFunc     string      `yaml:"id_func" default:"" validate:"oneof='' 'name_with_sha256'"`
	ClickHouse *ClickHouse `yaml:"clickhouse"`
}

type ConfigSamples

type ConfigSamples struct {
	Table                  string      `yaml:"table"`
	SamplesTimestampUInt32 bool        `yaml:"samples_timestamp_uint32"`
	ClickHouse             *ClickHouse `yaml:"clickhouse"`
}

type ConfigSeries

type ConfigSeries struct {
	Table                    string        `yaml:"table"`
	AutocompleteLookback     time.Duration `yaml:"autocomplete_lookback"`
	SeriesPartitionMs        int64         `yaml:"series_partition_ms"`
	SeriesMaterializedLabels []string      `yaml:"series_materialized_labels"`
	ClickHouse               *ClickHouse   `yaml:"clickhouse"`
}

type ConfigWhen

type ConfigWhen struct {
	WhenStr  string      `yaml:"when" default:""`
	WhenExpr *vm.Program `yaml:"-"`
}

func (*ConfigWhen) Pass

func (w *ConfigWhen) Pass() bool

func (*ConfigWhen) When

func (w *ConfigWhen) When(env any) (bool, error)

type EnvInsert

type EnvInsert struct {
	GetParams map[string]string `expr:"GET"`
	Headers   map[string]string `expr:"HEADER"`
}

func NewEnvInsert

func NewEnvInsert() *EnvInsert

func (*EnvInsert) WithRequest

func (env *EnvInsert) WithRequest(r *http.Request) *EnvInsert

type EnvQueryLog

type EnvQueryLog struct {
	Kind      string `expr:"kind"`
	Query     string `expr:"query"`
	ElapsedMs int64  `expr:"elapsed_ms"`
}

type EnvSamples

type EnvSamples EnvSeries

func NewEnvSamples

func NewEnvSamples() *EnvSamples

type EnvSeries

type EnvSeries struct {
	Start           int64    `expr:"start"`
	End             int64    `expr:"end"`
	Limit           int      `expr:"limit"`
	Step            int64    `expr:"step"`
	Func            string   `expr:"func"`
	Grouping        []string `expr:"grouping"`
	By              bool     `expr:"by"`
	Range           int64    `expr:"range"`
	ShardCount      uint64   `expr:"shard_count"`
	ShardIndex      uint64   `expr:"shard_index"`
	DisableTrimming bool     `expr:"disable_trimming"`
}

func NewEnvSeries

func NewEnvSeries() *EnvSeries

Jump to

Keyboard shortcuts

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