azureazure-api-management

Azure API Management service - getting the subscription key into Application Insights


I am currently using Azure API Management service on the consumption plan. While it's great it doesn't built-in analytics.

I have 15 users each with their own subscription key. At the moment I have no visibility on the usage of each user. I would like to get the subscription key for each API call and pass that into Application Insights.

Is this possible using a custom metric?

This query is working great however I'd like to get the subscription key included as well.

thank you so much!

requests
| project
    timestamp,
    url,
    operation_Name,    
    success,
    resultCode,
    duration,
    cloud_RoleName
| where timestamp > ago(1d)
| order by timestamp desc
| take 100

Solution

  • You may add this header in the app insights integration: enter image description here

    Then you may find it in the app insights logs:

    enter image description here

    and use the following query:

    requests
    | project timestamp, url, customDimensions["Request-Ocp-Apim-Subscription-Key"], operation_Name
    | where timestamp > ago(1d)