gcplogtarget

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ReservedLabelTenantID = "__tenant_id__"

ReservedLabelTenantID reserved to override the tenant ID while processing pipeline stages

Variables

This section is empty.

Functions

This section is empty.

Types

type GCPLogEntry

type GCPLogEntry struct {
	// why was this here?? nolint:revive
	LogName  string `json:"logName"`
	Resource struct {
		Type   string            `json:"type"`
		Labels map[string]string `json:"labels"`
	} `json:"resource"`
	Timestamp string `json:"timestamp"`

	// The time the log entry was received by Logging.
	// Its important that `Timestamp` is optional in GCE log entry.
	ReceiveTimestamp string `json:"receiveTimestamp"`

	// Optional. The severity of the log entry. The default value is DEFAULT.
	// DEFAULT, DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY
	// https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
	Severity string `json:"severity"`

	// Optional. A map of key, value pairs that provides additional information about the log entry.
	// The labels can be user-defined or system-defined.
	Labels map[string]string `json:"labels"`

	TextPayload string `json:"textPayload"`
}

GCPLogEntry that will be written to the pubsub topic according to the following spec. https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

type Metrics

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

Metrics stores gcplog entry metrics.

func NewMetrics

func NewMetrics(reg prometheus.Registerer) *Metrics

NewMetrics creates a new set of metrics. Metrics will be registered to reg.

type PullTarget

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

PullTarget represents a target that scrapes logs from a GCP project id and subscription and converts them to Loki log entries.

func NewPullTarget

func NewPullTarget(metrics *Metrics, logger log.Logger, handler loki.EntryHandler, jobName string, config *gcptypes.PullConfig, relabel []*relabel.Config, clientOptions ...option.ClientOption) (*PullTarget, error)

NewPullTarget returns the new instance of PullTarget.

func (*PullTarget) Details

func (t *PullTarget) Details() map[string]string

Details returns some debug information about the target.

func (*PullTarget) Labels

func (t *PullTarget) Labels() model.LabelSet

Labels return the model.LabelSet that the target applies to log entries.

func (*PullTarget) Stop

func (t *PullTarget) Stop() error

Stop shuts the target down.

type PushMessage

type PushMessage struct {
	Message struct {
		Attributes       map[string]string `json:"attributes"`
		Data             string            `json:"data"`
		ID               string            `json:"message_id"`
		PublishTimestamp string            `json:"publish_time"`
	} `json:"message"`
	Subscription string `json:"subscription"`
}

PushMessage is the POST body format sent by GCP PubSub push subscriptions. See https://cloud.google.com/pubsub/docs/push for details.

func (PushMessage) Validate

func (pm PushMessage) Validate() error

Validate checks that the required fields of a PushMessage are set.

type PushTarget

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

PushTarget defines a server for receiving messages from a GCP PubSub push subscription.

func NewPushTarget

func NewPushTarget(metrics *Metrics, logger log.Logger, handler loki.EntryHandler, jobName string, config *gcptypes.PushConfig, relabel []*relabel.Config, reg prometheus.Registerer) (*PushTarget, error)

NewPushTarget constructs a PushTarget.

func (*PushTarget) Details

func (p *PushTarget) Details() map[string]string

Details returns some debug information about the target.

func (*PushTarget) Labels

func (p *PushTarget) Labels() model.LabelSet

Labels return the model.LabelSet that the target applies to log entries.

func (*PushTarget) Stop

func (p *PushTarget) Stop() error

Stop shuts down the push target.

type Target

type Target interface {
	Details() map[string]string
	Stop() error
}

Target is a common interface implemented by both GCPLog targets.

Jump to

Keyboard shortcuts

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