-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Adds whitelisting of docker labels [#1730] #1735
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
Changes from all commits
695b50a
9c73513
25b79f0
261ea7e
466f015
310d26d
33f84c4
041a81b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,16 @@ From [glog](https://github.com/golang/glog) here are some flags we find useful: | |
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging | ||
``` | ||
|
||
## Labels | ||
|
||
Both Docker and Rkt labels support restricting the amount of labels collected by `cadvisor`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would omit runtimes here as well: " |
||
|
||
``` | ||
--enforce_label_whitelist=false: whether or not to enforce whitelisting of labels | ||
--label_whitelist="": comma-separated list of label keys that are allowed to be collected | ||
``` | ||
|
||
|
||
## Docker | ||
|
||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ import ( | |
|
||
var globalHousekeepingInterval = flag.Duration("global_housekeeping_interval", 1*time.Minute, "Interval between global housekeepings") | ||
var logCadvisorUsage = flag.Bool("log_cadvisor_usage", false, "Whether to log the usage of the cAdvisor container") | ||
var enforceLabelWhitelist = flag.Bool("enforce_label_whitelist", false, "enforces label whitelisting") | ||
var labelWhitelist = flag.String("label_whitelist", "", "comma-separated list of label keys that are allowed to be collected for docker and rkt containers") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont specify the runtime here: ... "collected for containers" |
||
var eventStorageAgeLimit = flag.String("event_storage_age_limit", "default=24h", "Max length of time for which to store events (per type). Value is a comma separated list of key values, where the keys are event types (e.g.: creation, oom) or \"default\" and the value is a duration. Default is applied to all non-specified event types") | ||
var eventStorageEventLimit = flag.String("event_storage_event_limit", "default=100000", "Max number of events to store (per type). Value is a comma separated list of key values, where the keys are event types (e.g.: creation, oom) or \"default\" and the value is an integer. Default is applied to all non-specified event types") | ||
var applicationMetricsCountLimit = flag.Int("application_metrics_count_limit", 100, "Max number of application metrics to store (per container)") | ||
|
@@ -255,12 +257,14 @@ type manager struct { | |
|
||
// Start the container manager. | ||
func (self *manager) Start() error { | ||
err := docker.Register(self, self.fsInfo, self.ignoreMetrics) | ||
labelsWhiteList := strings.Split(*labelWhitelist, ",") | ||
|
||
err := docker.Register(self, self.fsInfo, self.ignoreMetrics, *enforceLabelWhitelist, labelsWhiteList) | ||
if err != nil { | ||
glog.Warningf("Docker container factory registration failed: %v.", err) | ||
} | ||
|
||
err = rkt.Register(self, self.fsInfo, self.ignoreMetrics) | ||
err = rkt.Register(self, self.fsInfo, self.ignoreMetrics, *enforceLabelWhitelist, labelsWhiteList) | ||
if err != nil { | ||
glog.Warningf("Registration of the rkt container factory failed: %v", err) | ||
} else { | ||
|
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.
nit: condense this
if labelValue, present := ctnr.Config.Labels[exposedLabel]; present {
handler.labels[exposedLabel] = labelValue
}