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

Make ephemeral storage queryable #3961

Merged
merged 8 commits into from
Jan 17, 2023
Merged

Make ephemeral storage queryable #3961

merged 8 commits into from
Jan 17, 2023

Conversation

pstibrany
Copy link
Member

What this PR does

This PR modifies ingester to allow querying of ephemeral storage. This is done by special label __storage__ that ingester recognizes. It allows two values: ephemeral or persistent. If label is not in the matchers, ingester uses it as persistent. Any other values are rejected with error.

This PR also introduces new metrics:

  • cortex_ingester_queries_ephemeral_total (based on existing cortex_ingester_queries_total)
  • cortex_ingester_queried_ephemeral_samples (based on existing cortex_ingester_queried_samples)
  • cortex_ingester_queried_ephemeral_series (based on existing cortex_ingester_queried_series)

Which issue(s) this PR fixes or relates to

This is part of #3884. Changelog entry will be added after feature is complete.

Checklist

  • Tests updated
  • Documentation added
  • [na] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pstibrany pstibrany requested a review from a team as a code owner January 16, 2023 11:10
@pstibrany pstibrany mentioned this pull request Jan 16, 2023
Copy link
Contributor

@osg-grafana osg-grafana left a comment

Choose a reason for hiding this comment

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

Approving help text.

@osg-grafana osg-grafana added the type/docs Improvements or additions to documentation label Jan 16, 2023
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
…turn empty results.

Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
@@ -107,6 +107,18 @@ const (

// Prefix used in Prometheus registry for ephemeral storage.
ephemeralPrometheusMetricsPrefix = "ephemeral_"

// Label name used to select queried storage type.
StorageLabelName = "__storage__"
Copy link
Member Author

@pstibrany pstibrany Jan 16, 2023

Choose a reason for hiding this comment

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

Shall we use something less generic, eg. __mimir_storage__ here to avoid possible conflicts?

Copy link
Contributor

Choose a reason for hiding this comment

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

since this is only an internal label which most users will never get to see, I think making it specific would be the better choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

separate topic: should we prevent the successful ingestion of this label?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also 👍 to use __mimir_storage__.

Copy link
Member Author

@pstibrany pstibrany Jan 16, 2023

Choose a reason for hiding this comment

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

should we prevent the successful ingestion of this label?

I think the risk is tiny, and it would complicate our code. I'd leave it as-is (no extra check on push).

pkg/ingester/metrics.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
@pracucci pracucci self-requested a review January 16, 2023 15:57
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

I looked at the logic and LGTM! I haven't looked at the tests (I rely on Mauro's review ;))

@@ -107,6 +107,18 @@ const (

// Prefix used in Prometheus registry for ephemeral storage.
ephemeralPrometheusMetricsPrefix = "ephemeral_"

// Label name used to select queried storage type.
StorageLabelName = "__storage__"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also 👍 to use __mimir_storage__.

Comment on lines 1378 to 1391
storageValue, matchers, err := removeStorageMatcher(matchers)
if err != nil {
return err
}

ephemeral := false
if storageValue == "" || storageValue == PersistentStorageLabelValue {
// storageValue is logged later, so set it to proper value.
storageValue = PersistentStorageLabelValue
} else if storageValue == EphemeralStorageLabelValue {
ephemeral = true
} else {
return fmt.Errorf(errInvalidStorageLabelValue, storageValue)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] To keep this function cleaner, you may consider moving all of this to a dedicated function detectStorageMatcher().

Copy link
Member Author

@pstibrany pstibrany Jan 17, 2023

Choose a reason for hiding this comment

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

I've moved check for accepted label values to removeStorageMatcherAndGetStorageType (previously removeStorageMatcher) in 2c15e15

pkg/ingester/ingester.go Outdated Show resolved Hide resolved
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

Looks great

Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM!

@pstibrany pstibrany merged commit 04b7e4b into main Jan 17, 2023
@pstibrany pstibrany deleted the ephemeral-storage-querying branch January 17, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants