Skip to content

Commit

Permalink
feat(comp/cadvisor): allow user to disable collecting root Cgroup sta…
Browse files Browse the repository at this point in the history
…ts (#5713)

Signed-off-by: hainenber <[email protected]>
  • Loading branch information
hainenber authored Nov 23, 2023
1 parent 6404d29 commit 35f7f6a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ Main (unreleased)
- Agent Management: Introduce support for templated configuration. (@jcreixell)

### Enhancements

- Flow Windows service: Support environment variables. (@jkroepke)

- Allow disabling collection of root Cgroup stats in
`prometheus.exporter.cadvisor` (flow mode) and the `cadvisor` integration
(static mode). (@hainenber)

### Bugfixes

- Permit `X-Faro-Session-ID` header in CORS requests for the `faro.receiver`
Expand Down
5 changes: 4 additions & 1 deletion component/prometheus/exporter/cadvisor/cadvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ var DefaultArguments = Arguments{
DockerTLSKey: "key.pem",
DockerTLSCA: "ca.pem",

DockerOnly: false,
DockerOnly: false,
DisableRootCgroupStats: false,
}

// Arguments configures the prometheus.exporter.cadvisor component.
Expand All @@ -66,6 +67,7 @@ type Arguments struct {
DockerTLSKey string `river:"docker_tls_key,attr,optional"`
DockerTLSCA string `river:"docker_tls_ca,attr,optional"`
DockerOnly bool `river:"docker_only,attr,optional"`
DisableRootCgroupStats bool `river:"disable_root_cgroup_stats,attr,optional"`
}

// SetToDefault implements river.Defaulter.
Expand Down Expand Up @@ -103,6 +105,7 @@ func (a *Arguments) Convert() *cadvisor.Config {
DockerTLSKey: a.DockerTLSKey,
DockerTLSCA: a.DockerTLSCA,
DockerOnly: a.DockerOnly,
DisableRootCgroupStats: a.DisableRootCgroupStats,
}

return cfg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ func toCadvisorExporter(config *cadvisor_integration.Config) *cadvisor.Arguments
DockerTLSKey: config.DockerTLSKey,
DockerTLSCA: config.DockerTLSCA,
DockerOnly: config.DockerOnly,
DisableRootCgroupStats: config.DisableRootCgroupStats,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Name | Type | Description | Default | Required
`docker_tls_key` | `string` | Path to private key for TLS connection to docker. | `key.pem` | no
`docker_tls_ca` | `string` | Path to a trusted CA for TLS connection to docker. | `ca.pem` | no
`docker_only` | `bool` | Only report docker containers in addition to root stats. | `false` | no
`disable_root_cgroup_stats` | `bool` | Disable collecting root Cgroup stats. | `false` | no

For `allowlisted_container_labels` to take effect, `store_container_labels` must be set to `false`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,7 @@ Full reference of options:

# Only report docker containers in addition to root stats
[docker_only: <boolean> | default = false]

# Disable collecting root Cgroup stats
[disable_root_cgroup_stats: <boolean> | default = false]
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ replace (
// TODO(tpaschalis) this is to remove global instantiation of plugins
// and allow non-singleton components.
// https://github.com/grafana/cadvisor/tree/grafana-v0.47-noglobals
github.com/google/cadvisor => github.com/grafana/cadvisor v0.0.0-20230927082732-0d72868a513e
github.com/google/cadvisor => github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea

// TODO(mattdurham): this is so you can debug on windows, when PR is merged into perflib, can you use that
// and eventually remove if windows_exporter shifts to it. https://github.com/leoluk/perflib_exporter/pull/43
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,8 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gosnmp/gosnmp v1.36.0 h1:1Si+MImHcKIqFc3/kJEs2LOULP1nlFKlzPFyrMOk5Qk=
github.com/gosnmp/gosnmp v1.36.0/go.mod h1:iLcZxN2MxKhH0jPQDVMZaSNypw1ykqVi27O79koQj6w=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/grafana/cadvisor v0.0.0-20230927082732-0d72868a513e h1:hCYDh2cmnNFAjwcMlrSuptDZqjXUc3he4h61/xL/ANY=
github.com/grafana/cadvisor v0.0.0-20230927082732-0d72868a513e/go.mod h1:XjiOCFjmxXIWwauV5p39Mr2Yxlpyk72uKQH1UZvd4fQ=
github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea h1:Q5f5/nJJ0SbusZjA6F6XkJuHDbl2/PqdTGw6wHsuccA=
github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea/go.mod h1:XjiOCFjmxXIWwauV5p39Mr2Yxlpyk72uKQH1UZvd4fQ=
github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04 h1:tG8Qxq4dN1WqakMmsPaxaH4+OQhYg5HVsarw5acLBX8=
github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04/go.mod h1:HOnDIbkxfvVlDM5FBujt0uawGLfdpdTeqE7fIwfBmQk=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I=
Expand Down
3 changes: 2 additions & 1 deletion pkg/integrations/cadvisor/cadvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func New(logger log.Logger, c *Config) (integrations.Integration, error) {
}

rawOpts := raw.Options{
DockerOnly: c.DockerOnly,
DockerOnly: c.DockerOnly,
DisableRootCgroupStats: c.DisableRootCgroupStats,
}
rm, err := manager.New(plugins, memoryStorage, sysFs, manager.HousekeepingConfigFlags, includedMetrics, &collectorHTTPClient, c.RawCgroupPrefixAllowlist, c.EnvMetadataAllowlist, c.PerfEventsConfig, time.Duration(c.ResctrlInterval), rawOpts)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/integrations/cadvisor/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var DefaultConfig = Config{

// Raw config defaults
DockerOnly: false,

DisableRootCgroupStats: false,
}

// Config controls cadvisor
Expand Down Expand Up @@ -91,6 +93,9 @@ type Config struct {
// DockerOnly only report docker containers in addition to root stats
DockerOnly bool `yaml:"docker_only,omitempty"`

// DisableRootCgroupStats informs the exporter not collecting stats from the root cgroup.
DisableRootCgroupStats bool `yaml:"disable_root_cgroup_stats,omitempty"`

// Hold on to the logger passed to config.NewIntegration, to be passed to klog, as yet another unsafe global that needs to be set.
logger log.Logger //nolint:unused,structcheck // logger is only used on linux
}
Expand Down

0 comments on commit 35f7f6a

Please sign in to comment.