View Source Sleipnir (sleipnir v0.1.3)
Sleipnir consists of functions to create valid PushRequests to send to Grafana Loki, as well as a protocol for clients and a default implementation thereof for Tesla clients. This gives the user of this library flexibility in which parts they would like to use, as well as a quick way to start sending requests to Loki by using Tesla.
Functions generally return the underlying Protobufs:
Google.Protobuf.Timestamp
: Standard Protobuf for timestamps. Represented as seconds and nanoseconds encoded in Propleptic Gregorian Calendar. The Sleipnir.Timestamp module provides functions for manipulating and creating timestamps from Elixir-native types.Logproto.EntryAdapter
: An entry is a log line at a certain timeLogproto.StreamAdapter
: A stream is a collection of entries under a common set of labels.Logproto.PushRequest
: A request is a collection of streams, and can be sent to Grafana Loki.
Link to this section Summary
Types
Loki labels are easily represented in Elixir as a list of String tuples.
Functions
Returns an entry, which is a log line/string at a given time. The timestamp can be of type DateTime, NaiveDateTime, or Google.Protobuf.Timestamp. If no timestamp is provided, the current time is used.
Creates a PushRequest from one or more streams.
A stream consists of one or more entries under a common set of labels.
Returns a stream for a single entry from a line and timestamp. To create a stream of multiple entries, take a look at stream/2.
Link to this section Types
@type entry() :: Logproto.EntryAdapter.t()
Loki labels are easily represented in Elixir as a list of String tuples.
labels = [
{"namespace", "loki"},
{"region", "us-east-1"}
]
@type request() :: Logproto.PushRequest.t()
@type stream() :: Logproto.StreamAdapter.t()
@type timestamp() :: Google.Protobuf.Timestamp.t()
Link to this section Functions
@spec entry(term(), DateTime.t() | NaiveDateTime.t() | timestamp()) :: entry()
Returns an entry, which is a log line/string at a given time. The timestamp can be of type DateTime, NaiveDateTime, or Google.Protobuf.Timestamp. If no timestamp is provided, the current time is used.
entry1 = Sleipnir.entry("I am a log line") entry2 = Sleipnir.entry("I am also a log line", DateTime.utc_now())
Creates a PushRequest from one or more streams.
request = Sleipnir.request(stream)
A stream consists of one or more entries under a common set of labels.
stream = Sleipnir.stream([entry1, entry2], [{"label", "value"}])
@spec stream( labels(), String.t(), DateTime.t() | NaiveDateTime.t() | timestamp() ) :: stream()
Returns a stream for a single entry from a line and timestamp. To create a stream of multiple entries, take a look at stream/2.