Hello Community,
I have an API proxy with multiple flows, one for each exposed backend service. The GET methods receive path parameters
I’m facing an issue when creating a custom report in Apigee Analytics because I need to see separate metrics for each flow.
Initially, I tried using the "Flow Resource" dimension, but it always shows as "not set"
Using the request path doesn't work either because, with path parameters, each request is detected as a different path.
Now, I’m trying to use the StatisticsCollector policy to capture the environment variables current.flow.name or current.flow.description by placing the policy inside each flow, but the values always appear empty.
As a workaround, I’m creating an AssignMessage policy to generate a custom variable custom.flow.name, but I haven't found a way to dynamically pass the flow name as a parameter.
This is just an example of what I need for this last idea, I know it doesn't work this way.
I’d really appreciate any help or guidance on how to properly capture flow-specific metrics in Apigee Analytics.
Thanks in advance!
Solved! Go to Solution.
@svargasm - I was able to reproduce your issue and find a solution for it.
For each conditional flow, you will need to create a Stat Collector policy. I tried using a variable but it wasnt working since it has a special character. This is what I did. I created 3 different Stat Collector policy (one for lines, brands and vehicle)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StatisticsCollector async="false" continueOnError="false" enabled="true" name="StatCollect-Brands">
<DisplayName>StatCollect-Brands</DisplayName>
<Properties/>
<Statistics>
<Statistic name="customPath" type="string">/brands</Statistic>
</Statistics>
</StatisticsCollector>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StatisticsCollector async="false" continueOnError="false" enabled="true" name="StatCollect-Lines">
<DisplayName>StatCollect-Lines</DisplayName>
<Properties/>
<Statistics>
<Statistic name="customPath" type="string">/lines</Statistic>
</Statistics>
</StatisticsCollector>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StatisticsCollector async="false" continueOnError="false" enabled="true" name="StatCollect-Vehicles">
<DisplayName>StatCollect-Vehicles</DisplayName>
<Properties/>
<Statistics>
<Statistic name="customPath" type="string">/vehicles</Statistic>
</Statistics>
</StatisticsCollector>
And then added each of the policies to the Response for each flows
<Flow name="getLinesByCode">
<Description/>
<Request/>
<Response>
<Step>
<Name>StatCollect-Lines</Name>
</Step>
<Step>
<Name>AM-SetVehicleLineResponse</Name>
</Step>
</Response>
<Condition>proxy.pathsuffix MatchesPath "/lines/*" and request.verb = "GET"</Condition>
</Flow>
<Flow name="getVehicleByPlate">
<Description/>
<Request/>
<Response>
<Step>
<Name>StatCollect-Vehicles</Name>
</Step>
<Step>
<Name>AM-SetVehicleResponse</Name>
</Step>
</Response>
<Condition>proxy.pathsuffix MatchesPath "/vehicles/*" and request.verb = "GET"</Condition>
</Flow>
<Flow name="getBrands">
<Description/>
<Request/>
<Response>
<Step>
<Name>StatCollect-Brands</Name>
</Step>
<Step>
<Name>AM-SetBrandResponse</Name>
</Step>
</Response>
<Condition>proxy.pathsuffix MatchesPath "/brands/*" and request.verb = "GET"</Condition>
</Flow>
This create a custom dimension called "customPath". I then created a Custom report with "customPath" as the first dimension and then Proxy Path suffix as 2nd. After a few mins, the graph showed up the way you asked.
Not elegant but works for your use case. Apigee considers anything in the Path as part of the URI, so it considers each as separate records for the GET APIs as they are unique path parameters.
Hope this helps!