-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Hubble: Adding structured format to configure Hubble Metrics #32294
base: main
Are you sure you want to change the base?
Conversation
Commit 714df89 does not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
43aa546
to
7620ed6
Compare
|
||
// DynamicMetricsConfig represents the structure used for configuring | ||
// Hubble metrics context options | ||
type DynamicMetricsConfig struct { |
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.
@chancez Can you help pre-review these structures before i start making more changes.
} | ||
} else { | ||
// temporarily handling comma separated values for labels context | ||
for _, option := range strings.Split(s, ",") { |
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.
@chancez this is a weird case, Hubble uses two kinds of delimiters "|" for the contextOptions and "," for labelcontexts.
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.
Yeah that's because we needed another delimiter for nested config within the already nested config.
857b203
to
647d81c
Compare
Signed-off-by: vakr <vakr@microsoft.com>
647d81c
to
decee4b
Compare
Values ContextValues `json:"values,omitempty" yaml:"values,omitempty"` | ||
} | ||
|
||
type ContextOptionConfigs []*ContextOptionConfig |
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: Want to group the non-struct type
s together?
|
||
type ContextOptionConfigs []*ContextOptionConfig | ||
|
||
type MetricConfig struct { |
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.
Exported struct needs comment for documentation?
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.
And some comments on the individual fields too
Metrics []*MetricConfig `json:"metrics,omitempty" yaml:"metrics,omitempty"` | ||
} | ||
|
||
func (d *DynamicMetricsConfig) GetMetricNames() map[string]struct{} { |
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.
GetMetricNames
-> MetricNames
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.
Also, why return a map? The function name suggests getting a list.
return metrics | ||
} | ||
|
||
func ParseStaticMetricsConfig(enabledMetrics []string) (metricConfigs *DynamicMetricsConfig) { |
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: Can we add an example of what an enabledMetric
may possibly look like?
type ContextValues []string | ||
|
||
// ContextOptions is a structure used for configuring Hubble metrics context options | ||
type ContextOptionConfig struct { |
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.
Could also name this ContextOptions
? Since that's the name in the ConfigMap's yaml, and it looks like there used to be a type with similar name:
Init(registry *prometheus.Registry, options Options)
@@ -25,15 +25,15 @@ type dnsHandler struct { | |||
responseTypes *prometheus.CounterVec | |||
} | |||
|
|||
func (d *dnsHandler) Init(registry *prometheus.Registry, options api.Options) error { | |||
c, err := api.ParseContextOptions(options) | |||
func (d *dnsHandler) Init(registry *prometheus.Registry, options *api.MetricConfig) error { |
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: rename all the args that used to be options api.Options
?
|
||
// DynamicMetricsConfig represents the structure used for configuring | ||
// Hubble metrics context options | ||
type DynamicMetricsConfig struct { |
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.
naming idea: ConfiguredMetrics
?
@@ -0,0 +1,26 @@ | |||
hubbleMetrics: |
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.
Is this file used anywhere yet?
@@ -146,3 +128,101 @@ var registry = NewRegistry( | |||
func DefaultRegistry() *Registry { | |||
return registry | |||
} | |||
|
|||
// FlowFilters is a slice of filters to include or exclude flows. | |||
type FlowFilters []*pb.FlowFilter |
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.
Doesn't feel necessary to introduce another type here.
Values ContextValues `json:"values,omitempty" yaml:"values,omitempty"` | ||
} | ||
|
||
type ContextOptionConfigs []*ContextOptionConfig |
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.
Not sure you need a type here, can just use []*ContextOptionConfig
where needed.
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.
Generally this looks pretty good to me. My only thought is we're kinda lacking on tests that actually deploy Hubble with metrics enabled so it's hard to feel confident in a bigger change like this not resulting in any regressions.
I'm not sure about the best approach to remedy that though. My current thinking is it might be wise to add enable metrics in our default helm values for CI (in .github/actions/helm-default/action.yaml
or ci-required-values.yaml
). That would need to be done in a separate PR though, since the changes will be ignored until they get merged into main.
This pull request has been automatically marked as stale because it |
Draft PR for intial changes to bring structured format to static string-based metrics enablement.
First PR in the series to implement, https://github.com/cilium/design-cfps/blob/main/cilium/CFP-30788-managing-hubble-metrics-cardinality.md
CFP: cilium/design-cfps#29
Todo:
2) Adding tests to the new structures
Please ensure your pull request adheres to the following guidelines:
description and a
Fixes: #XXX
line if the commit addresses a particularGitHub issue.
Fixes: <commit-id>
tag, thenplease add the commit author[s] as reviewer[s] to this issue.
Fixes: #30788