Skip to content

Commit 0c046a0

Browse files
committed
feat: make default event severity filter configurable
Add a configuration option to set the default state of the events warning filter. Configurable via Helm chart value 'config.events.warningsOnly' or backend flag '-filters-warnings-only'. The frontend reads this value as the default if the user has not set a preference. Signed-off-by: zyzzmohit <mohitray949@gmail.com>
1 parent 51c2b8b commit 0c046a0

File tree

59 files changed

+5448
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5448
-22
lines changed

backend/cmd/headlamp.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const (
9797
type clientConfig struct {
9898
Clusters []Cluster `json:"clusters"`
9999
IsDynamicClusterEnabled bool `json:"isDynamicClusterEnabled"`
100+
PrometheusEndpoint string `json:"prometheusEndpoint"`
101+
FiltersWarningsOnly bool `json:"filtersWarningsOnly"`
100102
}
101103

102104
type OauthConfig struct {
@@ -1750,7 +1752,12 @@ func parseClusterFromKubeConfig(kubeConfigs []string) ([]Cluster, []error) {
17501752
func (c *HeadlampConfig) getConfig(w http.ResponseWriter, r *http.Request) {
17511753
w.Header().Set("Content-Type", "application/json")
17521754

1753-
clientConfig := clientConfig{c.getClusters(), c.EnableDynamicClusters}
1755+
clientConfig := clientConfig{
1756+
Clusters: c.getClusters(),
1757+
IsDynamicClusterEnabled: c.EnableDynamicClusters,
1758+
PrometheusEndpoint: c.PrometheusEndpoint,
1759+
FiltersWarningsOnly: c.FiltersWarningsOnly,
1760+
}
17541761

17551762
if err := json.NewEncoder(w).Encode(&clientConfig); err != nil {
17561763
logger.Log(logger.LevelError, nil, err, "encoding config")

backend/cmd/stateless.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ func (c *HeadlampConfig) parseKubeConfig(w http.ResponseWriter, r *http.Request)
178178
return
179179
}
180180

181-
clientConfig := clientConfig{contexts, c.EnableDynamicClusters}
181+
clientConfig := clientConfig{
182+
Clusters: contexts,
183+
IsDynamicClusterEnabled: c.EnableDynamicClusters,
184+
PrometheusEndpoint: c.PrometheusEndpoint,
185+
FiltersWarningsOnly: c.FiltersWarningsOnly,
186+
}
182187

183188
if err := json.NewEncoder(w).Encode(&clientConfig); err != nil {
184189
logger.Log(logger.LevelError, nil, err, "encoding config")

backend/pkg/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ type Config struct {
8282
UseOTLPHTTP *bool `koanf:"use-otlp-http"`
8383
StdoutTraceEnabled *bool `koanf:"stdout-trace-enabled"`
8484
SamplingRate *float64 `koanf:"sampling-rate"`
85+
// FiltersWarningsOnly is the default state of the events filter (true = only warnings, false = all events).
86+
FiltersWarningsOnly bool `koanf:"filters-warnings-only"`
8587
// TLS config
8688
TLSCertPath string `koanf:"tls-cert-path"`
8789
TLSKeyPath string `koanf:"tls-key-path"`
@@ -448,6 +450,7 @@ func addGeneralFlags(f *flag.FlagSet) {
448450
f.Uint("port", defaultPort, "Port to listen from")
449451
f.String("proxy-urls", "", "Allow proxy requests to specified URLs")
450452
f.Bool("enable-helm", false, "Enable Helm operations")
453+
f.Bool("filters-warnings-only", true, "Whether to filter events by warnings only by default")
451454
}
452455

453456
func addOIDCFlags(f *flag.FlagSet) {

backend/pkg/headlampconfig/headlampConfig.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ type HeadlampCFG struct {
6363
TLSCertPath string
6464
TLSKeyPath string
6565
SessionTTL int
66+
PrometheusEndpoint string
67+
FiltersWarningsOnly bool
6668
}

charts/headlamp/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ spec:
325325
{{- with .Values.config.tlsKeyPath }}
326326
- "-tls-key-path={{ . }}"
327327
{{- end }}
328+
- "-filters-warnings-only={{ .Values.config.events.warningsOnly }}"
328329
{{- with .Values.config.extraArgs }}
329330
{{- toYaml . | nindent 12 }}
330331
{{- end }}

charts/headlamp/tests/expected_templates/azure-oidc-with-validators.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ spec:
129129
- "-oidc-validator-client-id=$(OIDC_VALIDATOR_CLIENT_ID)"
130130
# Check if validatorIssuerURL is non empty either from env or oidc.config
131131
- "-oidc-validator-idp-issuer-url=$(OIDC_VALIDATOR_ISSUER_URL)"
132+
- "-filters-warnings-only=true"
132133
ports:
133134
- name: http
134135
containerPort: 4466

charts/headlamp/tests/expected_templates/default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ spec:
114114
- "-plugins-dir=/headlamp/plugins"
115115
- "-session-ttl=86400"
116116
# Check if externalSecret is disabled
117+
- "-filters-warnings-only=true"
117118
ports:
118119
- name: http
119120
containerPort: 4466

charts/headlamp/tests/expected_templates/extra-args.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ spec:
114114
- "-plugins-dir=/headlamp/plugins"
115115
- "-session-ttl=86400"
116116
# Check if externalSecret is disabled
117+
- "-filters-warnings-only=true"
117118
- -insecure-ssl
118119
ports:
119120
- name: http

charts/headlamp/tests/expected_templates/extra-manifests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ spec:
131131
- "-plugins-dir=/headlamp/plugins"
132132
- "-session-ttl=86400"
133133
# Check if externalSecret is disabled
134+
- "-filters-warnings-only=true"
134135
ports:
135136
- name: http
136137
containerPort: 4466

charts/headlamp/tests/expected_templates/host-users-override.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ spec:
114114
- "-plugins-dir=/headlamp/plugins"
115115
- "-session-ttl=86400"
116116
# Check if externalSecret is disabled
117+
- "-filters-warnings-only=true"
117118
ports:
118119
- name: http
119120
containerPort: 4466

0 commit comments

Comments
 (0)