2015-04-03 63 views
0

我一直在使用Statistics Collector生成自定義報告。apigee統計收集器/自定義報告不起作用

我的情況下,

我有一個巴斯DB與一個名爲「icustomer」收集其中有幾個名稱/值對的。

我創建了一個代理(icustomer),根據唯一的「cust_id」顯示特定的客戶(資源名稱特定的必需)。

對於特定客戶我做了「提取變量並分配可變策略」,它工作正常。

現在要獲取自定義報告,我再次添加了Extract變量策略,從JSON路徑中提取cust_id,然後添加統計收集器策略以獲取統計信息。

然後,我從Google Analytics創建了一份新報告並將其保存。但是報告不會生成。我所得到的是「NO_ID」報告。

我哪裏錯了?

代理終結代碼

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<ProxyEndpoint name="default"> 
    <Description/> 
<PreFlow name="PreFlow"> 
    <Request/> 
    <Response/> 
</PreFlow> 
<Flows> 
    <Flow name="specficcust"> 
     <Description/> 
     <Request/> 
     <Response/> 
     <Condition>(proxy.pathsuffix MatchesPath &quot;/{cust_id}&quot;) and (request.verb = &quot;GET&quot;)</Condition> 
    </Flow> 
</Flows> 
<PostFlow name="PostFlow"> 
    <Request/> 
    <Response/> 
</PostFlow> 
<HTTPProxyConnection> 
    <BasePath>/icustomer</BasePath> 
    <VirtualHost>default</VirtualHost> 
    <VirtualHost>secure</VirtualHost> 
</HTTPProxyConnection> 
<RouteRule name="default"> 
    <TargetEndpoint>default</TargetEndpoint> 
</RouteRule> 
</ProxyEndpoint> 

目標端點代碼

<?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> 
     <Condition>(proxy.pathsuffix MatchesPath &quot;/{cust_id}&quot;) and (request.verb = &quot;GET&quot;)</Condition> 
     <Response/> 
    </Flow> 
</Flows> 
<PostFlow name="PostFlow"> 
    <Response> 
     <Step> 
      <FaultRules/> 
      <Name>Extracting-for-Stats</Name> 
     </Step> 
     <Step> 
      <FaultRules/> 
      <Name>Statistics-Collector-1</Name> 
     </Step> 
    </Response> 
    <Request/> 
</PostFlow> 
<HTTPTargetConnection> 
    <URL>https://api.usergrid.com/siddharth1/sandbox/icustomer</URL> 
</HTTPTargetConnection> 
</TargetEndpoint> 

的統計提取代碼 -

<?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>$.entities[0].cust_id</JSONPath> 
    </Variable> 
</JSONPayload> 
<Source clearPayload="false">response</Source> 
<VariablePrefix>apigee</VariablePrefix> 

</ExtractVariables> 

統計收集代碼 -

<?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> 

回答

0

您的ExtractVariables指定了「apigee」的VariablePrefix。我希望可以從apigee.customer_id而不是僅僅是customer_id訪問提取的字段,這將在StatisticsCollector檢查中返回null。我想這就是爲什麼你得到你的默認「NO_ID」。

+0

我已經嘗試過「apigee.customer_id」,但我仍然在自定義報告中獲得默認的「NO_ID」。我甚至只嘗試了「customer_id」,它在自定義報告中給出了「未設置」。 – 2015-04-04 15:22:11

+0

我已經註釋掉VariablePrefix並且報告正在工作。我收到這些報告,但10份報告中只有少數報告顯示爲「未設置」 – 2015-04-06 05:02:42

+0

如果您因爲任何原因致使https:// api.usergrid.com/siddharth1/sandbox/icustomer失敗,您將跳轉到FaultRules而不是繼續使用PostFlow,並且您永遠無法訪問您的StatisticsCollector策略。您可以將StatisticCollector策略附加到您的代理中,並根據故障規則確保它總是按照您的意願命中。 – 2015-04-06 16:30:54