userconfig

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// RulesFiles maps from a rules filename to file contents.
	RulesConfig        RulesConfig
	TemplateFiles      map[string]string
	AlertmanagerConfig string
}

A Config is a Cortex configuration for a single user.

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Config) MarshalYAML

func (c Config) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Config) UnmarshalYAML

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

UnmarshalYAML implements yaml.Unmarshaler.

type ID

type ID int

An ID is the ID of a single users's Cortex configuration. When a configuration changes, it gets a new ID.

type RuleFormatVersion

type RuleFormatVersion int

RuleFormatVersion indicates which Prometheus rule format (v1 vs. v2) to use in parsing.

const (
	// RuleFormatV1 is the Prometheus 1.x rule format.
	RuleFormatV1 RuleFormatVersion = iota
	// RuleFormatV2 is the Prometheus 2.x rule format.
	RuleFormatV2 RuleFormatVersion = iota
)

func (RuleFormatVersion) IsValid

func (v RuleFormatVersion) IsValid() bool

IsValid returns whether the rules format version is a valid (known) version.

func (RuleFormatVersion) MarshalJSON

func (v RuleFormatVersion) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (RuleFormatVersion) MarshalYAML

func (v RuleFormatVersion) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*RuleFormatVersion) UnmarshalJSON

func (v *RuleFormatVersion) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*RuleFormatVersion) UnmarshalYAML

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

UnmarshalYAML implements yaml.Unmarshaler.

type RulesConfig

type RulesConfig struct {
	FormatVersion RuleFormatVersion `json:"format_version"`
	Files         map[string]string `json:"files"`
}

RulesConfig is the rules configuration for a particular organization.

func (RulesConfig) Equal

func (c RulesConfig) Equal(o RulesConfig) bool

Equal compares two RulesConfigs for equality.

instance Eq RulesConfig

func (RulesConfig) Parse

func (c RulesConfig) Parse() (map[string][]rules.Rule, error)

Parse parses and validates the content of the rule files in a RulesConfig according to the passed rule format version.

func (RulesConfig) ParseFormatted

func (c RulesConfig) ParseFormatted() (map[string]rulefmt.RuleGroups, error)

ParseFormatted returns the rulefmt map of a users rules configs. It allows for rules to be mapped to disk and read by the prometheus rules manager.

type VersionedRulesConfig

type VersionedRulesConfig struct {
	ID        ID          `json:"id"`
	Config    RulesConfig `json:"config"`
	DeletedAt time.Time   `json:"deleted_at"`
}

VersionedRulesConfig is a RulesConfig together with a version. `data Versioned a = Versioned { id :: ID , config :: a }`

func (VersionedRulesConfig) IsDeleted

func (vr VersionedRulesConfig) IsDeleted() bool

IsDeleted tells you if the config is deleted.

type View

type View struct {
	ID        ID        `json:"id"`
	Config    Config    `json:"config"`
	DeletedAt time.Time `json:"deleted_at"`
}

View is what's returned from the Weave Cloud configs service when we ask for all Cortex configurations.

The configs service is essentially a JSON blob store that gives each _version_ of a configuration a unique ID and guarantees that later versions have greater IDs.

func (View) GetVersionedRulesConfig

func (v View) GetVersionedRulesConfig() *VersionedRulesConfig

GetVersionedRulesConfig specializes the view to just the rules config.

func (View) IsDeleted

func (v View) IsDeleted() bool

IsDeleted tells you if the config is deleted.

Jump to

Keyboard shortcuts

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