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

Projects
None yet
4 participants
@valentinewallace
Copy link
Collaborator

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

This comment has been minimized.

Copy link
@Roasbeef

Roasbeef May 29, 2019

Member

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.

This comment has been minimized.

Copy link
@valentinewallace

valentinewallace May 31, 2019

Author Collaborator

IIUC, fixed.

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

This comment has been minimized.

Copy link
@Roasbeef

Roasbeef May 29, 2019

Member

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

This comment has been minimized.

Copy link
@valentinewallace

valentinewallace May 31, 2019

Author Collaborator

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 valentinewallace:grpc-perf-interceptor branch 2 times, most recently from 0c2ca1b to 9fc1a34 May 31, 2019

Show resolved Hide resolved 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

@valentinewallace valentinewallace force-pushed the valentinewallace:grpc-perf-interceptor branch 3 times, most recently from b409d45 to 5e8a404 Jun 6, 2019

@Roasbeef
Copy link
Member

left a comment

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

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

This comment has been minimized.

Copy link
@Roasbeef

@valentinewallace valentinewallace force-pushed the valentinewallace:grpc-perf-interceptor branch 3 times, most recently from 858a13c to 9b44375 Jun 6, 2019

Show resolved Hide resolved lncfg/monitoring_on.go Outdated

@valentinewallace valentinewallace force-pushed the valentinewallace: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) {}

This comment has been minimized.

Copy link
@halseth

halseth Jun 11, 2019

Collaborator

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

valentinewallace added some commits May 31, 2019

rpcserver+monitoring/config: enable Prometheus monitoring.
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 valentinewallace:grpc-perf-interceptor branch from 920919d to f5eeb05 Jun 11, 2019

@Roasbeef
Copy link
Member

left a comment

LGTM 👾

@Roasbeef Roasbeef merged commit 89f6db1 into lightningnetwork:master Jun 12, 2019

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.05%) to 60.888%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.