# Query BMV2 switch statistics using RPC or API

**URL:** <https://forum.p4.org/t/query-bmv2-switch-statistics-using-rpc-or-api/322>\
**Category:** Getting Started with P4\
**Created:** [May 7, 2022, 3:23pm UTC](https://forum.p4.org/t/query-bmv2-switch-statistics-using-rpc-or-api/322 "2022-05-07T15:23:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kh91](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@kh91](https://forum.p4.org/u/kh91)\
**Post date:** [May 7, 2022, 3:23pm UTC](https://forum.p4.org/t/query-bmv2-switch-statistics-using-rpc-or-api/322/1 "2022-05-07T15:23:12Z")

</div>

hello ,

I am a newbie in p4 and my question is : is it possibile through the SimpleSwitchThriftAPI or any other API to query the BMV2 switch statistics (E.g queeue depth ,number of a rule matched … ) without using a p4 program to do that . I want to compare the values obtained from the p4 program with the ones obtained from the SimpleSwitchThriftAPI().

thanks,

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [May 13, 2022, 6:26pm UTC](https://forum.p4.org/t/query-bmv2-switch-statistics-using-rpc-or-api/322/2 "2022-05-13T18:26:35Z")

</div>

Hi and welcome 🙂

I did not answer the question because I was not sure about the answer. But since no one passed by yet, let me try to answer.

I have to say that I am not sure what you mean by stating: `without using a p4 program to do that`. Which statistics did you collect with your P4 code?

Anyway, as you mentioned, you can query some statistics via the control plane protocol. If you run the `simple_switch_CLI` you can check some statistics like the counters for bytes or packets. You can associate them to a table and get the information you need via the control plane. See [here](https://cornell-pl.github.io/cs6114/lecture07.html) an example for counters. See more example about the runtime CLI [here](https://github.com/p4lang/behavioral-model/blob/main/docs/runtime_CLI.md). I could be wrong but last time I read it (could be a long time), the CLI used the Thrift API. This [file](https://github.com/p4lang/behavioral-model/blob/e1fcd5d54cecf7679f46ac462fdf92e049711e6c/tools/runtime_CLI.py) might be of help.

Cheers,
