Skip to content
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

Slightly improve UX around passing --metrics #22888

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/cmdref/cilium-agent.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Documentation/helm-values.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion daemon/cmd/daemon_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func initializeFlags() {
flags.MarkHidden(option.MaxCtrlIntervalName)
option.BindEnv(Vp, option.MaxCtrlIntervalName)

flags.StringSlice(option.Metrics, []string{}, "Metrics that should be enabled or disabled from the default metric list. (+metric_foo to enable metric_foo , -metric_bar to disable metric_bar)")
flags.StringSlice(option.Metrics, []string{}, "Metrics that should be enabled or disabled from the default metric list. The list is expected to be separated by a space. (+metric_foo to enable metric_foo , -metric_bar to disable metric_bar)")
option.BindEnv(Vp, option.Metrics)

flags.Bool(option.EnableMonitorName, true, "Enable the monitor unix domain socket server")
Expand Down
2 changes: 1 addition & 1 deletion install/kubernetes/cilium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ contributors across the globe, there is almost always someone available to help.
| preflight.validateCNPs | bool | `true` | By default we should always validate the installed CNPs before upgrading Cilium. This will make sure the user will have the policies deployed in the cluster with the right schema. |
| priorityClassName | string | `""` | The priority class to use for cilium-agent. |
| prometheus | object | `{"enabled":false,"metrics":null,"port":9962,"serviceMonitor":{"annotations":{},"enabled":false,"interval":"10s","labels":{},"metricRelabelings":null,"relabelings":[{"replacement":"${1}","sourceLabels":["__meta_kubernetes_pod_node_name"],"targetLabel":"node"}]}}` | Configure prometheus metrics on the configured port at /metrics |
| prometheus.metrics | string | `nil` | Metrics that should be enabled or disabled from the default metric list. (+metric_foo to enable metric_foo , -metric_bar to disable metric_bar). ref: https://docs.cilium.io/en/stable/operations/metrics/#exported-metrics |
| prometheus.metrics | string | `nil` | Metrics that should be enabled or disabled from the default metric list. The list is expected to be separated by a space. (+metric_foo to enable metric_foo , -metric_bar to disable metric_bar). ref: https://docs.cilium.io/en/stable/operations/metrics/#exported-metrics |
| prometheus.serviceMonitor.annotations | object | `{}` | Annotations to add to ServiceMonitor cilium-agent |
| prometheus.serviceMonitor.enabled | bool | `false` | Enable service monitors. This requires the prometheus CRDs to be available (see https://github.com/prometheus-operator/prometheus-operator/blob/master/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml) |
| prometheus.serviceMonitor.interval | string | `"10s"` | Interval for scrape metrics. |
Expand Down
6 changes: 3 additions & 3 deletions install/kubernetes/cilium/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1586,9 +1586,9 @@ prometheus:
replacement: ${1}
# -- Metrics relabeling configs for the ServiceMonitor cilium-agent
metricRelabelings: ~
# -- Metrics that should be enabled or disabled from the default metric
# list. (+metric_foo to enable metric_foo , -metric_bar to disable
# metric_bar).
# -- Metrics that should be enabled or disabled from the default metric list.
# The list is expected to be separated by a space. (+metric_foo to enable
# metric_foo , -metric_bar to disable metric_bar).
# ref: https://docs.cilium.io/en/stable/operations/metrics/#exported-metrics
metrics: ~

Expand Down
6 changes: 3 additions & 3 deletions install/kubernetes/cilium/values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1583,9 +1583,9 @@ prometheus:
replacement: ${1}
# -- Metrics relabeling configs for the ServiceMonitor cilium-agent
metricRelabelings: ~
# -- Metrics that should be enabled or disabled from the default metric
# list. (+metric_foo to enable metric_foo , -metric_bar to disable
# metric_bar).
# -- Metrics that should be enabled or disabled from the default metric list.
# The list is expected to be separated by a space. (+metric_foo to enable
# metric_foo , -metric_bar to disable metric_bar).
# ref: https://docs.cilium.io/en/stable/operations/metrics/#exported-metrics
metrics: ~

Expand Down
3 changes: 3 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ func CreateConfiguration(metricsEnabled []string) (Configuration, []prometheus.C

for _, metricName := range metricsEnabled {
switch metricName {
default:
logrus.WithField("metric", metricName).Warning("Metric does not exist, skipping")

case Namespace + "_" + SubsystemAgent + "_api_process_time_seconds":
APIInteractions = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: Namespace,
Expand Down