logs

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package logs implements logs support for the Grafana Agent.

Index

Constants

This section is empty.

Variables

View Source
var DefaultGlobalConfig = GlobalConfig{
	ClientConfigs: []client.Config{},
	FileWatch: file.WatchConfig{
		MinPollFrequency: 250 * time.Millisecond,
		MaxPollFrequency: 250 * time.Millisecond,
	},
}

DefaultGlobalConfig holds default global settings to be used across all instances.

Functions

func DefaultConfig

func DefaultConfig() config.Config

DefaultConfig returns a default config for a Logs instance.

Types

type Config

type Config struct {
	PositionsDirectory string            `yaml:"positions_directory,omitempty"`
	Global             GlobalConfig      `yaml:"global,omitempty"`
	Configs            []*InstanceConfig `yaml:"configs,omitempty"`
}

Config controls the configuration of the Loki log scraper.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults() error

ApplyDefaults applies defaults to the Config and ensures that it is valid.

Validations:

  1. No two InstanceConfigs may have the same name.
  2. No two InstanceConfigs may have the same positions path.
  3. No InstanceConfig may have an empty name.
  4. If InstanceConfig positions path is empty, shared PositionsDirectory must not be empty.

Defaults:

  1. If a positions config is empty, it will be generated based on the InstanceConfig name and Config.PositionsDirectory.
  2. If an InstanceConfigs's ClientConfigs is empty, it will be generated based on the Config.GlobalConfig.ClientConfigs.

func (*Config) UnmarshalYAML

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

UnmarshalYAML implements yaml.Unmarshaler.

type GlobalConfig

type GlobalConfig struct {
	FileWatch     file.WatchConfig `yaml:"file_watch_config,omitempty"`
	ClientConfigs []client.Config  `yaml:"clients,omitempty"`
}

GlobalConfig holds global settings that apply to all instances by default.

func (GlobalConfig) IsZero

func (c GlobalConfig) IsZero() bool

func (*GlobalConfig) UnmarshalYAML

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

UnmarshalYAML implements yaml.Unmarshaler.

type Instance

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

Instance is an individual Logs instance.

func NewInstance

func NewInstance(reg prometheus.Registerer, c *InstanceConfig, g GlobalConfig, l log.Logger, dryRun bool) (*Instance, error)

NewInstance creates and starts a Logs instance.

func (*Instance) ApplyConfig

func (i *Instance) ApplyConfig(c *InstanceConfig, g GlobalConfig, dryRun bool) error

ApplyConfig will apply a new InstanceConfig. If the config hasn't changed, then nothing will happen, otherwise the old Promtail will be stopped and then replaced with a new one.

func (*Instance) SendEntry

func (i *Instance) SendEntry(entry api.Entry, dur time.Duration) bool

SendEntry passes an entry to the internal promtail client and returns true if successfully sent. It is best effort and not guaranteed to succeed.

func (*Instance) Stop

func (i *Instance) Stop()

Stop stops the Promtail instance.

type InstanceConfig

type InstanceConfig struct {
	Name string `yaml:"name,omitempty"`

	ClientConfigs   []client.Config       `yaml:"clients,omitempty"`
	PositionsConfig positions.Config      `yaml:"positions,omitempty"`
	ScrapeConfig    []scrapeconfig.Config `yaml:"scrape_configs,omitempty"`
	TargetConfig    file.Config           `yaml:"target_config,omitempty"`
	LimitsConfig    limit.Config          `yaml:"limits_config,omitempty"`
}

InstanceConfig is an individual Promtail config.

func (*InstanceConfig) Initialize

func (c *InstanceConfig) Initialize()

func (*InstanceConfig) UnmarshalYAML

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

UnmarshalYAML implements yaml.Unmarshaler.

type ListTargetsResponse

type ListTargetsResponse []TargetInfo

ListTargetsResponse is returned by the ListTargetsHandler.

type Logs

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

Logs is a Logs log collection. It uses multiple distinct sets of Logs Promtail agents to collect logs and send them to a Logs server.

func New

func New(reg prometheus.Registerer, c *Config, l log.Logger, dryRun bool) (*Logs, error)

New creates and starts Loki log collection.

func (*Logs) ApplyConfig

func (l *Logs) ApplyConfig(c *Config, dryRun bool) error

ApplyConfig updates Logs with a new Config.

func (*Logs) Instance

func (l *Logs) Instance(name string) *Instance

Instance is used to retrieve a named Logs instance

func (*Logs) ListInstancesHandler

func (l *Logs) ListInstancesHandler(w http.ResponseWriter, _ *http.Request)

ListInstancesHandler writes the set of currently running instances to the http.ResponseWriter.

func (*Logs) ListTargetsHandler

func (l *Logs) ListTargetsHandler(w http.ResponseWriter, r *http.Request)

ListTargetsHandler retrieves the full set of targets across all instances and shows information on them.

func (*Logs) Stop

func (l *Logs) Stop()

Stop stops the log collector.

func (*Logs) WireAPI

func (l *Logs) WireAPI(r *mux.Router)

WireAPI adds API routes to the provided mux router.

type TargetInfo

type TargetInfo struct {
	InstanceName string `json:"instance"`
	TargetGroup  string `json:"target_group"`

	Type             target.TargetType `json:"type"`
	Labels           model.LabelSet    `json:"labels"`
	DiscoveredLabels model.LabelSet    `json:"discovered_labels"`
	Ready            bool              `json:"ready"`
	Details          interface{}       `json:"details"`
}

TargetInfo describes a specific target.

type TargetSet

type TargetSet map[string][]target.Target

TargetSet is a set of targets for an individual scraper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳