Hi guys, I'm stuck at generating custom reports using Statistics Collector.
My scenario,
I have an BaaS DB with a collection named "icustomer" which has few name/value pair's.
I created a proxy(icustomer) to display an specific Customer(Resource name- specificcust) depending on unique "cust_id".
For Specific Customer I did "extract variable and assign variable policies" which is working fine.
Now to get custom reports I again added an Extract Variable policy to extract cust_id from JSON Path and then added and Statistic Collector policy to get stats.
Then I created an new report from Analytics and saved it. But reports aren't generated.
Where did I go wrong?
Proxy Link - http://siddharth1-test.apigee.net/icustomer
Extract Variable Policy for stats
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extracting-for-Stats"> <DisplayName>Extracting for Stats</DisplayName> <FaultRules/> <Properties/> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="customer_id"> <JSONPath>$.cust_id</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">request</Source> <VariablePrefix>apigee</VariablePrefix> </ExtractVariables>
Statistic 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> <FaultRules/> <Properties/> <Statistics> <Statistic name="test_cust_id" ref="customer_id" type="STRING">NO_ID</Statistic> </Statistics> </StatisticsCollector>
Target Endpoint Code
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <TargetEndpoint name="default"> <Description/> <PreFlow name="PreFlow"> <Request/> <Response/> </PreFlow> <Flows> <Flow name="specficcust"> <Description/> <Request> <Step> <FaultRules/> <Name>Extract-Variables-1</Name> </Step> <Step> <FaultRules/> <Name>Assign-Message-1</Name> </Step> </Request> <Response> <Step> <FaultRules/> <Name>Extracting-for-Stats</Name> </Step> </Response> <Response> <Step> <FaultRules/> <Name>Statistics-Collector-1</Name> </Step> </Response> <Condition>(proxy.pathsuffix MatchesPath "/{cust_id}") and (request.verb = "GET")</Condition> </Flow> </Flows> <PostFlow name="PostFlow"> <Request/> <Response/> </PostFlow> <HTTPTargetConnection> <URL>https://api.usergrid.com/siddharth1/sandbox/icustomer</URL> </HTTPTargetConnection> </TargetEndpoint>
Custom Report Screenshot
Solved! Go to Solution.
With the provided information it is seems that one of the following reasons are responsible for this issue: 1. In the Target Endpoint Code, there are two <Response> flow in the resource "specficcust" which shouldn't be the there, it should be like following: <Response> <Step> <FaultRules/> <Name>Extracting-for-Stats</Name> </Step> <Step> <FaultRules/> <Name>Statistics-Collector-1</Name> </Step> </Response> 2. Extracting-for-Stats policy should extract the cust_id from response object. <Source clearPayload="false">response</Source> 3. Please check your JSON path in the policy Extracting-for-Stats, it should be $.entities[0].cust_id