Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicAuthCredentials ¶ added in v1.0.1
BasicAuthCredentials is a structure that holds a username and a password. to be used for HTTP queries.
type DynamicLabelProviderFunc ¶
DynamicLabelProviderFunc defines the func for providing custom dynamic labels https://grafana.com/docs/loki/latest/best-practices/#use-dynamic-labels-sparingly
type LokiHook ¶
type LokiHook struct {
// contains filtered or unexported fields
}
LokiHook sends logs to Loki via HTTP.
func NewLokiHook ¶
NewLokiHook creates a Loki hook for logrus if no levels are provided, then logrus.AllLevels is used
func NewLokiHookWithOpts ¶
func NewLokiHookWithOpts(host string, opts LokiHookOptions, levels ...logrus.Level) *LokiHook
NewLokiHookWithOpts creates a Loki hook for logrus with the specified LokiHookOptions if no levels are provided, then logrus.AllLevels is used
type LokiHookOptions ¶
type LokiHookOptions interface { // LevelMap returns the map of logrus.Levels and custom log level values LevelMap() LevelMap // StaticLabels returns the static labels added to the loki log stream StaticLabels() Labels // DynamicLabelProvider returns the DynamicLabelProviderFunc used to populate a log entry with dynamic labels DynamicLabelProvider() DynamicLabelProviderFunc // HttpClient returns the http.Client to be used for pushing logs to loki HttpClient() *http.Client // Formatter returns the logrus.Formatter to be used when writing log entries Formatter() logrus.Formatter // BasicAuth returns the basic authentication credentials to be used // when connecting to Loki. // nil means that no credentials should be used. BasicAuth() *BasicAuthCredentials // WithLevelMap allows for logrus.Levels to be re-mapped to a different label value WithLevelMap(LevelMap) LokiHookOptions // WithStaticLabels allow for multiple static labels to be added to the loki log stream // These should be preferred over dynamic labels: // https://grafana.com/docs/loki/latest/best-practices/#static-labels-are-good WithStaticLabels(Labels) LokiHookOptions // WithDynamicLabelProvider allows for dynamic labels to be added to log entries // Dynamic labels should be used sparingly: // https://grafana.com/docs/loki/latest/best-practices/#use-dynamic-labels-sparingly WithDynamicLabelProvider(DynamicLabelProviderFunc) LokiHookOptions // WithHttpClient allows for a custom http.Client to be used for pushing logs to loki // By default, the http.DefaultClient will be used WithHttpClient(*http.Client) LokiHookOptions // WithFormatter allows for a custom logrus.Formatter to be used when writing log entries // By default, the logrus.TextFormatter will be used WithFormatter(logrus.Formatter) LokiHookOptions // WithBasicAuth allows to set a username and password to use when writing to the remote Loki host. WithBasicAuth(username, password string) LokiHookOptions }
LokiHookOptions allows for the behaviour of the LokiHook to be customised
func NewLokiHookOptions ¶
func NewLokiHookOptions() LokiHookOptions
Click to show internal directories.
Click to hide internal directories.