cortex

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) string

FromContext returns the tenant ID from the context if present, and empty otherwise.

func NewContext

func NewContext(ctx context.Context, tenantId string) context.Context

NewContext returns a new context.Context that carries the provided tenant ID.

Types

type AlertManagerConfig

type AlertManagerConfig struct {
	Receivers []ReceiverConfig
}

type Client

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

func NewClient

func NewClient(cfg Config, opts ...ClientOption) (*Client, error)

func (*Client) CreateAlertmanagerConfig

func (c *Client) CreateAlertmanagerConfig(amConfigs AlertManagerConfig, tenantID string) error

CreateAlertmanagerConfig uploads an alert manager config to cortex

func (*Client) CreateRuleGroup

func (c *Client) CreateRuleGroup(ctx context.Context, namespace string, rg rwrulefmt.RuleGroup) error

func (*Client) DeleteRuleGroup

func (c *Client) DeleteRuleGroup(ctx context.Context, namespace, groupName string) error

func (*Client) GetRuleGroup

func (c *Client) GetRuleGroup(ctx context.Context, namespace, groupName string) (*rwrulefmt.RuleGroup, error)

func (*Client) ListRules

func (c *Client) ListRules(ctx context.Context, namespace string) (map[string][]rwrulefmt.RuleGroup, error)

type ClientOption

type ClientOption func(*Client)

func WithCortexClient

func WithCortexClient(cc CortexCaller) ClientOption

WithCortexClient uses cortex client passed in the argument

func WithHelperTemplate

func WithHelperTemplate(configYaml, helperTemplate string) ClientOption

WithHelperTemplate assigns helper template and configYaml string

type Config

type Config struct {
	Address                              string `mapstructure:"address" default:"http://localhost:8080"`
	PrometheusAlertManagerConfigYaml     string `mapstructure:"configyaml" default:""`
	PrometheusAlertManagerHelperTemplate string `mapstructure:"helpertemplate" default:""`
}

type CortexCaller

type CortexCaller interface {
	CreateAlertmanagerConfig(ctx context.Context, cfg string, templates map[string]string) error
	CreateRuleGroup(ctx context.Context, namespace string, rg rwrulefmt.RuleGroup) error
	DeleteRuleGroup(ctx context.Context, namespace, groupName string) error
	GetRuleGroup(ctx context.Context, namespace, groupName string) (*rwrulefmt.RuleGroup, error)
	ListRules(ctx context.Context, namespace string) (map[string][]rwrulefmt.RuleGroup, error)
}

type ReceiverConfig

type ReceiverConfig struct {
	Receiver      string
	Type          string
	Match         map[string]string
	Configuration map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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