agentctl

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigSync

func ConfigSync(logger log.Logger, cli client.PrometheusClient, dir string, dryRun bool) error

ConfigSync loads YAML files from a directory and syncs them to the provided PrometheusClient API. All YAML files will be synced and must be valid.

The base name of the YAML file (i.e., without the file extension) is used as the config name.

ConfigSync will completely overwrite the set of active configs present in the provided PrometheusClient - configs present in the API but not in the directory will be deleted.

func ConfigsFromDirectory

func ConfigsFromDirectory(dir string) ([]*instance.Config, error)

ConfigsFromDirectory parses all YAML files from a directory and loads each as an instance.Config.

Types

type BySeriesCount added in v0.7.0

type BySeriesCount []WALTargetStats

BySeriesCount can sort a slice of target stats by the count of series. The slice is sorted in descending order.

func (BySeriesCount) Len added in v0.7.0

func (s BySeriesCount) Len() int

func (BySeriesCount) Less added in v0.7.0

func (s BySeriesCount) Less(i, j int) bool

func (BySeriesCount) Swap added in v0.7.0

func (s BySeriesCount) Swap(i, j int)

type Cardinality added in v0.7.0

type Cardinality struct {
	Metric    string
	Instances int
}

Cardinality represents some metric by name and the number of times that metric is used with a different combination of unique labels.

func FindCardinality added in v0.7.0

func FindCardinality(walDir string, job string, instance string) ([]Cardinality, error)

FindCardinality searches the WAL and returns the cardinality of all __name__ series within the WAL for any given series with the label job=<job> and instance=<instance>. All other series are ignored.

type SampleStats added in v0.9.0

type SampleStats struct {
	Labels  labels.Labels
	From    time.Time
	To      time.Time
	Samples int64
}

SampleStats are statistics for samples for a series within the WAL. Each instance represents a unique series based on its labels, and holds the range of timestamps found for all samples including the total number of samples for that series.

func FindSamples added in v0.9.0

func FindSamples(walDir string, selectorStr string) ([]*SampleStats, error)

FindSamples searches the WAL and returns a summary of samples of series matching the given label selector.

type WALStats added in v0.7.0

type WALStats struct {
	// From holds the first timestamp for the oldest sample found within the WAL.
	From time.Time

	// To holds the last timestamp for the newest sample found within the WAL.
	To time.Time

	// CheckpointNumber is the segment number of the most recently created
	// checkpoint.
	CheckpointNumber int

	// FirstSegment is the segment number of the first (oldest) non-checkpoint
	// segment file found within the WAL folder.
	FirstSegment int

	// FirstSegment is the segment number of the last (newest) non-checkpoint
	// segment file found within the WAL folder.
	LastSegment int

	// InvalidRefs is the number of samples with a ref ID to which there is no
	// series defined.
	InvalidRefs int

	// HashCollisions is the total number of times there has been a hash
	// collision. A hash collision is any instance in which a hash of labels
	// is defined by two ref IDs.
	//
	// For the Grafana Agent, a hash collision has no negative side effects
	// on data sent to the remote_write endpoint but may have a noticeable inpact
	// on memory while the collision exists.
	HashCollisions int

	// Targets holds stats on specific scrape targets.
	Targets []WALTargetStats
}

WALStats stores statistics on the whole WAL.

func CalculateStats added in v0.7.0

func CalculateStats(walDir string) (WALStats, error)

CalculateStats calculates the statistics of the WAL for the given directory. walDir must be a folder containing segment files and checkpoint directories.

func (WALStats) Samples added in v0.7.0

func (s WALStats) Samples() int

Samples returns the number of Samples across all targets.

func (WALStats) Series added in v0.7.0

func (s WALStats) Series() int

Series returns the number of series across all targets.

type WALTargetStats added in v0.7.0

type WALTargetStats struct {
	// Job corresponds to the "job" label on the scraped target.
	Job string

	// Instance corresponds to the "instance" label on the scraped target.
	Instance string

	// Series is the total number of series for the scraped target. It is
	// equivalent to the total cardinality.
	Series int

	// Samples is the total number of samples for the scraped target.
	Samples int
}

WALTargetStats aggregates statistics on scrape targets across the entirety of the WAL and its checkpoints.

Jump to

Keyboard shortcuts

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