-
Notifications
You must be signed in to change notification settings - Fork 407
Add prometheus metrics to CSI external-snapshotter using new csi-lib-utils library #227
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ import ( | |
| "github.com/container-storage-interface/spec/lib/go/csi" | ||
| "github.com/kubernetes-csi/csi-lib-utils/connection" | ||
| "github.com/kubernetes-csi/csi-lib-utils/leaderelection" | ||
| "github.com/kubernetes-csi/csi-lib-utils/metrics" | ||
| csirpc "github.com/kubernetes-csi/csi-lib-utils/rpc" | ||
| controller "github.com/kubernetes-csi/external-snapshotter/pkg/sidecar-controller" | ||
| "github.com/kubernetes-csi/external-snapshotter/pkg/snapshotter" | ||
|
|
@@ -66,6 +67,9 @@ var ( | |
|
|
||
| leaderElection = flag.Bool("leader-election", false, "Enables leader election.") | ||
| leaderElectionNamespace = flag.String("leader-election-namespace", "", "The namespace where the leader election resource exists. Defaults to the pod namespace if not set.") | ||
|
|
||
| metricsAddress = flag.String("metrics-address", "", "The TCP network address address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled.") | ||
|
Collaborator
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. duplicate "address".
Member
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. Good catch. #229 |
||
| metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.") | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -110,7 +114,11 @@ func main() { | |
| snapshotscheme.AddToScheme(scheme.Scheme) | ||
|
|
||
| // Connect to CSI. | ||
| csiConn, err := connection.Connect(*csiAddress, connection.OnConnectionLoss(connection.ExitOnConnectionLoss())) | ||
| metricsManager := metrics.NewCSIMetricsManager("" /* driverName */) | ||
| csiConn, err := connection.Connect( | ||
| *csiAddress, | ||
| metricsManager, | ||
| connection.OnConnectionLoss(connection.ExitOnConnectionLoss())) | ||
| if err != nil { | ||
| klog.Errorf("error connecting to CSI driver: %v", err) | ||
| os.Exit(1) | ||
|
|
@@ -128,6 +136,8 @@ func main() { | |
| } | ||
|
|
||
| klog.V(2).Infof("CSI driver name: %q", driverName) | ||
| metricsManager.SetDriverName(driverName) | ||
| metricsManager.StartMetricsEndpoint(*metricsAddress, *metricsPath) | ||
|
|
||
| // Check it's ready | ||
| if err = csirpc.ProbeForever(csiConn, *csiTimeout); err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,19 +4,59 @@ go 1.12 | |
|
|
||
| require ( | ||
| github.com/container-storage-interface/spec v1.1.0 | ||
| github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect | ||
| github.com/golang/mock v1.2.0 | ||
| github.com/golang/protobuf v1.3.2 | ||
| github.com/google/go-cmp v0.3.1 // indirect | ||
| github.com/googleapis/gnostic v0.2.0 // indirect | ||
| github.com/imdario/mergo v0.3.7 // indirect | ||
| github.com/kubernetes-csi/csi-lib-utils v0.6.1 | ||
| github.com/kubernetes-csi/csi-lib-utils v0.7.0 | ||
| github.com/kubernetes-csi/csi-test v2.0.0+incompatible | ||
| google.golang.org/grpc v1.23.0 | ||
| k8s.io/api v0.0.0-20191122220107-b5267f2975e0 | ||
| k8s.io/apimachinery v0.0.0-20191121175448-79c2a76c473a | ||
| k8s.io/client-go v0.0.0-20191122220542-ed16ecbdf3a0 | ||
| google.golang.org/grpc v1.26.0 | ||
| k8s.io/api v0.17.0 | ||
| k8s.io/apimachinery v0.17.1-beta.0 | ||
| k8s.io/client-go v0.17.0 | ||
| k8s.io/code-generator v0.0.0-20191121015212-c4c8f8345c7e | ||
| k8s.io/klog v1.0.0 | ||
| k8s.io/kubernetes v1.14.0 | ||
| ) | ||
|
|
||
| replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.17.0 | ||
|
|
||
| replace k8s.io/apiserver => k8s.io/apiserver v0.17.0 | ||
|
|
||
| replace k8s.io/cli-runtime => k8s.io/cli-runtime v0.17.0 | ||
|
|
||
| replace k8s.io/cloud-provider => k8s.io/cloud-provider v0.17.0 | ||
|
|
||
| replace k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.17.0 | ||
|
|
||
| replace k8s.io/code-generator => k8s.io/code-generator v0.17.1-beta.0 | ||
|
|
||
| replace k8s.io/component-base => k8s.io/component-base v0.17.0 | ||
|
|
||
| replace k8s.io/cri-api => k8s.io/cri-api v0.17.1-beta.0 | ||
|
|
||
| replace k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.17.0 | ||
|
Collaborator
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. what actually uses csi-translation-lib here?
Member
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. Yep, ran $ go mod tidy
$ git status
On branch addMetricsUsingLib
nothing to commit, working tree cleanDoesn't look like anything is using it. My guess is replace does not get removed by tidy. Let me try to remove it manually.
Member
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. |
||
|
|
||
| replace k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.17.0 | ||
|
|
||
| replace k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.17.0 | ||
|
|
||
| replace k8s.io/kube-proxy => k8s.io/kube-proxy v0.17.0 | ||
|
|
||
| replace k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.17.0 | ||
|
|
||
| replace k8s.io/kubectl => k8s.io/kubectl v0.17.0 | ||
|
|
||
| replace k8s.io/kubelet => k8s.io/kubelet v0.17.0 | ||
|
|
||
| replace k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.17.0 | ||
|
|
||
| replace k8s.io/metrics => k8s.io/metrics v0.17.0 | ||
|
|
||
| replace k8s.io/node-api => k8s.io/node-api v0.17.0 | ||
|
|
||
| replace k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.17.0 | ||
|
|
||
| replace k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.17.0 | ||
|
|
||
| replace k8s.io/sample-controller => k8s.io/sample-controller v0.17.0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: duplicate "address".