Repository navigation
Add Stackdriver metrics exporter support for activator and autoscaler #2337
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
Changes from all commits
15a7469
5e31618
359cfdb
1c49bac
c95cc5f
7696e57
6e9b09c
544fb71
0f76671
af38665
1decb20
a6a414c
7a9b77a
e1e0a37
1834735
1d9579b
152d0fc
23a1d26
82a2285
5e606f1
d599159
86c329f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ package main | |
| import ( | ||
| "flag" | ||
| "log" | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/knative/pkg/configmap" | ||
|
|
@@ -31,11 +30,10 @@ import ( | |
| clientset "github.com/knative/serving/pkg/client/clientset/versioned" | ||
| informers "github.com/knative/serving/pkg/client/informers/externalversions" | ||
| "github.com/knative/serving/pkg/logging" | ||
| "github.com/knative/serving/pkg/metrics" | ||
| "github.com/knative/serving/pkg/reconciler" | ||
| "github.com/knative/serving/pkg/reconciler/v1alpha1/autoscaling" | ||
| "github.com/knative/serving/pkg/system" | ||
| "go.opencensus.io/exporter/prometheus" | ||
| "go.opencensus.io/stats/view" | ||
| "go.uber.org/zap" | ||
| "golang.org/x/sync/errgroup" | ||
| "k8s.io/apimachinery/pkg/util/wait" | ||
|
|
@@ -54,6 +52,7 @@ const ( | |
| statsServerAddr = ":8080" | ||
| statsBufferLen = 1000 | ||
| logLevelKey = "autoscaler" | ||
| component = "autoscaler" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -93,7 +92,8 @@ func main() { | |
| // Watch the logging config map and dynamically update logging levels. | ||
| configMapWatcher := configmap.NewInformedWatcher(kubeClientSet, system.Namespace) | ||
| configMapWatcher.Watch(logging.ConfigName, logging.UpdateLevelFromConfigMap(logger, atomicLevel, logLevelKey)) | ||
|
|
||
| // Watch the observability config map and dynamically update metrics exporter. | ||
| configMapWatcher.Watch(metrics.ObservabilityConfigName, metrics.UpdateExporterFromConfigMap(component, logger)) | ||
| // This is based on how Kubernetes sets up its scale client based on discovery: | ||
| // https://github.com/kubernetes/kubernetes/blob/94c2c6c84/cmd/kube-controller-manager/app/autoscaling.go#L75-L81 | ||
| restMapper := buildRESTMapper(kubeClientSet, stopCh) | ||
|
|
@@ -159,19 +159,6 @@ func main() { | |
| return ctl.Run(controllerThreads, stopCh) | ||
| }) | ||
|
|
||
| // Setup the metrics to flow to Prometheus. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this started implicitly by importing "metrics" above?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this will handled by metrics.UpdateExporterFromConfigMap. If it's prometheus, this will be called. |
||
| logger.Info("Initializing OpenCensus Prometheus exporter.") | ||
| promExporter, err := prometheus.NewExporter(prometheus.Options{Namespace: "autoscaler"}) | ||
| if err != nil { | ||
| logger.Fatal("Failed to create the Prometheus exporter.", zap.Error(err)) | ||
| } | ||
| view.RegisterExporter(promExporter) | ||
| view.SetReportingPeriod(time.Second * 10) | ||
| go func() { | ||
| http.Handle("/metrics", promExporter) | ||
| http.ListenAndServe(":9090", nil) | ||
| }() | ||
|
|
||
| statsCh := make(chan *autoscaler.StatMessage, statsBufferLen) | ||
|
|
||
| statsServer := statserver.New(statsServerAddr, statsCh, logger) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.