github.com/cilium/cilium@v1.16.2/operator/metrics/cell.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package metrics 5 6 import ( 7 "github.com/cilium/hive/cell" 8 "github.com/spf13/pflag" 9 ) 10 11 const ( 12 // OperatorPrometheusServeAddr IP:Port on which to serve prometheus metrics 13 // (pass ":<port>" to bind on all interfaces). 14 OperatorPrometheusServeAddr = "operator-prometheus-serve-addr" 15 ) 16 17 // Cell provides the modular metrics registry, metric HTTP server and 18 // legacy metrics cell for the operator. 19 var Cell = cell.Module( 20 "operator-metrics", 21 "Operator Metrics", 22 23 cell.Config(defaultConfig), 24 cell.Invoke(registerMetricsManager), 25 ) 26 27 // Config contains the configuration for the operator-metrics cell. 28 type Config struct { 29 OperatorPrometheusServeAddr string 30 } 31 32 var defaultConfig = Config{ 33 // default server address for operator metrics 34 OperatorPrometheusServeAddr: ":9963", 35 } 36 37 func (def Config) Flags(flags *pflag.FlagSet) { 38 flags.String(OperatorPrometheusServeAddr, def.OperatorPrometheusServeAddr, "Address to serve Prometheus metrics") 39 } 40 41 // SharedConfig contains the configuration that is shared between 42 // this module and others. 43 // Metrics cell needs to know if GatewayAPI is enabled in order to use 44 // the same Registry as controller-runtime and avoid to expose 45 // multiple metrics endpoints or servers. 46 type SharedConfig struct { 47 // EnableMetrics is set to true if operator metrics are enabled 48 EnableMetrics bool 49 50 // EnableGatewayAPI enables support of Gateway API 51 EnableGatewayAPI bool 52 }