Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LabelNamesForMetricName for the series store #1346

Merged
merged 4 commits into from
Jul 8, 2019

Conversation

cyriltovena
Copy link
Contributor

This adds LabelNamesForMetricName for the series store only, I wanted to first get your feedback if this seems correct.

  • I'm getting all series ids for a given metric name
  • lookupSingleChunkBySeries which takes the first index query and lookup index entries then take the first index entry and parse the chunk key.
  • fetch a single chunk for each series
  • merge all label names possible except metric name.

I would like a special attention to that lookupSingleChunkBySeries and its usage, not sure if this is the right way to approach the problem. (May be I should loop though queries and entries until I get a result ?)

I still need to implement this for the chunk store but I'm not sure what would be the most efficient way of doing this.

The PR is rebased on my other work to include the split of the time range validation. So don't mind the two other commit they won't be part of this PR.

Thank you !

@cyriltovena
Copy link
Contributor Author

/cc @gouthamve @jtlisi

@cyriltovena cyriltovena force-pushed the chunkstore-labelnames branch from ebb2661 to d6f9991 Compare April 24, 2019 01:38
@bboreham
Copy link
Contributor

Seems kinda gross 😬
I can't think of a better way to do it in the current schema; maybe we should think again about writing this data to the index (e.g. a metricname->labelnames row).

Back with the code as you have it, it may be worthwhile to pass a hint down to the DB interface that you only want one chunk, and/or avoid reading the same series across multiple day buckets.

@cyriltovena cyriltovena force-pushed the chunkstore-labelnames branch from d6f9991 to a4dd657 Compare April 24, 2019 14:17
@cyriltovena
Copy link
Contributor Author

So I tried another implementation, I'm fetching all index but only one chunk per metric fingerprint.

I had to create two implementation to make it works (series+chunk store)

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena cyriltovena force-pushed the chunkstore-labelnames branch from a4dd657 to 813c1b8 Compare June 7, 2019 14:47
@cyriltovena
Copy link
Contributor Author

cyriltovena commented Jun 7, 2019

I've rebased my branch, I think this is good to go.

@gouthamve @tomwilkie @jtlisi @cstyan : I would really love to get that fix for Loki, been sitting here for a month already.

Copy link
Contributor

@cstyan cstyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few comments, don't know enough about the chunk storage to 👍 though

pkg/chunk/chunk_store_utils.go Outdated Show resolved Hide resolved
pkg/chunk/chunk_store.go Outdated Show resolved Hide resolved
pkg/chunk/chunk_store.go Show resolved Hide resolved
pkg/chunk/chunk_store.go Outdated Show resolved Hide resolved
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena
Copy link
Contributor Author

please @tomwilkie @bboreham would you be able to take a look ? From my point of view this is good to go.

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok. I'm a bit disappointed with the amount of repetition, but it isn't obviously easy to refactor.

Did worry about the efficiency of dedupe.

return nil, err
}
var result []string
for _, c := range allChunks {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit seems likely to be inefficient - most chunks will have the same label names, but potentially thousands of unique fingerprints, so you will add thousands of copies of the same string then sort them then dedupe them.
Suggest using a map instead.

Copy link
Contributor Author

@cyriltovena cyriltovena Jul 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actuallyI'm only fetching a single chunk per unique fingerprints 257:

	filtered, keys := filterChunksByUniqueFingerprint(filtered)

but you're right unique fingerprint can have many label name duplicate. I'll improve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voila !

pkg/chunk/series_store.go Outdated Show resolved Hide resolved
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@tomwilkie
Copy link
Contributor

LGTM from me!

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bboreham bboreham merged commit ef492f6 into cortexproject:master Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants