You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-management/api-management-howto-log-event-hubs.md
+15-18Lines changed: 15 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,11 +25,17 @@ This article describes how to log API Management events using Azure Event Hubs.
25
25
26
26
## Configure access to the event hub
27
27
28
-
To log events to the event hub, you need credentials to enable access from API Management. API Management supports two access mechanisms: an Event Hubs connection string, or an API Management managed identity.
28
+
To log events to the event hub, you need to configure credentials for access from API Management. API Management supports two access mechanisms:
29
+
30
+
* An event hub connection string
31
+
* A managed identity for your API Management instance.
29
32
30
33
### Configure event hub connection string
31
34
32
-
To create an Event Hubs connection string, see [Get an Event Hubs connection string](../event-hubs/event-hubs-get-connection-string.md). You can get a connection string to the namespace or the specific event hub you use for logging from API Management
35
+
To create an Event Hubs connection string, see [Get an Event Hubs connection string](../event-hubs/event-hubs-get-connection-string.md).
36
+
37
+
* You can use a connection string for the Event Hubs namespace or for the specific event hub you use for logging from API Management.
38
+
* The shared access policy for the connection string must enable at least **Send** permissions.
33
39
34
40
### Configure API Management managed identity
35
41
@@ -40,25 +46,25 @@ To create an Event Hubs connection string, see [Get an Event Hubs connection str
40
46
41
47
* If you enable a user-assigned managed identity, take note of the identity's **Client ID**.
42
48
43
-
1. Assign the identity the **Azure Event Hubs Data Owner** role, scoped to the Event Hubs namespace or to the event hub used for logging. To assign the role, use the [Azure portal](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md) or other Azure tools.
44
-
49
+
1. Assign the identity the **Azure Event Hubs Data sender** role, scoped to the Event Hubs namespace or to the event hub used for logging. To assign the role, use the [Azure portal](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md) or other Azure tools.
45
50
46
51
## Create an API Management logger
47
-
Now that you have an event hub, the next step is to configure a [Logger](/rest/api/apimanagement/current-ga/logger) in your API Management service so that it can log events to the event hub.
52
+
The next step is to configure a [logger](/rest/api/apimanagement/current-ga/logger) in your API Management service so that it can log events to the event hub.
48
53
49
-
API Management loggers can be configured using the [API Management REST API](/rest/api/apimanagement/current-ga/logger/create-or-update) directly or tools including [Azure PowerShell](/powershell/module/az.apimanagement/new-azapimanagementlogger), a Bicep template, or an Azure Resource Management template.
54
+
You can create and manage API Management loggers using the [API Management REST API](/rest/api/apimanagement/current-ga/logger/create-or-update) directly or using tools including [Azure PowerShell](/powershell/module/az.apimanagement/new-azapimanagementlogger), a Bicep template, or an Azure Resource Management template.
50
55
51
56
### Logger with connection string credentials
52
57
53
58
#### [PowerShell](#tab/PowerShell)
54
59
55
-
The following example uses the [New-AzApiManagementLogger](/powershell/module/az.apimanagement/new-azapimanagementlogger) cmdlet to create a logger to an event hub by specifying a connection string.
60
+
The following example uses the [New-AzApiManagementLogger](/powershell/module/az.apimanagement/new-azapimanagementlogger) cmdlet to create a logger to an event hub by configuring a connection string.
@@ -118,7 +124,7 @@ Include the following JSON snippet in your Azure Resource Manager template.
118
124
119
125
## Configure log-to-eventhub policy
120
126
121
-
Once your logger is configured in API Management, you can configure your [log-to-eventhub](api-management-advanced-policies.md#log-to-event-hub) policy to log the desired events. The `log-to-eventhub` policy can be used in either the inbound policy section or the outbound policy section.
127
+
Once your logger is configured in API Management, you can configure your [log-to-eventhub](api-management-advanced-policies.md#log-to-eventhub) policy to log the desired events. For example, use the `log-to-eventhub` policy in the inbound policy section to log requests, or in the outbound policy section to log responses.
122
128
123
129
1. Browse to your API Management instance.
124
130
1. Select **APIs**, and then select the API to which you want to add the policy. In this example, we're adding a policy to the **Echo API** in the **Unlimited** product.
@@ -156,7 +162,7 @@ You can preview the log in Event Hubs by using [Azure Stream Analytics queries](
156
162
157
163
1. In the Azure portal, browse to the event hub that the logger sends events to.
158
164
2. Under **Features**, select the **Process data** tab.
159
-
3. On the **Enable real time insights from events** card, select **Explore**.
165
+
3. On the **Enable real time insights from events** card, select **Start**.
160
166
4. You should be able to preview the log on the **Input preview** tab. If the data shown isn't current, select **Refresh** to see the latest events.
161
167
162
168
## Next steps
@@ -169,12 +175,3 @@ You can preview the log in Event Hubs by using [Azure Stream Analytics queries](
0 commit comments