Open Ichabond opened 4 weeks ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
This is a proposed solution for #503
Updated the commit to fix the type assertion issue as well as the variable assignment issue.
Anything else needed here @karimra ?
While this works for that junos extension, I'm not sure it will for any other extension. The data in an extension is not always meant to be added as tags, we should find a way to pass it on to the output and use processors to select some keys to set as tags. The other thing I'm not entirely convinced by is that these proto files are set by target. If you have 100s of targets of the same type (same extensions), we will have to parse the proto files 100s of times. This is fine for now, but it should be improved/fixed in a future PR.
gNMI allows for the use of an
extension
field in each top-level message of the gNMI RPCs: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-extensions.md Given this is an arbitrary Protobyte payload, the default gNMI protobufs can't decode the payload contained within the field. This PR adds the necessary configuration options to load in an arbitrary Protobuf file perextension
identifier, with a message-name to lookup the message type.In this change:
DecodeExtension
is added. This function usesprotoreflect
to dynamically marshal arbitrary protoBytes into JSON. The loaded JSON is then put back in the Extension message as bytes (mainting type)Target
type has anExtensionProtoMap
added, allowing for the lookup of Extension IDs to loaded-in protobufsTargetConfig
type to support loading in the new configurationcollector.go
to output the gNMI message after inlining the decoded protoBytesapp/target.go
:parseExtensionProtos
. This uses theParser
provided byprotoreflect/desc/protoparse
event.go
to insert the K/Vs provided by the Extension as Tags. Given we come from JSON, all numbers are float64, so the only 2 types supported currently arestring
andfloat64
This has been tested with a device emiting an
extension
field:Which is then properly rendered to a Prometheus metric:
Note that some label-drop rules have been added to remove the spurious labels to avoid a cardinality explosion.