gnmic icon indicating copy to clipboard operation
gnmic copied to clipboard

subscription name per xpath

Open jrametta opened this issue 2 years ago • 4 comments

I was wondering if it is possible to use event message name or subscription_name on a per xpath basis

I know I can do something like this...

subscriptions:
 ipv4-bgp-routes:
    paths:
      - "/state/service/vprn[service-name=*]/route-table/unicast/ipv4/statistics/bgp"
 ipv4-bgp-vpn-routes:
    paths:
      - "/state/service/vprn[service-name=*]/route-table/unicast/ipv4/statistics/bgp-vpn"
 ipv4-direct-routes:
    paths:
      - "/state/service/vprn[service-name=*]/route-table/unicast/ipv4/statistics/direct"

rather than this...

subscriptions:
  route-counts:
      - "/state/service/vprn[service-name=*]/route-table/unicast/ipv4/statistics/bgp"
      - "/state/service/vprn[service-name=*]/route-table/unicast/ipv4/statistics/bgp-vpn"
      - "/state/service/vprn[service-name=*]/route-table/unicast/ipv4/statistics/direct"

but wondering if there are negatives consequences to this as number of xpaths per router could be many. For example I can see Active RPC count on SROS router is increased.

Any suggestions, basically I'm looking for a way to easily identify a metric name (perhaps in addition to using path-base processor to trim event value keys in response).

thanks!

jrametta avatar Apr 05 '23 19:04 jrametta

It's possible to manipulate the metric name using processors as well. strings processor with the replace transform allows you to change the path to the desired metric name.

karimra avatar Apr 06 '23 00:04 karimra

Hi @karimra I would like to be able to update "subscription_name" or "name" in event msg. If I have multiple xpaths under the same subscription, then they all have the same name/subscription_name. For example using the 2nd config in my original post, I do not know if this event message belongs to bgp routes, bgp-vpn routes, or direct routes...

[
  {
    "name": "route-counts",
    "timestamp": 1679692200960575500,
    "tags": {
      "source": "r1",
      "subscription-name": "route-counts",
      "vprn_service-name": "vprn1"
    },
    "values": {
      "active-routes": 3,
      "available-routes": 3
    }
  }
]

jrametta avatar Apr 06 '23 16:04 jrametta

That's because you apply path-base before replacing the subscription-name. The way to do it is replace subscription-name based on the xpath (values.X) then apply path-base on the values name.

karimra avatar Apr 06 '23 16:04 karimra

This issue is stale because it has been open for 12 months with no activity.

github-actions[bot] avatar Apr 26 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 30 days since being marked as stale.

github-actions[bot] avatar May 26 '24 01:05 github-actions[bot]