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 active_series_additional_custom_trackers config option #10428

Merged
merged 10 commits into from
Jan 16, 2025

Conversation

pracucci
Copy link
Collaborator

@pracucci pracucci commented Jan 13, 2025

What this PR does

At Grafana Labs we do an extensive usage of active_series_custom_trackers and we've configured many of them.

Typically, we define active_series_custom_trackers for all tenants using CLI flags. In few cases, we have per-tenant overrides. When we have per-tenant overrides, we re-define active_series_custom_trackers using YAML and the per-tenant config is typically the default trackers + few additional ones that are tenant specific.

This means that the per-tenant config of active_series_custom_trackers is essentially a copy-paste of the default ones + few extra ones. This bloat the YAML config file with a bunch of trackers that are actually just the default ones.

In this PR I propose to add another config option called active_series_additional_custom_trackers. The idea is that we can use active_series_additional_custom_trackers to configure the few extra per-tenant trackers only, and we keep having the default ones only configured through active_series_custom_trackers.

Manual tests

I've tested it locally and looks working. In the screenshot below you can see a local Mimir cluster where I've configured the "base" trackers first, and then I've modified the runtime config to add the "additional" trackers too. The gap in the metrics is during the cortex_ingester_active_series_loading (I've configured a 1m idle timeout for active series, to quickly test it):

Screenshot 2025-01-13 at 16 18 18

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@pracucci pracucci requested review from tacole02 and a team as code owners January 13, 2025 15:24
Copy link
Contributor

github-actions bot commented Jan 13, 2025

💻 Deploy preview deleted.

)

// Cache it.
o.getOverridesForUser(userID).activeSeriesMergedCustomTrackersConfig = &merged
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks racy 🤔 Shouldn't we coordinate the access here and above where we're reading it?

Copy link
Collaborator Author

@pracucci pracucci Jan 16, 2025

Choose a reason for hiding this comment

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

You're right, it's racy and I missed it. I pushed an option to fix the race and added an high-level unit test (TestRuntimeConfigLoader_ActiveSeriesCustomTrackersMergingShouldNotInterfereBetweenTenants) to gain better confidence. I also added a unit test for the race, that fails with the previous code (when running with -race).

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -3368,6 +3368,19 @@ The `limits` block configures default and per-tenant limits imposed by component
# CLI flag: -ingester.active-series-custom-trackers
[active_series_custom_trackers: <map of tracker name (string) to matcher (string)> | default = ]

# (advanced) Additional custom trackers for active metrics merged on top of the
# custom trackers. This configuration option can be useful to define the base
Copy link
Contributor

Choose a reason for hiding this comment

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

Does merged on top of the custom trackers refer to preexisting trackers? If so, we should specify this for clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

Reading the rest of this, it looks like that are merged on top of base custom trackers? I think we should say that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes your understanding is correct. I've addressed it in b66faea

@pracucci pracucci force-pushed the prototype-additional-custom-trackers branch from 187d2a7 to 877b9ab Compare January 16, 2025 10:45
@pracucci pracucci marked this pull request as draft January 16, 2025 10:57
@pracucci pracucci marked this pull request as ready for review January 16, 2025 13:19
Signed-off-by: Marco Pracucci <[email protected]>
@@ -402,6 +407,11 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) {
// Ingest storage.
f.StringVar(&l.IngestStorageReadConsistency, "ingest-storage.read-consistency", api.ReadConsistencyEventual, fmt.Sprintf("The default consistency level to enforce for queries when using the ingest storage. Supports values: %s.", strings.Join(api.ReadConsistencies, ", ")))
f.IntVar(&l.IngestionPartitionsTenantShardSize, "ingest-storage.ingestion-partition-tenant-shard-size", 0, "The number of partitions a tenant's data should be sharded to when using the ingest storage. Tenants are sharded across partitions using shuffle-sharding. 0 disables shuffle sharding and tenant is sharded across all partitions.")

// Ensure the pointer holder is initialized.
if l.activeSeriesMergedCustomTrackersConfig == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The fact that we have to check this here is confusing, but I'll trust that you added this because you saw the need 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's not necessary. I removed it (after manual testing the removal).

Copy link
Contributor

@colega colega left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

Signed-off-by: Marco Pracucci <[email protected]>
@pracucci pracucci merged commit 12c09fd into main Jan 16, 2025
31 checks passed
@pracucci pracucci deleted the prototype-additional-custom-trackers branch January 16, 2025 14:37
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.

3 participants