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 support for Alloy as monitoring agent #62

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

TheoBrigitte
Copy link
Member

Towards: giantswarm/roadmap#3522

This PR add support for Alloy to be used as monitoring agent instead of Prometheus Agent. This is configurable via the --monitoring-agent flag in the observability-operator.

The operator will then disable Prometheus Agent and enable Alloy (the opposite is also possible) app via the observability-bundle config.

@TheoBrigitte TheoBrigitte self-assigned this Aug 6, 2024
@TheoBrigitte TheoBrigitte requested a review from a team as a code owner August 6, 2024 17:07
switch s.config.MonitoringAgent {
case common.MonitoringAgentPrometheus:
bundleConfiguration.Apps[common.MonitoringPrometheusAgentAppName] = app{
Enabled: s.config.IsMonitored(cluster),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this Can bé simplified without the Switch with: s.config.IsMonitored(cluster) && common.MonitoringAgentPrometheus == s.config.MonitoringAgent. this would definitely reduce duplication

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to keep the Switch, maybe move the bundleConfiguration.Apps outside thé Switch?

Copy link
Contributor

Choose a reason for hiding this comment

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

You could use a function liké enableApp or disabledApp instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

This implementation make it clear what is happening each case. I don't see how I can move bundleConfiguration outside the switch. Also I would rather not add a function which would obfuscate the behavior here.
If you feel like making a suggestion do it via github suggestion because I am having a hard time to grasp what you have in mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, i'll try 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Having a validation in main.go would be nice and allow to fail early, but here we would still need to handle all possible different values for the logging agent.

Merging the observability and logging operator would require major refactoring so I would rather leave this for later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well if you add validation in main.go then you can change thé metricAgent type to an enum type with only 2 allowed values, alloy and prometheusAgent so you don't need a Switch but an if else right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, you need to check the current observability bundle app version supports alloy right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the check to ensure observability bundle support alloy as monitoring agent.

I rather keep the switch as is for now and not add enum, it's safer with enum true, but still we have a case where multiple values are possible and I prefer to handle all cases including when the value is not what's expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with that for now then :)

switch s.config.MonitoringAgent {
case common.MonitoringAgentPrometheus:
bundleConfiguration.Apps[common.MonitoringPrometheusAgentAppName] = app{
Enabled: s.config.IsMonitored(cluster),
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to keep the Switch, maybe move the bundleConfiguration.Apps outside thé Switch?

switch s.config.MonitoringAgent {
case common.MonitoringAgentPrometheus:
bundleConfiguration.Apps[common.MonitoringPrometheusAgentAppName] = app{
Enabled: s.config.IsMonitored(cluster),
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use a function liké enableApp or disabledApp instead?

@@ -30,6 +30,12 @@ const (

GCPManagedClusterKind = "GCPManagedCluster"
GCPManagedClusterKindProvider = "gke"

MonitoringAgentPrometheus = "prometheus-agent"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe they should bé in thé monitoring config and not in common?

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this into a new common/monitoring package, I keep this into a separate package to avoid later circular import problem with the upcoming implementation.

@TheoBrigitte
Copy link
Member Author

Can we go with this PR then @giantswarm/team-atlas ?

@TheoBrigitte TheoBrigitte merged commit 564986a into main Aug 12, 2024
6 checks passed
@TheoBrigitte TheoBrigitte deleted the monitoring-agent-toggle branch August 12, 2024 10: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.

2 participants