Documentation
¶
Index ¶
- Constants
- Variables
- type BackoffConfig
- type Client
- type DefaultClient
- func (c *DefaultClient) CancelDeleteRequest(requestID string, force bool, quiet bool) error
- func (c *DefaultClient) CreateDeleteRequest(params DeleteRequestParams, quiet bool) error
- func (c *DefaultClient) GetDetectedFields(queryStr, fieldName string, limit, lineLimit int, start, end time.Time, ...) (*loghttp.DetectedFieldsResponse, error)
- func (c *DefaultClient) GetOrgID() string
- func (c *DefaultClient) GetStats(queryStr string, start, end time.Time, quiet bool) (*logproto.IndexStatsResponse, error)
- func (c *DefaultClient) GetVolume(query *volume.Query) (*loghttp.QueryResponse, error)
- func (c *DefaultClient) GetVolumeRange(query *volume.Query) (*loghttp.QueryResponse, error)
- func (c *DefaultClient) ListDeleteRequests(quiet bool) ([]DeleteRequest, error)
- func (c *DefaultClient) ListLabelNames(quiet bool, start, end time.Time) (*loghttp.LabelResponse, error)
- func (c *DefaultClient) ListLabelValues(name string, quiet bool, start, end time.Time) (*loghttp.LabelResponse, error)
- func (c *DefaultClient) LiveTailQueryConn(queryStr string, delayFor time.Duration, limit int, start time.Time, ...) (*websocket.Conn, error)
- func (c *DefaultClient) Query(queryStr string, limit int, time time.Time, direction logproto.Direction, ...) (*loghttp.QueryResponse, error)
- func (c *DefaultClient) QueryRange(queryStr string, limit int, start, end time.Time, direction logproto.Direction, ...) (*loghttp.QueryResponse, error)
- func (c *DefaultClient) Series(matchers []string, start, end time.Time, quiet bool) (*loghttp.SeriesResponse, error)
- type DeleteRequest
- type DeleteRequestParams
- type FileClient
- func (f *FileClient) CancelDeleteRequest(_ string, _ bool, _ bool) error
- func (f *FileClient) CreateDeleteRequest(_ DeleteRequestParams, _ bool) error
- func (f *FileClient) GetDetectedFields(_, _ string, _, _ int, _, _ time.Time, _ time.Duration, _ bool) (*loghttp.DetectedFieldsResponse, error)
- func (f *FileClient) GetOrgID() string
- func (f *FileClient) GetStats(_ string, _, _ time.Time, _ bool) (*logproto.IndexStatsResponse, error)
- func (f *FileClient) GetVolume(_ *volume.Query) (*loghttp.QueryResponse, error)
- func (f *FileClient) GetVolumeRange(_ *volume.Query) (*loghttp.QueryResponse, error)
- func (f *FileClient) ListDeleteRequests(_ bool) ([]DeleteRequest, error)
- func (f *FileClient) ListLabelNames(_ bool, _, _ time.Time) (*loghttp.LabelResponse, error)
- func (f *FileClient) ListLabelValues(name string, _ bool, _, _ time.Time) (*loghttp.LabelResponse, error)
- func (f *FileClient) LiveTailQueryConn(_ string, _ time.Duration, _ int, _ time.Time, _ bool) (*websocket.Conn, error)
- func (f *FileClient) Query(q string, limit int, t time.Time, direction logproto.Direction, _ bool) (*loghttp.QueryResponse, error)
- func (f *FileClient) QueryRange(queryStr string, limit int, start, end time.Time, direction logproto.Direction, ...) (*loghttp.QueryResponse, error)
- func (f *FileClient) Series(_ []string, _, _ time.Time, _ bool) (*loghttp.SeriesResponse, error)
- type Tripperware
Constants ¶
const ( // HTTP header keys HTTPScopeOrgID = "X-Scope-OrgID" HTTPQueryTags = "X-Query-Tags" HTTPCacheControl = "Cache-Control" HTTPCacheControlNoCache = "no-cache" )
Variables ¶
var ErrNotSupported = errors.New("not supported")
Functions ¶
This section is empty.
Types ¶
type BackoffConfig ¶
type Client ¶
type Client interface {
Query(queryStr string, limit int, time time.Time, direction logproto.Direction, quiet bool) (*loghttp.QueryResponse, error)
QueryRange(queryStr string, limit int, start, end time.Time, direction logproto.Direction, step, interval time.Duration, quiet bool) (*loghttp.QueryResponse, error)
ListLabelNames(quiet bool, start, end time.Time) (*loghttp.LabelResponse, error)
ListLabelValues(name string, quiet bool, start, end time.Time) (*loghttp.LabelResponse, error)
Series(matchers []string, start, end time.Time, quiet bool) (*loghttp.SeriesResponse, error)
LiveTailQueryConn(queryStr string, delayFor time.Duration, limit int, start time.Time, quiet bool) (*websocket.Conn, error)
GetOrgID() string
GetStats(queryStr string, start, end time.Time, quiet bool) (*logproto.IndexStatsResponse, error)
GetVolume(query *volume.Query) (*loghttp.QueryResponse, error)
GetVolumeRange(query *volume.Query) (*loghttp.QueryResponse, error)
GetDetectedFields(queryStr, fieldName string, fieldLimit, lineLimit int, start, end time.Time, step time.Duration, quiet bool) (*loghttp.DetectedFieldsResponse, error)
CreateDeleteRequest(params DeleteRequestParams, quiet bool) error
ListDeleteRequests(quiet bool) ([]DeleteRequest, error)
CancelDeleteRequest(requestID string, force bool, quiet bool) error
}
Client contains all the methods to query a Loki instance, it's an interface to allow multiple implementations.
type DefaultClient ¶
type DefaultClient struct {
TLSConfig config.TLSConfig
Username string
Password string
Address string
OrgID string
Tripperware Tripperware
BearerToken string
BearerTokenFile string
Retries int
QueryTags string
NoCache bool
AuthHeader string
ProxyURL string
BackoffConfig BackoffConfig
Compression bool
EnvironmentProxy bool
}
Client contains fields necessary to query a Loki instance
func (*DefaultClient) CancelDeleteRequest ¶ added in v3.6.0
func (c *DefaultClient) CancelDeleteRequest(requestID string, force bool, quiet bool) error
func (*DefaultClient) CreateDeleteRequest ¶ added in v3.6.0
func (c *DefaultClient) CreateDeleteRequest(params DeleteRequestParams, quiet bool) error
func (*DefaultClient) GetDetectedFields ¶ added in v3.1.0
func (*DefaultClient) GetOrgID ¶
func (c *DefaultClient) GetOrgID() string
func (*DefaultClient) GetStats ¶
func (c *DefaultClient) GetStats(queryStr string, start, end time.Time, quiet bool) (*logproto.IndexStatsResponse, error)
func (*DefaultClient) GetVolume ¶
func (c *DefaultClient) GetVolume(query *volume.Query) (*loghttp.QueryResponse, error)
func (*DefaultClient) GetVolumeRange ¶
func (c *DefaultClient) GetVolumeRange(query *volume.Query) (*loghttp.QueryResponse, error)
func (*DefaultClient) ListDeleteRequests ¶ added in v3.6.0
func (c *DefaultClient) ListDeleteRequests(quiet bool) ([]DeleteRequest, error)
func (*DefaultClient) ListLabelNames ¶
func (c *DefaultClient) ListLabelNames(quiet bool, start, end time.Time) (*loghttp.LabelResponse, error)
ListLabelNames uses the /api/v1/label endpoint to list label names
func (*DefaultClient) ListLabelValues ¶
func (c *DefaultClient) ListLabelValues(name string, quiet bool, start, end time.Time) (*loghttp.LabelResponse, error)
ListLabelValues uses the /api/v1/label endpoint to list label values
func (*DefaultClient) LiveTailQueryConn ¶
func (c *DefaultClient) LiveTailQueryConn(queryStr string, delayFor time.Duration, limit int, start time.Time, quiet bool) (*websocket.Conn, error)
LiveTailQueryConn uses /api/prom/tail to set up a websocket connection and returns it
func (*DefaultClient) Query ¶
func (c *DefaultClient) Query(queryStr string, limit int, time time.Time, direction logproto.Direction, quiet bool) (*loghttp.QueryResponse, error)
Query uses the /api/v1/query endpoint to execute an instant query excluding interfacer b/c it suggests taking the interface promql.Node instead of logproto.Direction b/c it happens to have a String() method nolint:interfacer
func (*DefaultClient) QueryRange ¶
func (c *DefaultClient) QueryRange(queryStr string, limit int, start, end time.Time, direction logproto.Direction, step, interval time.Duration, quiet bool) (*loghttp.QueryResponse, error)
QueryRange uses the /api/v1/query_range endpoint to execute a range query excluding interfacer b/c it suggests taking the interface promql.Node instead of logproto.Direction b/c it happens to have a String() method nolint:interfacer
func (*DefaultClient) Series ¶
func (c *DefaultClient) Series(matchers []string, start, end time.Time, quiet bool) (*loghttp.SeriesResponse, error)
type DeleteRequest ¶ added in v3.6.0
type DeleteRequest struct {
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Query string `json:"query"`
Status string `json:"status"`
}
DeleteRequest represents a log deletion request
type DeleteRequestParams ¶ added in v3.6.0
type DeleteRequestParams struct {
Query string `json:"query"`
Start string `json:"start,omitempty"`
End string `json:"end,omitempty"`
MaxInterval string `json:"max_interval,omitempty"`
}
DeleteRequestParams represents the parameters for creating a delete request
type FileClient ¶
type FileClient struct {
// contains filtered or unexported fields
}
FileClient is a type of LogCLI client that do LogQL on log lines from the given file directly, instead get log lines from Loki servers.
func NewFileClient ¶
func NewFileClient(r io.ReadCloser) *FileClient
NewFileClient returns the new instance of FileClient for the given `io.ReadCloser`
func (*FileClient) CancelDeleteRequest ¶ added in v3.6.0
func (f *FileClient) CancelDeleteRequest(_ string, _ bool, _ bool) error
func (*FileClient) CreateDeleteRequest ¶ added in v3.6.0
func (f *FileClient) CreateDeleteRequest(_ DeleteRequestParams, _ bool) error
func (*FileClient) GetDetectedFields ¶ added in v3.1.0
func (*FileClient) GetOrgID ¶
func (f *FileClient) GetOrgID() string
func (*FileClient) GetStats ¶
func (f *FileClient) GetStats(_ string, _, _ time.Time, _ bool) (*logproto.IndexStatsResponse, error)
func (*FileClient) GetVolume ¶
func (f *FileClient) GetVolume(_ *volume.Query) (*loghttp.QueryResponse, error)
func (*FileClient) GetVolumeRange ¶
func (f *FileClient) GetVolumeRange(_ *volume.Query) (*loghttp.QueryResponse, error)
func (*FileClient) ListDeleteRequests ¶ added in v3.6.0
func (f *FileClient) ListDeleteRequests(_ bool) ([]DeleteRequest, error)
func (*FileClient) ListLabelNames ¶
func (f *FileClient) ListLabelNames(_ bool, _, _ time.Time) (*loghttp.LabelResponse, error)
func (*FileClient) ListLabelValues ¶
func (f *FileClient) ListLabelValues(name string, _ bool, _, _ time.Time) (*loghttp.LabelResponse, error)
func (*FileClient) LiveTailQueryConn ¶
func (*FileClient) QueryRange ¶
func (*FileClient) Series ¶
func (f *FileClient) Series(_ []string, _, _ time.Time, _ bool) (*loghttp.SeriesResponse, error)
type Tripperware ¶
type Tripperware func(http.RoundTripper) http.RoundTripper
Tripperware can wrap a roundtripper.