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

[target allocator] Make scrape interval configurable #1923

Merged

Conversation

swiatekm
Copy link
Contributor

@swiatekm swiatekm commented Jul 13, 2023

Resolves #1925.

I don't entirely like the fact that this only affects Prometheus CRs, but this is part of an ongoing problem where some values can logically be set both on the Collector CR and in prometheus receiver configuration.

I've tested this end-to-end and it does work.

@swiatekm swiatekm force-pushed the feat/scrape-config-configurable branch from 145e4cc to 5128c0d Compare July 14, 2023 15:39
@swiatekm swiatekm marked this pull request as ready for review July 14, 2023 16:10
@swiatekm swiatekm requested review from a team July 14, 2023 16:10
@@ -96,6 +99,12 @@ func unmarshal(cfg *Config, configFile string) error {
return nil
}

func createDefaultConfig() Config {
return Config{
CRScrapeInterval: DefaultCRScrapeInterval,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any other defaults that would be good to have here?

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. would it be better for us to just embed something like CommonPrometheusFields in the config?

Copy link
Contributor Author

@swiatekm swiatekm Jul 14, 2023

Choose a reason for hiding this comment

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

Having had a quick look through that (https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#commonprometheusfields), there's way too many that wouldn't apply to TA, or which would apply, but we'd rather set them once at the Collector level and inherit. So I think we'll need to cherry pick the ones we want, unfortunately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, you mean just for TA config, not for the spec in the CR? I guess we could do that. It'd still be a bit messy to have settable values that don't do anything, but if they're just exposed in the TA config and not the CR, it's less of a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

holy crap there are a LOT of fields in there. I think it's okay to piece meal it on second thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can open an issue to decide what we want from there, exactly. Should that block this change, though?

Copy link
Contributor

Choose a reason for hiding this comment

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

An issue would be great... and nope, definitely not blocking!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@swiatekm swiatekm force-pushed the feat/scrape-config-configurable branch 2 times, most recently from 71e9141 to cd0fe81 Compare July 17, 2023 08:56

type Config struct {
LabelSelector map[string]string `yaml:"label_selector,omitempty"`
Config *promconfig.Config `yaml:"config"`
AllocationStrategy *string `yaml:"allocation_strategy,omitempty"`
FilterStrategy *string `yaml:"filter_strategy,omitempty"`
CRScrapeInterval model.Duration `yaml:"cr_scrape_interval,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought some more about this over the weekend, and I think this may be better if we make an embedded CR config resource and that's where we'll be able to then move the incorrect Pod and Service monitor selectors to. Does that seem reasonable to you? (this issue)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, what should we name it? I'm ok with PrometheusCR for consistency, but no strong opinions. Also, should we allow enabling the functionality via the config file (currently it can only be done via a CLI flag)?

Also, do you want to move the current selector attributes, as opposed to creating new ones with the right semantics?

Copy link
Contributor

Choose a reason for hiding this comment

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

PrometheusCR makes sense. And I'm not sure I have an opinion on where the enabling should happen... i trust your judgement. And let's keep the current selector attributes where they are now, and then in a follow up make the new ones in the PrometheusCR, deprecating the current ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I left the CLIConf alone for now, it's not entirely clear what the logic should be there, and I'd rather do it in a separate PR without these other changes in the way.

@swiatekm swiatekm force-pushed the feat/scrape-config-configurable branch from cd0fe81 to 61fa119 Compare July 19, 2023 10:02
@swiatekm
Copy link
Contributor Author

FYI, the E2E upgrade test passes on my machine ™️ .

@swiatekm swiatekm requested a review from jaronoff97 July 19, 2023 13:22
Copy link
Contributor

@jaronoff97 jaronoff97 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, rerunning the tests and will merge when they pass!

@jaronoff97 jaronoff97 merged commit d1ede76 into open-telemetry:main Jul 19, 2023
@swiatekm swiatekm deleted the feat/scrape-config-configurable branch July 19, 2023 15:33
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
…1923)

* [target allocator] Make scrape interval configurable

* Put PrometheusCR config for TA in a separate structure
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.

Make the default scrape interval configurable for Target Allocator
2 participants