FDio / govpp

Go toolset for the VPP.
Apache License 2.0
199 stars 82 forks source link

Support new VPP API objects: counters & paths #62

Closed ondrej-fabry closed 1 year ago

ondrej-fabry commented 2 years ago

The VPP has added support for a data model in VPP API for counters.

Gerrit change which introduced this feature: https://gerrit.fd.io/r/c/vpp/+/29296

Here is a part of ip.api.json file extracted from VPP master branch:

{
    "counters": [
      {
        "name": "ip_frag",
        "elements": [
          {
            "name": "none",
            "severity": "info",
            "type": "counter64",
            "units": "packets",
            "description": "packet fragmented"
          },
          {
            "name": "small_packet",
            "severity": "error",
            "type": "counter64",
            "units": "packets",
            "description": "packet smaller than MTU"
          },
          // ...
        ]
      }
    ],
    "paths": [
        [
          {
            "path": "/err/ip-frag",
            "counter": "ip_frag"
          },
          {
            "path": "/err/mpls-frag",
            "counter": "ip_frag"
          },
          // ...
        ]
    ]
}

We should consider adding support for this in the GoVPP. At the minimum we can add support to vppapi parser package so it is properly extracted from VPP API file.

Then, just brainstorming here, we could generate special file for this which could be used by the VPP Stats client in GoVPP for retrieving the stats data using defined paths and then structuring them according counters definition.

VladoLavor commented 1 year ago

vppapi support: PR#121. I'd continue on this task and make use of the data.

Right now only it seems only /err directory is covered in counters. Generating a separate file is probably the best approach. One option how to implement it is to create a stats service in each file (as the RPC is done) and generate a separate method for each path returning respective counters.