Skip to content

[performance] label: takes 25 seconds whene cardinality >= 10w #6243

@liguozhong

Description

@liguozhong

Describe the bug
A clear and concise description of what the bug is.

/loki/api/v1/label?start=1653399718498000000&end=1653403318498000000

The slow label http handler of loki leads to a poor experience in grafana loki explore, it takes 25 seconds to load the label prompt box on the left.

level=debug ts=2022-05-25T03:16:47.274713123Z caller=series_index_store.go:95 org_id=1662_qamopdln traceID=46b14075ea76f47d series-ids=64129

level=debug ts=2022-05-25T03:16:47.275711308Z caller=series_index_store.go:390 org_id=1662_qamopdln traceID=46b14075ea76f47d msg="post intersection" matchers=1 ids=64191

code :
pkg/querier/querier.go:352
func (q *SingleTenantQuerier) Label(ctx context.Context, req *logproto.LabelRequest) (*logproto.LabelResponse, error) {
}

pkg/storage/stores/series/series_index_store.go:220
func (c *indexStore) LabelNamesForMetricName(ctx context.Context, userID string, from, through model.Time, metricName string) ([]string, error) {
}

pkg/storage/stores/series/series_index_store.go:502
func (c *indexStore) lookupEntriesByQueries(ctx context.Context, queries []index.Query) ([]index.Entry, error) {
err := c.index.QueryPages(ctx, queries, func(query index.Query, resp index.ReadBatchResult) bool {

}
}


To Reproduce
Steps to reproduce the behavior:

  1. Started Loki (SHA or version)
  2. Started Promtail (SHA or version) to tail '...'
  3. Query: {} term

Expected behavior
A clear and concise description of what you expected to happen.

Environment:

  • Infrastructure: [e.g., Kubernetes, bare-metal, laptop]
  • Deployment tool: [e.g., helm, jsonnet]

Screenshots, Promtail config, or terminal output
If applicable, add any output to help explain your problem.
image

image

image

slow
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleA stale issue or PR that will automatically be closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions