@@ -158,10 +158,8 @@ func (s *APIServer) PrepareRun(stopCh <-chan struct{}) error {
|
||||
|
||||
s.installKubeSphereAPIs()
|
||||
|
||||
s.installAPI()
|
||||
if s.Config.MetricsOptions != nil && s.Config.MetricsOptions.Enable {
|
||||
s.container.Filter(monitorRequest)
|
||||
}
|
||||
s.installMetricsAPI()
|
||||
s.container.Filter(monitorRequest)
|
||||
|
||||
for _, ws := range s.container.RegisteredWebServices() {
|
||||
klog.V(2).Infof("%s", ws.RootPath())
|
||||
@@ -185,11 +183,9 @@ func monitorRequest(r *restful.Request, response *restful.Response, chain *restf
|
||||
}
|
||||
}
|
||||
|
||||
func (s *APIServer) installAPI() {
|
||||
if s.Config.MetricsOptions != nil && s.Config.MetricsOptions.Enable {
|
||||
register()
|
||||
metrics.Defaults.Install(s.container)
|
||||
}
|
||||
func (s *APIServer) installMetricsAPI() {
|
||||
register()
|
||||
metrics.Defaults.Install(s.container)
|
||||
}
|
||||
|
||||
// Install all kubesphere api groups
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/logging/elasticsearch"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/metrics"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/multicluster"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/network"
|
||||
@@ -98,7 +97,6 @@ type Config struct {
|
||||
AuditingOptions *auditingclient.Options `json:"auditing,omitempty" yaml:"auditing,omitempty" mapstructure:"auditing"`
|
||||
AlertingOptions *alerting.Options `json:"alerting,omitempty" yaml:"alerting,omitempty" mapstructure:"alerting"`
|
||||
NotificationOptions *notification.Options `json:"notification,omitempty" yaml:"notification,omitempty" mapstructure:"notification"`
|
||||
MetricsOptions *metrics.Options `json:"metrics,omitempty" yaml:"metrics,omitempty" mapstructure:"metrics"`
|
||||
}
|
||||
|
||||
// newConfig creates a default non-empty Config
|
||||
@@ -122,7 +120,6 @@ func New() *Config {
|
||||
MultiClusterOptions: multicluster.NewOptions(),
|
||||
EventsOptions: eventsclient.NewElasticSearchOptions(),
|
||||
AuditingOptions: auditingclient.NewElasticSearchOptions(),
|
||||
MetricsOptions: metrics.NewMetricsOptions(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/logging/elasticsearch"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/metrics"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/monitoring/prometheus"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/multicluster"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/network"
|
||||
@@ -157,9 +156,6 @@ func newTestConfig() (*Config, error) {
|
||||
IndexPrefix: "ks-logstash-auditing",
|
||||
Version: "6",
|
||||
},
|
||||
MetricsOptions: &metrics.Options{
|
||||
Enable: false,
|
||||
},
|
||||
}
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func (r *Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
if err := r.Update(rootCtx, workspace); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
workspaceOperation.WithLabelValues("create", instance.Name).Inc()
|
||||
workspaceOperation.WithLabelValues("create", workspace.Name).Inc()
|
||||
}
|
||||
} else {
|
||||
// The object is being deleted
|
||||
@@ -112,7 +112,7 @@ func (r *Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
logger.Error(err, "update workspace failed")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
workspaceOperation.WithLabelValues("delete", instance.Name).Inc()
|
||||
workspaceOperation.WithLabelValues("delete", workspace.Name).Inc()
|
||||
}
|
||||
// Our finalizer has finished, so the reconciler can do nothing.
|
||||
return ctrl.Result{}, nil
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package metrics
|
||||
|
||||
import "github.com/spf13/pflag"
|
||||
|
||||
type Options struct {
|
||||
Enable bool `json:"enable,omitempty" description:"enable metric"`
|
||||
}
|
||||
|
||||
func NewMetricsOptions() *Options {
|
||||
return &Options{
|
||||
Enable: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Options) ApplyTo(options *Options) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Options) AddFlags(fs *pflag.FlagSet, c *Options) {
|
||||
fs.BoolVar(&s.Enable, "enable-metrics", c.Enable, "If true, allow metrics. [default=false]")
|
||||
}
|
||||
Reference in New Issue
Block a user