Skip to content

Commit

Permalink
Refactor STREAM_TELEMETRY_GROUP
Browse files Browse the repository at this point in the history
Signed-off-by: Ze Gan <[email protected]>
  • Loading branch information
Pterosaur committed Sep 13, 2024
1 parent b60811d commit 754fca7
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 21 deletions.
53 changes: 39 additions & 14 deletions doc/stream-telemetry/sonic-stream-telemetry.yang
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ module sonic-stream-telemetry {

prefix sonic-stream-telemetry;

import sonic-port {
prefix port;
}

import sonic-buffer-pool {
prefix bpl;
}

import sonic-buffer-pg {
prefix bpg;
}

import sonic-buffer-queue {
prefix bql;
}

container sonic-stream-telemetry {
container STREAM_TELEMETRY_PROFILE {
description "STREAM_TELEMETRY_PROFILE part of config_db.json";
Expand All @@ -19,19 +35,23 @@ module sonic-stream-telemetry {
}

leaf stream_state {
mandatory true;
type string {
pattern "enabled|disabled";
}
}

leaf poll_interval {
mandatory true;
description "The interval to poll counter, unit milliseconds.";
type uint32;
}

leaf chunk_size {
type uint32;
default 0;
type uint32 {
range "1..4294967295";
}
default 1;
}

leaf cache_size {
Expand All @@ -54,25 +74,30 @@ module sonic-stream-telemetry {

// The table name of config db
leaf group_name {
type string {
pattern "PORT|QUEUE|BUFFER_PG|BUFFER_POOL|BUFFER_QUEUE";
type enumeration {
enum PORT;
enum BUFFER_POOL;
enum BUFFER_PG;
enum BUFFER_QUEUE;
}
}

leaf-list object_names {
type string {
pattern "\w+(\|\d+(-\d+)?)?";
error-message "Invalid object names";
}
description "The object names to be monitored";
type string;
must "( ../group_name = 'PORT' and current() = /port:sonic-port/port:PORT/port:PORT_LIST/port:name )"
+ " or ( ../group_name = 'BUFFER_POOL' and current() = /bpl:sonic-buffer-pool/bpl:BUFFER_POOL/bpl:BUFFER_POOL_LIST/bpl:name )"
+ " or ( ../group_name = 'BUFFER_PG' and substring-before(current(), '|') = /bpg:sonic-buffer-pg/bpg:BUFFER_PG/bpg:BUFFER_PG_LIST/bpg:port and re-match(substring-after(current(), '|'), '[0-9]+') )"
+ " or ( ../group_name = 'BUFFER_QUEUE' and substring-before(current(), '|') = /bql:sonic-buffer-queue/bql:BUFFER_QUEUE/bql:BUFFER_QUEUE_LIST/bql:port and re-match(substring-after(current(), '|'), '[0-9]+') )";
}

must "count(object_names) > 0";

leaf-list object_counters {
string {
pattern "SAI_[A-Z]+_STAT_([A-Z]+_)*[A-Z]+";
error-message "Invalid STATS ID for SAI object";
}
description "The SAI STATS ID";
type string;
must "( ../group_name = 'PORT' and re-match(current(), 'IF_IN_OCTETS|IF_IN_UCAST_PKTS|IF_IN_DISCARDS|IF_IN_ERRORS|IN_CURR_OCCUPANCY_BYTES|IF_OUT_OCTETS|IF_OUT_DISCARDS|IF_OUT_ERRORS|IF_OUT_UCAST_PKTS|OUT_CURR_OCCUPANCY_BYTES') )"
+ " or ( ../group_name = 'BUFFER_POOL' and re-match(current(), 'PACKETS|BYTES|DROPPED_PACKETS|CURR_OCCUPANCY_BYTES|WATERMARK_BYTES|WRED_ECN_MARKED_PACKETS') )"
+ " or ( ../group_name = 'BUFFER_PG' and re-match(current(), 'PACKETS|BYTES|CURR_OCCUPANCY_BYTES|WATERMARK_BYTES|XOFF_ROOM_CURR_OCCUPANCY_BYTES|XOFF_ROOM_WATERMARK_BYTES|DROPPED_PACKETS') )"
+ " or ( ../group_name = 'BUFFER_QUEUE' and re-match(current(), 'DROPPED_PACKETS|CURR_OCCUPANCY_BYTES|WATERMARK_BYTES|CURR_OCCUPANCY_BYTES|XOFF_ROOM_WATERMARK_BYTES') )";
}

}
Expand Down
14 changes: 7 additions & 7 deletions doc/stream-telemetry/stream-telemetry-hld.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Stream telemetry high level design <!-- omit in toc -->

## Table of Content ## <!-- omit in toc -->
## Table of Content <!-- omit in toc -->

- [Revision](#revision)
- [Scope](#scope)
Expand Down Expand Up @@ -374,15 +374,15 @@ key = STREAM_TELEMETRY_GROUP:group_name:profile_name
; Multiple groups can be bound to a same stream telemetry profile.
; field = value
object_names = A comma separated list of object name.
; The syntax of object name is top_object_name|index_range.
; The syntax of object name is top_object_name|index.
; The object_name is the object of the top level, like port, Ethernet0,Ethernet4.
; The index range is the object in second level, like priority group.
; An example is Ethernet0|0,Ethernet4|3-4.
object_counters = list of stats of object
; The stats name in the group. like SAI_PORT_STAT_IF_IN_OCTETS,SAI_PORT_STAT_IF_IN_UCAST_PKTS.
; comma separated list.
; The index indicates the object in second level, like priority group.
; An example is Ethernet0|0,Ethernet4|3.
object_counters = list of stats of object; comma separated list
```

For the schema of `STREAM_TELEMETRY_GROUP`, please refer to its [YANG model](sonic-stream-telemetry.yang).

### StateDb

#### STREAM_TELEMETRY_SESSION
Expand Down
105 changes: 105 additions & 0 deletions doc/stream-telemetry/stream_telemetry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"STREAM_TELEMETRY_VALID_CASE": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"lanes": "0",
"speed": 25000
},
{
"name": "Ethernet4",
"lanes": "4",
"speed": 25000
}
]
}
},
"sonic-buffer-pool:sonic-buffer-pool": {
"sonic-buffer-pool:BUFFER_POOL": {
"BUFFER_POOL_LIST": [
{
"name": "egress_lossless_pool",
"mode": "static",
"size": "300",
"type": "ingress"
}
]
}
},
"sonic-buffer-profile:sonic-buffer-profile": {
"sonic-buffer-profile:BUFFER_PROFILE": {
"BUFFER_PROFILE_LIST": [
{
"name": "lossless_buffer_profile",
"size": "1518",
"dynamic_th": "2",
"pool": "egress_lossless_pool"
}
]
}
},
"sonic-buffer-pg:sonic-buffer-pg": {
"sonic-buffer-pg:BUFFER_PG": {
"BUFFER_PG_LIST": [
{
"port": "Ethernet4",
"pg_num": "3",
"profile": "lossless_buffer_profile"
}
]
}
},
"sonic-buffer-queue:sonic-buffer-queue": {
"sonic-buffer-queue:BUFFER_QUEUE": {
"BUFFER_QUEUE_LIST": [
{
"port": "Ethernet0",
"qindex": "15",
"profile": "lossless_buffer_profile"
}
]
}
},
"sonic-stream-telemetry:sonic-stream-telemetry": {
"sonic-stream-telemetry:STREAM_TELEMETRY_PROFILE": {
"STREAM_TELEMETRY_PROFILE_LIST": [
{
"name": "high_frequency_counters",
"stream_state": "enabled",
"poll_interval": 100
}
]
},
"sonic-stream-telemetry:STREAM_TELEMETRY_GROUP": {
"STREAM_TELEMETRY_GROUP_LIST": [
{
"profile_name": "high_frequency_counters",
"group_name": "PORT",
"object_names": ["Ethernet0", "Ethernet4"],
"object_counters": ["IF_IN_OCTETS", "OUT_CURR_OCCUPANCY_BYTES"]
},
{
"profile_name": "high_frequency_counters",
"group_name": "BUFFER_POOL",
"object_names": ["egress_lossless_pool"],
"object_counters": ["PACKETS", "WRED_ECN_MARKED_PACKETS"]
},
{
"profile_name": "high_frequency_counters",
"group_name": "BUFFER_PG",
"object_names": ["Ethernet4|0", "Ethernet4|3"],
"object_counters": ["CURR_OCCUPANCY_BYTES", "XOFF_ROOM_WATERMARK_BYTES"]
},
{
"profile_name": "high_frequency_counters",
"group_name": "BUFFER_QUEUE",
"object_names": ["Ethernet0|15", "Ethernet0|3"],
"object_counters": ["WATERMARK_BYTES", "XOFF_ROOM_WATERMARK_BYTES"]
}
]
}
}
}
}

0 comments on commit 754fca7

Please sign in to comment.