Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
gNMI Filtering
Problem Statement
In the rapidly evolving landscape of network management, the gNMI
(gRPC Network Management Interface) specification has emerged as a pivotal
protocol for the configuration and monitoring of network devices. While gNMI
provides a robust framework for network telemetry, it currently lacks an
efficient and standardized filtering mechanism. This gap poses several
significant challenges:
High Data Volume: Modern networks generate vast amounts of telemetry
data. Without effective filtering, network management systems are inundated
with irrelevant or redundant data, leading to unnecessary processing overhead
and increased storage requirements.
Network Bandwidth Consumption: Unfiltered data streams contribute to
excessive bandwidth usage, which can degrade network performance and increase
operational costs. Efficient filtering would enable the transmission of only
pertinent data, optimizing network bandwidth utilization.
Performance and Scalability: The absence of filtering mechanisms impacts
the performance and scalability of network management solutions. Systems must
handle and process large datasets, which can strain resources and hinder
real-time analysis and decision-making capabilities.
Operational Efficiency: Network operators need precise and relevant data
to make informed decisions. The lack of filtering complicates data extraction,
analysis, and correlation, thereby reducing operational efficiency and
increasing the likelihood of human error.
Security and Compliance: Transmitting all data without filtering can
expose sensitive information unnecessarily, raising security and compliance
risks.
Implementing filtering ensures that only authorized and relevant data is
transmitted, enhancing data privacy and security compliance.
Therefore, to address these challenges and improve the overall efficacy of
network management, it is imperative to incorporate a comprehensive filtering
mechanism within the gNMI specification. This enhancement will facilitate more
efficient data handling, optimize network performance, and empower network
operators with the precise information needed for effective management and
decision-making.
Proposed Solution
To address the identified challenges, a filtering mechanism called the
Where
extension will be added to the
PathElem
message.This requires a new extension field to be added to the PathElem message
The Where extension can be included in a
PathElem
message that is part of:This extension allows clients to specify conditions that must be met for a
path's children to be included in the response(s).
A single
Where
extension must be added to aPathElem
but multipleWhere
extensions can be added to a
Path
under differentPathElem
messages toform complex conditions. All Where conditions under different PathElem in the
same Path must evaluate to true for the children of that path to be included
in the response(s).
Where Message Definition
The Where message enables filtering based on conditions defined by expressions,
paths, or values. It includes the following components:
Expression Message Definition
The Expression message defines an operator node in a binary expression tree,
specifying the condition to be evaluated using an operation
op
and twooperands called
left
andright
.Valid and Invalid Combinations of Left and Right Operands
When constructing an Expression, it is crucial to ensure the operands are
appropriately paired to form valid expressions. The following outlines the
valid and invalid combinations:
Path and Value: One operand is a Path and the other is a Value.
// Invalid example expr: { op: EQUAL left: { value: { ... } } right: { value: { ... } } }
// Invalid example expr: { op: EQUAL left: { path: { ... } } right: { path: { ... } } }
Ensuring the proper combination of operands is essential to maintaining the
integrity of the expression tree and preventing logical errors in the
evaluation process.
Path Message Definition
The
Path
message defines an operand in anExpression
, it is a relative path thatbegins at the
PathElem
to which the Where message was appended.A
Path
operand returns the value of the leaf or leaf-list it points to.If the path points to a container or a list, it returns a boolean
true
if the container or list existsin the data tree; otherwise, it returns
false
.Value Message Definition
The Value message defines a node in the binary expression tree, allowing
one or multiple values to be specified based on the
WhereOp
value.WhereOp Enum Definition
The WhereOp enum defines the list of supported operations for filtering
conditions.
Implementation Details
Expression Tree Depth
Implementations can define a maximum binary expression tree depth.
If an expression exceeds this maximum depth, the server must return
an error with code
ResourceExhausted
.Operations
This extension defines a list of operations used to evaluate expressions.
This list can be extended in the future.
If an implementation does not support a operation received in a Request,
it must return an error with code
Unimplemented
.AND
The
AND
operation takes two operands of type boolean.It returns true only if both operands are true; otherwise, it returns false.
If one of the operands is not a boolean, an
InvalidArgument
error must bereturned.
OR
The OR operation takes two operands of type boolean.
It returns true if at least one of the operands is true; otherwise, it returns
false.
If one of the operands is not a boolean, an
InvalidArgument
error must bereturned.
NOT
The
NOT
or!
operation takes one operand of type boolean.It returns true if the operand is false, and false if the operand is true.
It inverts the boolean value. If the operand is not a boolean, an
InvalidArgument
error must be returned.If more than one operand is set together with the
NOT
operation,an
InvalidArgument
error must be returned.EQUAL
The
EQUAL
or==
operation takes two operands of the same type.It returns true if both operands are equal; otherwise, it returns false.
The comparison must be based on the underlying operand type.
If the two operands are not of the same type, an
InvalidArgument
error mustbe returned.
NOT_EQUAL
The
NOT_EQUAL
or!=
operation takes two operands of the same type,if returns true if the operands are not equal,
otherwise it returns false.
The comparison must be based on the underlying operands type.
If the two operands are not of the same type an
InvalidArgument
error mustbe returned.
LESS_THAN
The
LESS_THAN
or<
operation takes two operands of the same type.It returns true if the left operand is less than the right operand;
otherwise, it returns false.
The comparison must be based on the underlying value type.
The operands must be of one of the following types:
int64
,uint64
,or
double
.If the two operands are not of type
int64
,uint64
, ordouble
,an
InvalidArgument
error must be returned.If the two operands are not of the same type, an
InvalidArgument
errormust be returned.
GREATER_THAN
The
GREATER_THAN
or>
operation takes two operands of the same type.It returns true if the left operand is greater than the right operand;
otherwise, it returns false.
The comparison must be based on the underlying value type.
The operands must be of one of the following types:
int64
,uint64
,or
double
.If the two operands are not of type
int64
,uint64
, ordouble
,an
InvalidArgument
error must be returned.If the two operands are not of the same type, an
InvalidArgument
error must be returned.
LESS_THAN_OR_EQUAL
The
LESS_THAN_OR_EQUAL
or<=
operation takes two operands of the same type.It returns true if the left operand is less than or equal to the
right operand; otherwise, it returns false.
The operands must be of one of the following types:
int64
,uint64
,or
double
.If the two operands are not of type
int64
,uint64
, ordouble
,an
InvalidArgument
error must be returned.If the two operands are not of the same type, an
InvalidArgument
error mustbe returned.
GREATER_THAN_OR_EQUAL
The
GREATER_THAN_OR_EQUAL
or=>
operation takes two operands of the same type.It returns true if the left operand is greater than or equal to the
right operand; otherwise, it returns false.
The operands must be of one of the following types:
int64
,uint64
, ordouble
.If the two operands are not of type
int64
,uint64
, ordouble
,an
InvalidArgument
error must be returned.If the two operands are not of the same type, an
InvalidArgument
error must be returned.
IN
The
IN
orin
operation takes two operands. The left operand's type must be one ofthe following:
int64
,uint64
,double
,string
, orbool
.The right operand must be a
list_val
.It returns true if the left operand is found within the collection
specified by the right operand; otherwise, it returns false.
If the left operand is not of type
int64
,uint64
,double
,string
,or
bool
, an error code ofInvalidArgument
error must be returned.If the right operand is not of type
list_val
, anInvalidArgument
errormust be returned.
NOT_IN
The
NOT_IN
or!in
operation takes two operands. The left operand's type must be oneof the following:
int64
,uint64
,double
,string
, orbool
.The right operand must be a
list_val
.It returns true if the left operand is not found within the collection
specified by the right operand; otherwise, it returns false.
If the left operand is not of type
int64
,uint64
,double
,string
,or
bool
, an error code ofInvalidArgument
error must be returned.If the right operand is not of type
list_val
, anInvalidArgument
errormust be returned.
Example Usages
Here are a few examples of how the
Where
extension can be used in gNMImessages:
Get the list interface names where the oper-status is
UP
.String representation:
Proto message:
String representation:
Proto message:
This examples shows how the
Where
extension expressions can be nested, allowingto combine multiple conditions together.
String representation:
Proto message:
String representation:
Proto message:
String representation:
Proto message: