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

receiver: Add hot reload for relabel configs #124

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

abhijith-db
Copy link

@abhijith-db abhijith-db commented Feb 3, 2025

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

  • Receiver to hot reload the relabel configs file. Implementation is similar to the receiever limits config file which already supports hot reload.

Verification

  • Unit tests
  • Deployed to dev-aws-us-east-1-obs-integrationtest
    • no Crash Loop
  • Deployed to dev-azure-westus
    • No crash loop, alerts firing

@@ -143,14 +137,6 @@ func NewLimiterWithOptions(
Help: "How many times the limit configuration failed to reload.",
},
)
limiter.configReloadFailedCounter = promauto.With(limiter.registerer).NewCounter(
Copy link
Author

Choose a reason for hiding this comment

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

Removed because this is present twice here (see line 138 just above)

@abhijith-db abhijith-db assigned jnyi and hczhu-db and unassigned jnyi and hczhu-db Feb 3, 2025
Copy link
Collaborator

@jnyi jnyi left a comment

Choose a reason for hiding this comment

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

TSDBStats: dbs,
Limiter: limiter,

Writer: writer,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: no change happens here right?

Copy link
Author

Choose a reason for hiding this comment

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

yes only whitespace changes by gofmt that does some kind of alignment of the fields.

@@ -1073,6 +1086,8 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
rc.maxBackoff = extkingpin.ModelDuration(cmd.Flag("receive-forward-max-backoff", "Maximum backoff for each forward fan-out request").Default("5s").Hidden())

rc.relabelConfigPath = extflag.RegisterPathOrContent(cmd, "receive.relabel-config", "YAML file that contains relabeling configuration.", extflag.WithEnvSubstitution())
cmd.Flag("receive.relabel-config-reload-timer", "Minimum amount of time to pass for the relabel configuration to be reloaded. Helps to avoid excessive reloads.").
Default("1s").Hidden().DurationVar(&rc.relabelConfigReloadTimer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

default 1s could be excessive, let's do 5m for default, i assume the relabel config should not change that frequently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1
Can we have a default value that disables this feature?

Copy link
Author

Choose a reason for hiding this comment

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

Ok. I went by the same value as for the limiters config file that is reloaded every 1s by default.

cmd.Flag("receive.limits-config-reload-timer", "Minimum amount of time to pass for the limit configuration to be reloaded. Helps to avoid excessive reloads.").

Copy link
Author

Choose a reason for hiding this comment

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

Changed default to 0 with the semantics of disabling the feature.

testutil.Ok(t, err)

// Rewrite the relabels file in temp with an invalid file, should not update the config.
testutil.Ok(t, relabelFile.Rewrite(invalidRelabels))
Copy link
Collaborator

Choose a reason for hiding this comment

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

how do we know the invalid relabels are not picked up

Copy link
Author

Choose a reason for hiding this comment

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

There is an assert below on line 56 that the value is the same as origRelabelsConfig.

@@ -1073,6 +1086,8 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
rc.maxBackoff = extkingpin.ModelDuration(cmd.Flag("receive-forward-max-backoff", "Maximum backoff for each forward fan-out request").Default("5s").Hidden())

rc.relabelConfigPath = extflag.RegisterPathOrContent(cmd, "receive.relabel-config", "YAML file that contains relabeling configuration.", extflag.WithEnvSubstitution())
cmd.Flag("receive.relabel-config-reload-timer", "Minimum amount of time to pass for the relabel configuration to be reloaded. Helps to avoid excessive reloads.").
Default("1s").Hidden().DurationVar(&rc.relabelConfigReloadTimer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1
Can we have a default value that disables this feature?

@abhijith-db abhijith-db force-pushed the abhijith-vmohan_data/hotreload-relabel-config branch from 0741201 to 7f4a0b9 Compare February 12, 2025 16:55
@abhijith-db abhijith-db requested a review from jnyi February 17, 2025 09:16
Copy link
Collaborator

@jnyi jnyi left a comment

Choose a reason for hiding this comment

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

lgtm, thank you for working on this one, please rebase your pr, I've fixed some of the failing tests in #128

@abhijith-db abhijith-db force-pushed the abhijith-vmohan_data/hotreload-relabel-config branch from 7f4a0b9 to e6fcd04 Compare February 19, 2025 03:14
@abhijith-db abhijith-db merged commit d35a00c into db_main Feb 19, 2025
14 checks passed
@abhijith-db abhijith-db deleted the abhijith-vmohan_data/hotreload-relabel-config branch February 19, 2025 04:31
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