config

package
v0.0.0-...-ac3e8bd Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Discard ColumnUsage = iota // Ignore this column
	Label                      // Use this column as a label
	Counter                    // Use this column as a counter
	Gauge                      // Use this column as a gauge

	NoVersion PgVersion = -1
)

Column usage types

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnUsage

type ColumnUsage int

ColumnUsage describes column usage

func (*ColumnUsage) UnmarshalYAML

func (c *ColumnUsage) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the yaml

type Config

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

Config describes exporter config

func New

func New(filename string) *Config

New creates new config

func (*Config) Db

func (c *Config) Db(dbName string) DbConfig

Db returns the database config

func (*Config) DbList

func (c *Config) DbList() []string

DbList returns list of the databases

func (*Config) Load

func (c *Config) Load() error

Load loads the config

type DbConfig

type DbConfig struct {
	Host             string            `yaml:"host"`
	Port             uint16            `yaml:"port"`
	User             string            `yaml:"user"`
	Password         string            `yaml:"password"`
	Dbname           string            `yaml:"dbname"`
	Sslmode          string            `yaml:"sslmode"`
	QueryFiles       []string          `yaml:"queryFiles"`
	LabelsMap        map[string]string `yaml:"labels"`
	WorkersNumber    int               `yaml:"workers"`
	StatementTimeout time.Duration     `yaml:"statementTimeout"`
	IsNotPg          bool              `yaml:"isNotPg"`
	// contains filtered or unexported fields
}

DbConfig describes database to get metrics from

func (*DbConfig) ApplicationName

func (d *DbConfig) ApplicationName() string

func (*DbConfig) InstanceName

func (d *DbConfig) InstanceName() string

InstanceName returns instance name

func (*DbConfig) Labels

func (d *DbConfig) Labels() map[string]string

Labels returns db labels

func (*DbConfig) LoadQueries

func (d *DbConfig) LoadQueries() error

LoadQueries loads the queries from the QueryFiles

func (*DbConfig) Queries

func (d *DbConfig) Queries() []Query

Queries returns db queries

func (*DbConfig) Workers

func (d *DbConfig) Workers() int

Workers returns number of workers for the db

type DbConfigInterface

type DbConfigInterface interface {
	Workers() int
	Queries() []Query
	InstanceName() string
	Labels() map[string]string
	ApplicationName() string
}

DbConfigInterface describes DbConfig methods

type Interface

type Interface interface {
	Load() error
	DbList() []string
	Db(string) DbConfig
}

Interface describes Config methods

type Metric

type Metric struct {
	Usage       ColumnUsage `yaml:"usage"`
	Description string      `yaml:"description"`
}

Metric describes metric

type Metrics

type Metrics map[string]Metric

Metrics describe metrics

func (*Metrics) UnmarshalYAML

func (m *Metrics) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the yaml

type PgVersion

type PgVersion int

PgVersion describes version in server_version_num format

func ParseVersion

func ParseVersion(str string) PgVersion

func (PgVersion) String

func (v PgVersion) String() string

PgVersion returns string representation of the version

func (*PgVersion) UnmarshalYAML

func (v *PgVersion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the yaml

type Query

type Query struct {
	Name        string
	Metrics     Metrics `yaml:"metrics"`
	VerSQL      VerSQLs `yaml:"query"`
	NameColumn  string  `yaml:"nameColumn"`
	ValueColumn string  `yaml:"valueColumn"`
}

Query describes query

type VerSQL

type VerSQL struct {
	SQL    string
	MinVer PgVersion
	MaxVer PgVersion
}

VerSQL describes PostgreSQL version specific SQL

type VerSQLs

type VerSQLs []VerSQL

VerSQLs contain version specific SQLs

func (VerSQLs) Query

func (v VerSQLs) Query(version PgVersion) string

Query returns query for the requested postgresql version

func (*VerSQLs) UnmarshalYAML

func (v *VerSQLs) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the yaml

Jump to

Keyboard shortcuts

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