Using the REST API, the usage (amount of hits on a rule) counter of various rules in cOS Core can be retrieved. The information is sent back by cOS Core in JSON format and consists of the values that can also be provided by using the cOS Core CLI rules command.
Sending the Request
To retrieve the rule usage totals since the last system reconfigure, an HTTP GET should be sent. The URI values sent, depending on the type of rule, are as follows:IP Rules
For the main rule set:
/api/oper/usage/iprules
For a specific named IP rule set:
/api/oper/usage/iprules?ruleset=<rule-set-name>
IDP Rules
/api/oper/usage/idprules
Threshold Rules
/api/oper/usage/thresholdrules
Pipe Rules
/api/oper/usage/piperules
Routing Rules
/api/oper/usage/routingrules
An Example JSON Reply
Below is an example of a typical JSON reply for an IP rule set with a single entry:{ "error":false, "rules":[ { "index":1, "name":"test_log", "usage":0 } ] }