generator

package
v0.0.0-...-7376c67 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SyntheticSampleSelection is a string of characters a SyntheticLogType will use
	// to create a synthetic log.
	SyntheticSampleSelection = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

Variables

This section is empty.

Functions

func FormatLog

func FormatLog(style Format, hash string, messageCount int64, payload string) (string, error)

func LogLabelSet

func LogLabelSet(host string, options LabelSetOptions) model.LabelSet

LogLabelSet creates a label set based on the configured options

func NewElasticsearchLogContent

func NewElasticsearchLogContent(host, logLine string) ([]byte, error)

NewElasticsearchLogContent returns a byte array representing the json content for a log to be consumed by Elasticsearch.

func RandomLog

func RandomLog(logType LogType, logSize int) (string, error)

RandomLog returns a log of a given type from the requested sample set.

Types

type ClientType

type ClientType string

ClientType describes the type of client to use for querying logs

const (
	// FileClientType uses a file to write logs to
	FileClientType ClientType = "file"

	// LokiClientType uses a Promtail client to forward logs
	LokiClientType ClientType = "loki"

	// ElasticsearchClientType uses an Elasticsearch client to forward logs
	ElasticsearchClientType ClientType = "elasticsearch"
)

type ElasticsearchLogContent

type ElasticsearchLogContent struct {
	Hostname  string    `json:"hostname"`
	Service   string    `json:"service"`
	Level     string    `json:"level"`
	Component string    `json:"component"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
}

ElasticsearchLogContent describes the json content for logs for Elasticsearch

type Format

type Format string

Format describes the way a log should be formatted

const (
	// CRIOFormat formats a log to appear in CRIO style
	CRIOFormat Format = "crio"

	// CRIOFormat formats a log to appear in CSV style
	CSVFormat Format = "csv"

	// JSONFormat formats a log to appear in JSON style
	JSONFormat Format = "json"

	// RawFormat formats a log to appear as the sample with no changes.  This is most
	// applicable for audit like samples
	RawFormat Format = "raw"
)

type LabelSetOptions

type LabelSetOptions string

LabelSetOptions describes which labels to include

const (
	// ClientOnlyOption creates a label set with only the client label
	ClientOnlyOption LabelSetOptions = "client"

	// ClientHostOnlyOption creates a label set with only the client and host label
	ClientHostOnlyOption LabelSetOptions = "client-host"
)

type LogGenerator

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

LogGenerator describes an object which generates logs

func NewLogGenerator

func NewLogGenerator(opts Options, registry *prometheus.Registry) (*LogGenerator, error)

func (*LogGenerator) GenerateLogs

func (g *LogGenerator) GenerateLogs()

func (*LogGenerator) Start

func (g *LogGenerator) Start(ctx context.Context, wg *sync.WaitGroup, errCh chan<- error)

type LogType

type LogType string

LogType describes the type of generated log

const (
	// ApplicationLogType represents a log that is likely to be seen in an
	// application runtime environment.
	ApplicationLogType LogType = "application"

	// AuditLogType represents a log from a kubernetes API server audit log
	AuditLogType LogType = "audit"

	// SyntheticLogType represents a log that is composed of random
	// alphabetical characters of a certain size.
	SyntheticLogType LogType = "synthetic"
)

type Options

type Options struct {
	// Client describes the client to use for forwarding
	Client ClientType
	// ClientURl is the endpoint to forward to
	ClientURL string
	// FileName is the name of the file to create and write to
	FileName string
	// Tenant is identification to use for Loki
	Tenant string
	// DisableSecurityCheck deactivates the TLS checks
	DisableSecurityCheck bool
	// LogsPerSecond is the number of logs to write per second
	LogsPerSecond int

	LogType              string
	LogFormat            string
	LabelType            string
	SyntheticPayloadSize int
	UseRandomHostname    bool
}

Options describes the settings that can be modified for the log generator

Jump to

Keyboard shortcuts

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