Skip to main content
Version: 0.9.x

Remedy Statistics Report

After one or more remedy plugins were configured and enabled, their effect can be inspected by using the remedy_stats command.

Lunar's Remedy Statistics Report records accumulative statistics that reveal how configured remedies acted and affected the traffic they encountered. This tool is meant to serve as a quick way to inspect that policies.yaml is properly configured.

The output of this command is printed out in JSON format, the schema of which is described below.

How To Run

docker exec lunar-proxy remedy_stats

Output Example

{
"remedy_stats": [
{
"remedy": "response_based_throttling",
"action": "generated",
"affected_count": 5,
"affected_ratio": 0.23809,
"affected_stats_by_endpoint": [
{
"method": "POST",
"url": "some-api.com/v2/*",
"count": 5,
"count_by_status_code": {
"400": 5
}
}
]
},
{
"remedy": "strategy_based_throttling",
"action": "generated",
"affected_count": 3,
"affected_ratio": 0.14285,
"affected_stats_by_endpoint": [
{
"method": "GET",
"url": "another-api.com/{some-path-param}",
"count": 3,
"count_by_status_code": {
"429": 3
}
}
]
},
// further per-plugin statistics (e.g. `account_orchestration`)...
],
"remedy_action_stats": {
"generated": {
"count": 8,
"ratio": 0.38095,
"ratio_by_status_code": {
"419": 0.5
}
}
// further per-action statistics (e.g. `modified`)...
},
"max_epoch_millis": 1688394379367,
"min_epoch_millis": 1688394264386
}

Data Scope

While this utility is called Remedy Statistics Report, it takes into account all the HTTP calls (aka transactions) that reached Lunar Proxy, whether they were remediated, diagnosed, or were merely forwarded to the API provider by Lunar Proxy. This is done in order to calculate ratio fields, which we will describe in the below section. In any ratio field exposed by this utility, the denominator is always the total amount of transactions that reached Lunar Proxy.

In the example above, the total amount of transactions that reached Lunar Proxy is 21.

Remedy Action Type

As remedy plugins are meant to solve API consumption problems, they can either modify the request or the response of a transaction, or generate a response on their own and prevent the API call to the original provider. They can also do nothing, of course.

Output Drilldown

Data is aggregated on both the remedy plugin level and on the action-type level.

Remedy Plugin Level Statistics

The output's top-level field remedy_stats holds an array in which each item describes the works of a specific remedy plugin. Data is aggregated on the plugin level, so if, for example, several Strategy Based Throttling policies are defined in policies.yaml, the statistics regarding their effect will be aggregated into a single item in this array, each distinct by the remedy field.

  • The action field explains the effect of each plugin. This value can be either modified or generated, as explained above.
  • The affected_count field counts the total amount of transactions upon which this plugin had an effect.
  • The affected_ratio field divides affected_count by the total amount of transactions that reached Lunar Proxy.
  • The affected_stats_by_endpoint field is an array which helps in understanding where were the affected transactions originally directed at and how their effective response status codes are distributed.

Action Type Level Statistics

The output's top-level field remedy_action_stats holds an object which may contain two fields: modified and generated, each describing the aggregated works of one or more remedy plugins, grouped by their action type. Each such field holds an object which contains the following fields:

  • The count field counts the total amount of transactions for which this action type was applied by remedy plugins.
  • The ratio field divides the count field by the total amount of transactions that reached Lunar Proxy.
  • The ratio_by_status_code field sheds light regarding the distribution of effective response status codes of the transactions in which this remedy action type was applied by remedy plugins. The ratio is calculated per status code from the total amount of transactions that reached Lunar Proxy.
note

Lunar Proxy will clear its Remedy Statistics Report state upon restart.