Statistics Collector Policy - How to gather request & response parameters and display them in Custom Report

Hi,

I am trying to capture couple of url params from the request and one or two boolean variables from the response. I had read it in the docs that you can only have one Statistics Collector Policy within a given proxy. So how should I capture both request and response parameters and create a custom report ?

Any help would be appreciated.

Thanks,

P.S - Tried putting the policy in the target response flow but the custom report displays "not set".

Solved Solved
1 11 1,574
1 ACCEPTED SOLUTION

@skanade , Welcome to Apigee Community,

Yes, You can do that. You will extract all the variables that you would like to capture using policy like extract variables or out of the box flow variables.

Once, you have all the data in Apigee flow variables, You will attach statistics collector policy in response flow to push the custom analytics data along with the API meta data to Apigee Analytics.

For example,

I would like to capture the URL Query params foo, name in URL like https://example.com/?foo=bar&name=anil , Also response payload parameter "empId" if sample response is,

{
  "name" : "anil",
  "empId" : 12345
}

Query params are available in apigee flow variables,

request.queryparam.foo
request.queryparam.name

In response flow, You will use extract variables policy to extract empId into a Apigee variables, Let's say api.empId .

Once you have all the custom analytics data in flow variables, You will use Statistics Collector policy to push information to Apigee Edge Analytics.

<StatisticsCollector name="publishPurchaseDetails">
  <Statistics>
    <Statistic name="fooApiDimension" ref="request.queryparam.foo" type="string">bar</Statistic>
    <Statistic name="nameApiDimension" ref="request.queryparam.name" type="string">defaultName</Statistic>
    <Statistic name="empId" ref="api.empId" type="string">0</Statistic>
  </Statistics>
</StatisticsCollector>

You will see "notset" only if you made a call with missing values of data to the custom analytics dimension or metric. More details here. Also, There will be delay of 10 - 12 minutes before you start seeing data in Analytics.

Hope it helps. Keep us posted moving forward if any.

View solution in original post

11 REPLIES 11

@skanade , Welcome to Apigee Community,

Yes, You can do that. You will extract all the variables that you would like to capture using policy like extract variables or out of the box flow variables.

Once, you have all the data in Apigee flow variables, You will attach statistics collector policy in response flow to push the custom analytics data along with the API meta data to Apigee Analytics.

For example,

I would like to capture the URL Query params foo, name in URL like https://example.com/?foo=bar&name=anil , Also response payload parameter "empId" if sample response is,

{
  "name" : "anil",
  "empId" : 12345
}

Query params are available in apigee flow variables,

request.queryparam.foo
request.queryparam.name

In response flow, You will use extract variables policy to extract empId into a Apigee variables, Let's say api.empId .

Once you have all the custom analytics data in flow variables, You will use Statistics Collector policy to push information to Apigee Edge Analytics.

<StatisticsCollector name="publishPurchaseDetails">
  <Statistics>
    <Statistic name="fooApiDimension" ref="request.queryparam.foo" type="string">bar</Statistic>
    <Statistic name="nameApiDimension" ref="request.queryparam.name" type="string">defaultName</Statistic>
    <Statistic name="empId" ref="api.empId" type="string">0</Statistic>
  </Statistics>
</StatisticsCollector>

You will see "notset" only if you made a call with missing values of data to the custom analytics dimension or metric. More details here. Also, There will be delay of 10 - 12 minutes before you start seeing data in Analytics.

Hope it helps. Keep us posted moving forward if any.

Thanks Anil for the explanation. I am able to extract all the request and response parameters and generate the report.

Awesome @skanade , Glad to know your query is resolved. Keep us posted moving forward if any.

Not applicable

Statistics Collector Policy -

,

Hi,

@Anil Sagar I have a query. Could you please explain how do you set the below value (you can see it in bold)?

<Statisticname="fooApiDimension"ref="request.queryparam.foo"type="string">bar</Statistic><Statisticname="nameApiDimension"ref="request.queryparam.name"type="string">defaultName</Statistic><Statisticname="empId"ref="api.empId"type="string">0</Statistic>

Your prompt response would be highly appreciated.

Regards,

Salman

@anil Sagar

Hi Anil, I have used the below xml for stats collector. However, it giving null in DB and I am not able to capture the amount. I have tried using EV variable i.e. "Rechargeamount" in ref but didn't work as well. Could you please tell me what needs to be done here? Also what value do one use here "type="STRING">value</Statistic>' ?

EV Policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-GetRequestPayload"> <DisplayName>EV-GetRequestPayload</DisplayName> <JSONPayload> <Variable name="correlationID"> <JSONPath>$.correlationID</JSONPath> </Variable> <Variable name="msisdn"> <JSONPath>$.msisdn</JSONPath> </Variable> <Variable name="RetailerMSISDN"> <JSONPath>$.RetailerMSISDN</JSONPath> </Variable> <Variable name="RechargepartyMSISDN"> <JSONPath>$.RechargepartyMSISDN</JSONPath> </Variable> <Variable name="RetailerPIN"> <JSONPath>$.RetailerPIN</JSONPath> </Variable> <Variable name="RechargeAmount"> <JSONPath>$.chargableAmount</JSONPath> </Variable> <Variable name="PartnerID"> <JSONPath>$.PartnerID</JSONPath> </Variable> </JSONPayload> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <Source clearPayload="false">request</Source> </ExtractVariables>

Stats Collector policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <StatisticsCollector async="false" continueOnError="false" enabled="true" name="Statistics-Collector-1"> <DisplayName>Statistics Collector-1</DisplayName> <Properties/> <Statistics> <Statistic name="amount1" ref="amount" type="STRING">value</Statistic> </Statistics> </StatisticsCollector>

Your prompt response would be highly appreciated.

Regards,

Salman

@Salman Khan, pl raise a separate question. It's not recommended to raise another question as part of an existing one.

@salman Khan

Do you see the EV capturing the value for RechargeAmount ? If yes then you just need to update your stats collector policy and make sure that this policy is after the EV policy.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StatisticsCollector async="false" continueOnError="false" enabled="true" name="Statistics-Collector-1">
    <DisplayName>Statistics Collector-1</DisplayName>
    <Properties/>
    <Statistics>
        <Statistic name="amount1" ref="RechargeAmount" type="String">defaultValue</Statistic>
    </Statistics>
</StatisticsCollector>

The ref field should reflect the EV variable and defaultValue can be any value that you want to set if for some reasons the data is not captured it will show the default value.

Let me know if it worked.

Not applicable

@skanade

I have tried this but didn't work when I place the policy with EV of the payload. However, when I put it in the post flow request it is working fine.

Thanks for the prompt support.

Regards,

Salman

Not applicable

I have one more query, how can I remove the custom dimensions from analytics which are now extra?

Regards,

Salman

Currently there is no mechanism to remove unused custom dimensions. Should be sometimes down the road (future releases). Reference : - https://community.apigee.com/answers/15064/view.html

Can I just remove the column from DB?