Documentation
¶
Overview ¶
Package client provides a client for pushing logs to a Loki instance.
Index ¶
Constants ¶
const PushPath = "/loki/api/v1/push"
PushPath is the path to the Loki push endpoint.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is an interface that abstracts the sending of log entries to Loki. Each call to Push represents a single log entry being sent to Loki.
Implementations of this interface should be safe to use concurrently.
type Entry ¶
type Entry struct { Timestamp time.Time Labels Labeler Line string StructuredMetadata map[string]string }
Entry is a struct that represents a single log entry to be sent to Loki. It contains the timestamp, labels, line, and structured metadata. It does not have any knowledge of streams.
func (*Entry) AsPushRequest ¶
func (entry *Entry) AsPushRequest() push.PushRequest
AsPushRequest converts the Entry to a push.PushRequest that can be marshaled, compressed, and sent to Loki. This method does not modify the Entry.
type LabelMap ¶
LabelMap is a map of labels that can be converted to a string for sending to Loki. It implements the Labeler interface.
func (LabelMap) Label ¶
func (lm LabelMap) Label() LabelString
Label returns the string representation of the LabelMap.
type LabelString ¶
type LabelString string
LabelString is a string that contains labels already formatted as a string. It implements the Labeler interface.
func (LabelString) Label ¶
func (ls LabelString) Label() LabelString
Label returns the string representation of the LabelsString. It is effectively a no-op.
type Labeler ¶
type Labeler interface { // Label returns a single string that represents all the labels to add to the stream. // // # Format // // The labels follow the format `{key="value", key2="value2"}`. The values should be properly escaped as Go // strings, such as by [strconv.Quote]. The keys should also be sorted alphabetically. Label() LabelString }
Labeler is an interface that abstracts the conversion of labels to a string for sending to Loki. For now, it is best to use the LabelMap type, which implements this interface.
type LokiClient ¶
type LokiClient struct {
// contains filtered or unexported fields
}
LokiClient is a client for pushing log entries to a Loki instance. It implements the Client interface.
func NewLokiClient ¶
func NewLokiClient(url string) *LokiClient
NewLokiClient creates a new LokiClient with the given URL.