-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
7d91e50
to
f298a48
Compare
3b6e36b
to
9eaa547
Compare
@@ -86,6 +86,16 @@ func (s *dummyService) GetCheckNames() []string { | |||
return s.CheckNames | |||
} | |||
|
|||
// IsMetricExcluded returns false | |||
func (s *dummyService) IsMetricExcluded() bool { |
There was a problem hiding this comment.
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 {
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed 👍
ed336d9
to
b1c9e0a
Compare
func (s *DockerService) IsExcluded(filter containers.FilterType) bool { | ||
switch filter { | ||
case containers.Metrics: | ||
return s.metricsExcluded | ||
case containers.Logs: | ||
return s.logsExcluded | ||
} | ||
return false | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do 👍
There was a problem hiding this 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!
pkg/util/containers/types.go
Outdated
type FilterType string | ||
|
||
// Global is used to cover both Metrics and Logs filter types | ||
const Global FilterType = "Global" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
func (s *DockerService) IsExcluded(filter containers.FilterType) bool { | ||
switch filter { | ||
case containers.Metrics: | ||
return s.metricsExcluded | ||
case containers.Logs: | ||
return s.logsExcluded | ||
} | ||
return false | ||
} |
There was a problem hiding this comment.
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
.
b1c9e0a
to
4be1394
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
What does this PR do?
container_include_metrics
container_exclude_metrics
container_include_logs
container_exclude_logs
ac_include
andac_exclude
bycontainer_include
andcontainer_exclude
and ensure backward compatibilityMotivation
More flexible AD filtering
Additional Notes
Brief explanation of the expected behaviour
container_exclude
, the AD listener ignores it and doesn't create the AD servicecontainer_exclude
but matchescontainer_exclude_metrics
orcontainer_exclude_logs