Skip to content

Commit 3b23d01

Browse files
committed
pkg/options/types.go: Adjust Set to parse new flag params
1 parent cdad26e commit 3b23d01

7 files changed

Lines changed: 96 additions & 417 deletions

File tree

docs/cli-arguments.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,34 @@ spec:
2525
```txt
2626
$ kube-state-metrics -h
2727
Usage of ./kube-state-metrics:
28-
--add_dir_header If true, adds the file directory to the header of the log messages
29-
--alsologtostderr log to standard error as well as files
30-
--apiserver string The URL of the apiserver to use as a master
31-
--enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.
32-
-h, --help Print Help text
33-
--host string Host to expose metrics on. (default "0.0.0.0")
34-
--kubeconfig string Absolute path to the kubeconfig file
35-
--labels-allow-list string list of metric names and labels you would like to allow, metric_name=[label1,labeln...],metric_name[]...
36-
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
37-
--log_dir string If non-empty, write log files in this directory
38-
--log_file string If non-empty, use this log file
39-
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
40-
--logtostderr log to standard error instead of files (default true)
41-
--metric-allowlist string Comma-separated list of metrics to be exposed. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.
42-
--metric-denylist string Comma-separated list of metrics not to be enabled. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.
43-
--namespaces string Comma-separated list of namespaces to be enabled. Defaults to ""
44-
--pod string Name of the pod that contains the kube-state-metrics container. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
45-
--pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
46-
--port int Port to expose metrics on. (default 8080)
47-
--resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments"
48-
--shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0)
49-
--skip_headers If true, avoid header prefixes in the log messages
50-
--skip_log_headers If true, avoid headers when opening log files
51-
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
52-
--telemetry-host string Host to expose kube-state-metrics self metrics on. (default "0.0.0.0")
53-
--telemetry-port int Port to expose kube-state-metrics self metrics on. (default 8081)
54-
--total-shards int The total number of shards. Sharding is disabled when total shards is set to 1. (default 1)
55-
-v, --v Level number for the log level verbosity
56-
--version kube-state-metrics build version information
57-
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
28+
--add_dir_header If true, adds the file directory to the header of the log messages
29+
--alsologtostderr log to standard error as well as files
30+
--apiserver string The URL of the apiserver to use as a master
31+
--enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.
32+
-h, --help Print Help text
33+
--host string Host to expose metrics on. (default "0.0.0.0")
34+
--kubeconfig string Absolute path to the kubeconfig file
35+
--labels-metric-allow-list string Allows to pass a list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional labels provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=["k8s-label-1","k8s-label-n",...],pods=["app"],...)'
36+
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
37+
--log_dir string If non-empty, write log files in this directory
38+
--log_file string If non-empty, use this log file
39+
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
40+
--logtostderr log to standard error instead of files (default true)
41+
--metric-allowlist string Comma-separated list of metrics to be exposed. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.
42+
--metric-denylist string Comma-separated list of metrics not to be enabled. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.
43+
--namespaces string Comma-separated list of namespaces to be enabled. Defaults to ""
44+
--pod string Name of the pod that contains the kube-state-metrics container. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
45+
--pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice.
46+
--port int Port to expose metrics on. (default 8080)
47+
--resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments"
48+
--shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0)
49+
--skip_headers If true, avoid header prefixes in the log messages
50+
--skip_log_headers If true, avoid headers when opening log files
51+
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
52+
--telemetry-host string Host to expose kube-state-metrics self metrics on. (default "0.0.0.0")
53+
--telemetry-port int Port to expose kube-state-metrics self metrics on. (default 8081)
54+
--total-shards int The total number of shards. Sharding is disabled when total shards is set to 1. (default 1)
55+
-v, --v Level number for the log level verbosity
56+
--version kube-state-metrics build version information
57+
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
5858
```

pkg/builder/types/interfaces.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,3 @@ type AllowDenyLister interface {
5454
IsIncluded(string) bool
5555
IsExcluded(string) bool
5656
}
57-
58-
// AllowLabels interface to only allow certain labels for a given metric.
59-
type AllowLabels interface {
60-
Allowed(metric string, labels, values []string) (allowedLabels, allowedValues []string)
61-
}

pkg/metric_generator/generator.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,3 @@ func FilterMetricFamilies(l allowDenyLister, families []FamilyGenerator) []Famil
120120

121121
return filtered
122122
}
123-
124-
type allowLabels interface {
125-
Allowed(metric string, labels, values []string) (allowedLabels, allowedValues []string)
126-
}
127-
128-
// FilterMetricFamiliesLabels takes a AllowLabels and a slice of metric
129-
// families and returns a filtered slice with metric families with their functions adapted to include only allowed labels for that metric Family.
130-
func FilterMetricFamiliesLabels(allowLabels allowLabels, families []FamilyGenerator) []FamilyGenerator {
131-
var filtered []FamilyGenerator
132-
for _, f := range families {
133-
generateFunc := func(familyGenerator FamilyGenerator) func(obj interface{}) *metric.Family {
134-
return func(obj interface{}) *metric.Family {
135-
metricFamily := familyGenerator.GenerateFunc(obj)
136-
137-
for _, m := range metricFamily.Metrics {
138-
m.LabelKeys, m.LabelValues = allowLabels.Allowed(familyGenerator.Name, m.LabelKeys, m.LabelValues)
139-
}
140-
return metricFamily
141-
}
142-
}(f)
143-
144-
f.GenerateFunc = generateFunc
145-
filtered = append(filtered, f)
146-
}
147-
148-
return filtered
149-
}

pkg/metric_generator/generator_test.go

Lines changed: 0 additions & 274 deletions
This file was deleted.

pkg/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (o *Options) AddFlags() {
9797
o.flags.StringVar(&o.Namespace, "pod-namespace", "", "Name of the namespace of the pod specified by --pod. "+autoshardingNotice)
9898
o.flags.BoolVarP(&o.Version, "version", "", false, "kube-state-metrics build version information")
9999
o.flags.BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.")
100-
o.flags.Var(&o.LabelsAllowList, "labels-allow-list", "list of metric names and labels you would like to allow, metric_name=[label1,labeln...],metric_name[]...")
100+
o.flags.Var(&o.LabelsAllowList, "labels-metric-allow-list", "Allows to pass a list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional labels provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=[\"k8s-label-1\",\"k8s-label-n\",...],pods=[\"app\"],...)'")
101101
}
102102

103103
// Parse parses the flag definitions from the argument list.

0 commit comments

Comments
 (0)