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

Add gRPC performance Prometheus exporter. #3134

Merged

Conversation

@valentinewallace
Copy link
Contributor

@valentinewallace valentinewallace commented May 29, 2019

Optionally export lnd gRPC performance metrics for use by a Prometheus server through gRPC interceptors.

If the user compiles lnd with the monitoring tag, the exporter will automatically start listening for Prometheus requests when lnd starts up. The user has the option of specifying an address for the exporter to listen on, with the default being localhost:8989.

@@ -0,0 +1,9 @@
package monitoring

// PrometheusConfig is the set of configuration data that specifies
Copy link
Member

@Roasbeef Roasbeef May 29, 2019

Alternatively, this can live in lncfg and have two versions: one with w/ the build tag, and one w/o it. This way, if the user doesn't have this tag enabled, then it won't show up in lnd -h.

Copy link
Contributor Author

@valentinewallace valentinewallace May 31, 2019

IIUC, fixed.

monitoring/monitoring_on.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
rpcserver.go Outdated
case macService != nil:
unaryInterceptor = macService.UnaryServerInterceptor(permissions)
streamInterceptor = macService.StreamServerInterceptor(permissions)
case monitoring.Enabled:
Copy link
Member

@Roasbeef Roasbeef May 29, 2019

Rather than check this manually here independent of the build tag, I think this can be melded in with the current monitoring.Start method.

Copy link
Contributor Author

@valentinewallace valentinewallace May 31, 2019

Hm, server options need to be set before any services can register with the grpc server. Lmk if my solution works.

@valentinewallace valentinewallace force-pushed the grpc-perf-interceptor branch 2 times, most recently from 0c2ca1b to 9fc1a34 May 31, 2019
monitoring/monitoring_on.go Outdated Show resolved Hide resolved
lncfg/monitoring_off.go Outdated Show resolved Hide resolved
monitoring/monitoring_on.go Outdated Show resolved Hide resolved
lncfg/monitoring_off.go Outdated Show resolved Hide resolved
lncfg/monitoring_on.go Outdated Show resolved Hide resolved
lncfg/monitoring_off.go Outdated Show resolved Hide resolved
monitoring/monitoring_on.go Outdated Show resolved Hide resolved
monitoring/monitoring_on.go Outdated Show resolved Hide resolved
@valentinewallace valentinewallace force-pushed the grpc-perf-interceptor branch 3 times, most recently from b409d45 to 5e8a404 Jun 6, 2019
Copy link
Member

@Roasbeef Roasbeef left a comment

Diff looking much better now IMO, few more final comments, and then I think this is ready to land

monitoring/monitoring_on.go Outdated Show resolved Hide resolved
monitoring/monitoring_on.go Show resolved Hide resolved
serverOpts = append(serverOpts,
unaryInterceptor, streamInterceptor,
// Concatenate the slices of unary and stream interceptors respectively.
unaryInterceptors := append(macUnaryInterceptors, promUnaryInterceptors...)
Copy link
Member

@Roasbeef Roasbeef Jun 6, 2019

👍

@valentinewallace valentinewallace force-pushed the grpc-perf-interceptor branch 3 times, most recently from 858a13c to 9b44375 Jun 6, 2019
lncfg/monitoring_on.go Outdated Show resolved Hide resolved
@valentinewallace valentinewallace force-pushed the grpc-perf-interceptor branch 2 times, most recently from 9c367ca to 920919d Jun 7, 2019

// ExportPrometheusMetrics is required for lnd to compile so that Prometheus
// metric exporting can be hidden behind a build tag.
func ExportPrometheusMetrics(_ *grpc.Server, _ lncfg.Prometheus) {}
Copy link
Collaborator

@halseth halseth Jun 11, 2019

should this method possibly return an error if called on !monitoring build?

Start the Prometheus exporter in rpcserver.go if monitoring is enabled through the
build tag. Also allow users to specify what address they want the Prometheus
exporter to be listening on.
@valentinewallace valentinewallace force-pushed the grpc-perf-interceptor branch from 920919d to f5eeb05 Jun 11, 2019
Copy link
Member

@Roasbeef Roasbeef left a comment

LGTM 👾

@Roasbeef Roasbeef merged commit 89f6db1 into lightningnetwork:master Jun 12, 2019
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants