config

package
v1.1.0-rc-1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config contains the configuration for the application.

Index

Constants

This section is empty.

Variables

View Source
var ResourceTypeToMetricName = map[ResourceType]string{
	Unknown:     "unknown",
	Deployment:  "deployment",
	StatefulSet: "statefulset",
	Pod:         "pod",
	Node:        "node",
	Namespace:   "namespace",
	Job:         "job",
	CronJob:     "cronjob",
	DaemonSet:   "daemonset",
}

Functions

This section is empty.

Types

type Annotations

type Annotations struct {
	Enabled   bool      `yaml:"enabled" default:"false" env:"ANNOTATIONS_ENABLED" env-description:"enable annotations"`
	Resources Resources `yaml:"resources"`
	Patterns  []string  `yaml:"patterns" env:"ANNOTATIONS_FILTERS" env-description:"list of annotations regular expressions to filter"`
}

type Certificate

type Certificate struct {
	Key  string `yaml:"key" env:"TLS_KEY" env-description:"path to the TLS key"`
	Cert string `yaml:"cert" env:"TLS_CERT" env-description:"path to the TLS certificate"`
}

type Database

type Database struct {
	Enabled         bool          `` /* 150-byte string literal not displayed */
	StoragePath     string        `yaml:"storage_path" default:"/opt/insights" env:"DATABASE_STORAGE_PATH" env-description:"location where to write database"`
	RetentionTime   time.Duration `` /* 136-byte string literal not displayed */
	CleanupInterval time.Duration `yaml:"cleanup_interval" default:"3h" env:"DATABASE_CLEANUP_INTERVAL" env-description:"how often to check for expired data"`
	BatchUpdateSize int           `` /* 134-byte string literal not displayed */
}

type Files

type Files []string

Files is a custom flag type to handle multiple configuration files

func (*Files) Set

func (c *Files) Set(value string) error

Set appends a new configuration file to the Files

func (*Files) String

func (c *Files) String() string

type Filters

type Filters struct {
	Labels      Labels      `yaml:"labels"`
	Annotations Annotations `yaml:"annotations"`
	Policy      bluemonday.Policy
}

type K8sClient

type K8sClient struct {
	KubeConfig      string `yaml:"kube_config" env:"KUBE_CONFIG" default:"false" env-description:"path to the kubeconfig file"`
	PaginationLimit int64  `yaml:"pagination_limit" env:"KUBE_PAGINATION_LIMIT" default:"500" env-description:"limit for pagination"`
}

type Labels

type Labels struct {
	Enabled   bool      `yaml:"enabled" default:"false" env:"LABELS_ENABLED" env-description:"enable labels"`
	Resources Resources `yaml:"resources"`
	Patterns  []string  `yaml:"patterns" env:"LABEL_FILTERS" env-description:"list of label regular expressions to filter"`
}

type Logging

type Logging struct {
	Level string `yaml:"level" default:"info" env:"LOG_LEVEL" env-description:"logging level such as debug, info, error"`
}

type MetricLabelTags

type MetricLabelTags = map[string]string

MetricLabelTags represents metric labels attached to a metric that represent annotations or labels; value must be prefixed with "label_"

func Filter

func Filter(tags map[string]string, patterns []regexp.Regexp, enabled bool, settings *Settings) MetricLabelTags

type MetricLabels

type MetricLabels = map[string]string

MetricLabels represents any metric label that can be added to a metric; "pod", "namespace", "label_foo" etc.

type RemoteWrite

type RemoteWrite struct {
	Host            string
	MaxBytesPerSend int           `` /* 129-byte string literal not displayed */
	SendInterval    time.Duration `yaml:"send_interval" default:"60s" env:"SEND_INTERVAL" env-description:"interval in seconds to send data"`
	SendTimeout     time.Duration `yaml:"send_timeout" default:"30s" env:"SEND_TIMEOUT" env-description:"timeout in seconds to send data"`
	MaxRetries      int           `yaml:"max_retries" default:"3" env:"MAX_RETRIES" env-description:"maximum number of retries"`
	// contains filtered or unexported fields
}

type ResourceType

type ResourceType int
const (
	Unknown     ResourceType = 0
	Deployment  ResourceType = 1
	StatefulSet ResourceType = 2
	Pod         ResourceType = 3
	Node        ResourceType = 4
	Namespace   ResourceType = 5
	Job         ResourceType = 6
	CronJob     ResourceType = 7
	DaemonSet   ResourceType = 8
)

type Resources

type Resources struct {
	Pods         bool `yaml:"pods" default:"true"`
	Namespaces   bool `yaml:"namespaces" default:"true"`
	Deployments  bool `yaml:"deployments" default:"false"`
	Jobs         bool `yaml:"jobs" default:"false"`
	CronJobs     bool `yaml:"cronjobs" default:"false"`     //nolint:tagliatelle // compatibility
	StatefulSets bool `yaml:"statefulsets" default:"false"` //nolint:tagliatelle // compatibility
	DaemonSets   bool `yaml:"daemonsets" default:"false"`   //nolint:tagliatelle // compatibility
	Nodes        bool `yaml:"nodes" default:"false"`
}

type Server

type Server struct {
	Port         string        `yaml:"port" default:"8080" env:"PORT" env-description:"port to listen on"`
	ReadTimeout  time.Duration `yaml:"read_timeout" default:"15s" env:"READ_TIMEOUT" env-description:"server read timeout in seconds"`
	WriteTimeout time.Duration `yaml:"write_timeout" default:"15s" env:"WRITE_TIMEOUT" env-description:"server write timeout in seconds"`
	IdleTimeout  time.Duration `yaml:"idle_timeout" default:"60s" env:"IDLE_TIMEOUT" env-description:"server idle timeout in seconds"`
}

type Settings

type Settings struct {
	CloudAccountID    string      `yaml:"cloud_account_id" env:"CLOUD_ACCOUNT_ID" env-description:"CSP account ID"`
	Region            string      `yaml:"region" env:"CSP_REGION" env-description:"cloud service provider region"`
	ClusterName       string      `yaml:"cluster_name" env:"CLUSTER_NAME" env-description:"name of the cluster to monitor"`
	Destination       string      `` /* 143-byte string literal not displayed */
	APIKeyPath        string      `yaml:"api_key_path" env:"API_KEY_PATH" env-description:"path to the API key file"`
	Server            Server      `yaml:"server"`
	Certificate       Certificate `yaml:"certificate"`
	Logging           Logging     `yaml:"logging"`
	Database          Database    `yaml:"database"`
	Filters           Filters     `yaml:"filters"`
	RemoteWrite       RemoteWrite `yaml:"remote_write"`
	K8sClient         K8sClient   `yaml:"k8s_client"`
	LabelMatches      []regexp.Regexp
	AnnotationMatches []regexp.Regexp
	// contains filtered or unexported fields
}

Settings represents the configuration settings for the application.

func NewSettings

func NewSettings(configFiles ...string) (*Settings, error)

func (*Settings) GetAPIKey

func (s *Settings) GetAPIKey() string

func (*Settings) SetAPIKey

func (s *Settings) SetAPIKey() error

Jump to

Keyboard shortcuts

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