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

feat(inputs.gnmi): set max gRPC message size #12495

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/inputs/gnmi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
# encoding = "proto"

## redial in case of failures after
redial = "10s"
# redial = "10s"

## gRPC Maximum Message Size
# max_msg_size = "4MB"

## enable client-side TLS and define CA to authenticate the device
# enable_tls = false
Expand Down
13 changes: 11 additions & 2 deletions plugins/inputs/gnmi/gnmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type GNMI struct {
Subscriptions []Subscription `toml:"subscription"`
TagSubscriptions []TagSubscription `toml:"tag_subscription"`
Aliases map[string]string `toml:"aliases"`
MaxMsgSize config.Size `toml:"max_msg_size"`

// Optional subscription configuration
Encoding string
Expand Down Expand Up @@ -298,9 +299,17 @@ func (c *GNMI) subscribeGNMI(ctx context.Context, worker *Worker, tlscfg *tls.Co
} else {
creds = insecure.NewCredentials()
}
opt := grpc.WithTransportCredentials(creds)
opts := []grpc.DialOption{
grpc.WithTransportCredentials(creds),
}

if c.MaxMsgSize > 0 {
opts = append(opts, grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(int(c.MaxMsgSize)),
))
}

client, err := grpc.DialContext(ctx, worker.address, opt)
client, err := grpc.DialContext(ctx, worker.address, opts...)
if err != nil {
return fmt.Errorf("failed to dial: %v", err)
}
Expand Down
7 changes: 5 additions & 2 deletions plugins/inputs/gnmi/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# encoding = "proto"

## redial in case of failures after
redial = "10s"
# redial = "10s"

## gRPC Maximum Message Size
# max_msg_size = "4MB"

## enable client-side TLS and define CA to authenticate the device
# enable_tls = false
Expand Down Expand Up @@ -70,4 +73,4 @@
# ## At least one path element name must be supplied that contains at least
# ## one key to match on. Multiple element names can be specified in any
# ## order. In this case all element names must be present.
# elements = ["description", "interface"]
# elements = ["description", "interface"]