How to send the data of the "Developer" and the "Application" in the CURLs, to be able to generate complete reports ?

Hi. For GET and POST requests, I am generating statistical data which I am collecting using the "StatisticsCollector" policy and previously also an "ExtractVariables" policy, and I have a personalized report through which I consult the statistical data. These requests are related in the list of "Proxy Endpoints" elements. But for the vast majority of these requests the statistical records are generated with data equal to "null".

I understand that this is because using CURL I am not sending all the complete data, such as the data of the "Developer" and the data of the "App": Am I right?

, and if so, then...¿how through CURL can I send all this data as the “Developer” and the “App” (what should I add to the CURL), so that the sample of the reports have no problem ?

imagen-del-reporte.zip

1 2 241
2 REPLIES 2

I think it would be helpful if we saw a trace of a typical request.

Also, I would like to see specifically the StatisticsCollector policy, to see what data you are attempting to record and how.

The StatisticsCollector can store arbitrary information - anything available in a context variable - in a record for a request. The information it stores in the record need not be sent explicitly through the initial request. As I said, it can reference any context variable.

As you may know,

  • Apigee Edge automatically sets context variables that represent various data intrinsic to the request: request headers, request query params, request uri path and the verb. You can also get the payload ("content") for requests that have a payload,. Apigee Edge sets these for every inbound request.
  • there are additional "environmental" context variables automatically set by Apigee Edge, indicating things like the proxy name, the system time, the messageid (a uniqufier for the request), the system id (identifying the server handling the request) and more. These are all set automatically.
  • If you configure additional policies in your Apigee Edge proxy, then those policies can also set context variables. The simplest case is to use an AssignMessage/AssignVariable - this sets a variable explicitly. But other policies also set variables - like ExtractVariables, or VerifyApiKey or OAuthV2/VerifyAccessToken. For example, sometimes the initial request includes only an API Key. That information itself is not enough to identify the developer of the app, but when your proxy flow executes VerifyApiKey, then the policy sets a variable containing the developer name, and also another variable containing the app name.

I wasn't sure if you were clear on all of that. But now that we have that out of the way, the key conclusion here is that you do not need to "pass in" the developer name or app name in the request. These data should be loaded into context implicitly by verification of the application credential - either an API Key or a Token. After you call the VerifyApiKey or VerifyAccessToken, the developer and app name will be populated in context variables. Consult the product doc (here for VerifyApiKey) to see the precise variable names.

I suspect that your StatisticsCollector policy is misconfigured and you are not storing what you think you are storing in the analytics record. Double check that you are referencing the correct data. In particular, probably the appearance of "variable_name" in your statisticscollector policy should be replaced with the name of an actual variable that holds the developer name, possibly something like developer.app.id, or developer.app.name.

But please note: these data are ALREADY implicitly stored by the analytics subsystem. You only need to call VerifyApiKey or VerifyAccessToken and that data will be (a) loaded into context, and (B) correctly recorded in the analytics record, even without any StatisticsCollector policy. Use the StatisticsCollector policy to collect data in addition to the normally collected data . To see the full list, examine the "dimension" dropdown in the Custom Report Designer UI.

Okay. Thank you very much for the explanation: I did not know that the VerifyAPIKey policy generated having all these variables at hand. I am using this policy: the CURL within the application are made with the APIKey by sending it in the header. Then, according to the documentation on the link page that you put me, the variable that contains the name of the APP I understand is "developer.app.name". The name of my VerifyAPIKey type policy is "VerifyClientAPIKey". Please confirm me then if the following is correct: ¿to obtain the data of the name of the APP I must make reference to the variable in this way: "verifyapikey.{Policy_name}.developer.app.name" that is in my case "verifyapikey.VerifyClientAPIKey.developer.app.name"?

--

The idea is that in the application the CURL are done in this way (example of one of the CURL):

curl -X POST --header 'APIKey: <clave_Api_Key>' --header 'Content-Type: application/json' --header 'Accept: application/octet-stream' --header 'authorization: <token>' -d '{ "apifilters": [ { "dateType": "xxxxxxx", "name": "xxxxxx", "offset": xx, "value": "xxxxx" } ], "apiid": "xxxxxxxxx", "apiownerid": "xxxxxxx" }' '<URL_of_Proxy_Apigee_Server>/previewapidata'

(The "authorization" is a token that is generated internally in the web application to which the Apigee addresses).

--

Within the Apigee proxy server (in "default" within "Proxy Endpoints"), for the element corresponding to the CURL request that I have set as an example, I added these two policies in the Response flow:

* policy "Extract-Variables-Preview-Data-Api" (type "ExtractVariables"):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-Preview-Data-Api"> <DisplayName>Extract Variables - Preview Data Api</DisplayName> <JSONPayload> <Variable name="apiid"> <JSONPath>$.apiid</JSONPath> </Variable> <Variable name="apiownerid"> <JSONPath>$.apiownerid</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">response</Source> </ExtractVariables>

* policy "Statistics-Collector-Preview-Data-Api" (type "StatisticsCollector"):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <StatisticsCollector async="false" continueOnError="false" enabled="true" name="Statistics-Collector-Preview-Data-Api"> <DisplayName>Statistics Collector - Preview Data Api</DisplayName> <Properties/> <Statistics> <Statistic name="dthb_previewdata_apiid" ref="apiid" type="String">NO_APIID</Statistic> <Statistic name="dthb_previewdata_apiownerid" ref="apiownerid" type="Float">NO_APIOWNERID</Statistic> </Statistics> </StatisticsCollector>

--

where "dthb_previewdata_apiid" and "dthb_previewdata_apiownerid" are the two dimensions that I hope to show in the report.