Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to fetch counters from the switch? #99

Open
swapniil opened this issue Apr 26, 2022 · 2 comments
Open

how to fetch counters from the switch? #99

swapniil opened this issue Apr 26, 2022 · 2 comments

Comments

@swapniil
Copy link

I've added certain counters to check packets in-out stats.
srv6_transit_table_counter
But I'm not able to fetch them using that util/gnmi-cli command.

Can someone please let me know how can I fetch the newly added counters from switch,
util/gnmi-cli --grpc-addr localhost:50001 get /interfaces

@ccascone
Copy link
Collaborator

ccascone commented Apr 27, 2022

P4 counters can be read using P4Runtime, not gNMI. Unfortunately in ONOS we don't have an API for reading indirect counters (yet). ONOS can read direct counters when periodically reading table entries, and displaythem as part of flow rule stats (onos> flows command in the ONOS CLI).

I'm assuming you are dealing with indirect ones, I see two options:

  • Hard: write an ONOS CLI command that uses the P4RuntimeClient class to read the counter of interest. You can see an example here.
  • Easy: use p4runtime-shell (in parallel with ONOS)

@swapniil
Copy link
Author

swapniil commented Apr 28, 2022

@ccascone Thanks for the response and the clarifying the problem I'm debugging on.

To elaborate more, I did the declaration of the counters as below:

direct_counter(CounterType.packets_and_bytes) ue_counter;
direct_counter(CounterType.packets_and_bytes) gtp_decap_counter;

The above declaration suggest these are direct counters. (I'm not sure about it as I have just started learning about the P4 and going through basic understandings).

onos> flows is not showing these counters.

Apologies for the next questions but I'm not exactly getting what is the Easy: use p4runtime-shell (in parallel with ONOS) means here.
I tried as below:

*** Connecting to P4Runtime server at localhost:50001 ...
You are not master, you only have read access to the server
*** Welcome to the IPython shell for P4Runtime ***
P4Runtime sh >>> for te in direct_counter_entry["gtp_decap_counter"].read(): 
            ...:     print(te) 
            ...:                                                                                                                                                     
---------------------------------------------------------------------------
P4RuntimeException                        Traceback (most recent call last)
<ipython-input-1-8dc7f7218aa1> in <module>
----> 1 for te in direct_counter_entry["gtp_decap_counter"].read():
      2     print(te)
      3 

/p4runtime-sh/p4runtime_sh/p4runtime.py in handle(*args, **kwargs)
    132             return f(*args, **kwargs)
    133         except grpc.RpcError as e:
--> 134             raise P4RuntimeException(e) from None
    135     return handle
    136 

P4RuntimeException: P4Runtime RPC error (UNIMPLEMENTED): 

P4Runtime sh >>>  

With the reference from the issue, P4RuntimeClient also not showing the counters.

Can you please revert me what is wrong in this from below list ?

  1. Declaration of Direct counters
  2. Execution of P4Runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants