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

[AD] Exclude logs and metrics separately #5312

Merged
merged 2 commits into from
Apr 17, 2020

Conversation

ahmed-mez
Copy link
Contributor

What does this PR do?

  • Offers the possibility to filter out the collection of logs OR metrics separately for auto-discovered containers by introducing new filtering parameters
    • container_include_metrics
    • container_exclude_metrics
    • container_include_logs
    • container_exclude_logs
  • Replaces ac_include and ac_exclude by container_include and container_exclude and ensure backward compatibility

Motivation

More flexible AD filtering

Additional Notes

Brief explanation of the expected behaviour

  • If the AD service (container) matches container_exclude, the AD listener ignores it and doesn't create the AD service
  • If the AD service (container) doesn't match container_exclude but matches container_exclude_metrics or container_exclude_logs
    • The AD listener stores that information for the service
    • The AD config resolver passes the information to the schedulers through the config
    • Each scheduler (logs/checks) checks out the corresponding information before scheduling the config.

@ahmed-mez ahmed-mez added this to the 7.20.0 milestone Apr 9, 2020
@ahmed-mez ahmed-mez force-pushed the ahmed-mez/exclude-logs-or-metrics branch from 7d91e50 to f298a48 Compare April 9, 2020 18:27
@ahmed-mez ahmed-mez marked this pull request as ready for review April 9, 2020 19:18
@ahmed-mez ahmed-mez requested review from a team as code owners April 9, 2020 19:18
@ahmed-mez ahmed-mez force-pushed the ahmed-mez/exclude-logs-or-metrics branch 2 times, most recently from 3b6e36b to 9eaa547 Compare April 10, 2020 11:30
@@ -86,6 +86,16 @@ func (s *dummyService) GetCheckNames() []string {
return s.CheckNames
}

// IsMetricExcluded returns false
func (s *dummyService) IsMetricExcluded() bool {
Copy link
Contributor

@clamoriniere clamoriniere Apr 14, 2020

Choose a reason for hiding this comment

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

what do you think if we create only once new method but with one parameter. It can ease futur integration

func (s *dummyService) IsExcluded(types containers.FilterType) bool {
     // ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed 👍

@ahmed-mez ahmed-mez force-pushed the ahmed-mez/exclude-logs-or-metrics branch 2 times, most recently from ed336d9 to b1c9e0a Compare April 14, 2020 11:14
Comment on lines 627 to 636
func (s *DockerService) IsExcluded(filter containers.FilterType) bool {
switch filter {
case containers.Metrics:
return s.metricsExcluded
case containers.Logs:
return s.logsExcluded
}
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why we don't have container.Global in the switch case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we don't even create services that are globally excluded in AD, see https://github.com/DataDog/datadog-agent/blob/master/pkg/autodiscovery/listeners/docker.go#L221-L224 for example
it's the current behaviour, I tried to explain it more in the PR description

If the AD service (container) matches container_exclude, the AD listener ignores it and doesn't create the AD service

If the AD service (container) doesn't match container_exclude but matches container_exclude_metrics or container_exclude_logs

  • The AD listener stores that information for the service
  • The AD config resolver passes the information to the schedulers through the config
  • Each scheduler (logs/checks) checks out the corresponding information before scheduling the config.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same question as @clamoriniere. Can you add a single line comment indicating that ? For instance:

// no containers.Global case here because we don't create services that are globally excluded in AD

or something like that? Same goes in integration/config.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do 👍

clamoriniere
clamoriniere previously approved these changes Apr 16, 2020
remeh
remeh previously approved these changes Apr 17, 2020
Copy link
Contributor

@remeh remeh left a comment

Choose a reason for hiding this comment

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

Left a couple comments but nice addition!

type FilterType string

// Global is used to cover both Metrics and Logs filter types
const Global FilterType = "Global"
Copy link
Contributor

Choose a reason for hiding this comment

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

It is cosmetic but that looks weird to me to have global variables named containers.Global, containers.Metrics and containers.Logs actually being FilterType, don't you think? Not a big deal though.

I would have been with containers.GlobalFilter, containers.MetricsFilter and containers.LogsFilter I think and called IsExcluded -> HasFilter instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, will do that thanks!

Comment on lines 627 to 636
func (s *DockerService) IsExcluded(filter containers.FilterType) bool {
switch filter {
case containers.Metrics:
return s.metricsExcluded
case containers.Logs:
return s.logsExcluded
}
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same question as @clamoriniere. Can you add a single line comment indicating that ? For instance:

// no containers.Global case here because we don't create services that are globally excluded in AD

or something like that? Same goes in integration/config.go.

@ahmed-mez ahmed-mez dismissed stale reviews from remeh and clamoriniere via 4be1394 April 17, 2020 14:49
@ahmed-mez ahmed-mez force-pushed the ahmed-mez/exclude-logs-or-metrics branch from b1c9e0a to 4be1394 Compare April 17, 2020 14:49
Copy link
Contributor

@remeh remeh left a comment

Choose a reason for hiding this comment

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

👍

@ahmed-mez ahmed-mez merged commit 42cc96c into master Apr 17, 2020
@ahmed-mez ahmed-mez deleted the ahmed-mez/exclude-logs-or-metrics branch April 17, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants