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
# How to log events to Azure Event Hubs in Azure API Management
15
-
Azure Event Hubs is a highly scalable data ingress service that can ingest millions of events per second so that you can process and analyze the massive amounts of data produced by your connected devices and applications. Event Hubs acts as the "front door" for an event pipeline, and once data is collected into an event hub, it can be transformed and stored using any real-time analytics provider or batching/storage adapters. Event Hubs decouples the production of a stream of events from the consumption of those events, so that event consumers can access the events on their own schedule.
16
15
17
16
This article describes how to log API Management events using Azure Event Hubs.
18
17
18
+
Azure Event Hubs is a highly scalable data ingress service that can ingest millions of events per second so that you can process and analyze the massive amounts of data produced by your connected devices and applications. Event Hubs acts as the "front door" for an event pipeline, and once data is collected into an event hub, it can be transformed and stored using any real-time analytics provider or batching/storage adapters. Event Hubs decouples the production of a stream of events from the consumption of those events, so that event consumers can access the events on their own schedule.
19
+
19
20
## Prerequisites
20
21
21
22
* An API Management service instance. If you don't have one, see [Create an API Management service instance](get-started-create-service-instance.md).
@@ -25,7 +26,7 @@ This article describes how to log API Management events using Azure Event Hubs.
25
26
26
27
## Configure access to the event hub
27
28
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
+
To log events to the event hub, you need to configure credentials for access from API Management. API Management supports either of the two following access mechanisms:
29
30
30
31
* An event hub connection string
31
32
* A managed identity for your API Management instance.
@@ -51,7 +52,7 @@ To create an Event Hubs connection string, see [Get an Event Hubs connection str
51
52
## Create an API Management logger
52
53
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.
53
54
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.
55
+
Create and manage API Management loggers by using the [API Management REST API](/rest/api/apimanagement/current-preview/logger/create-or-update) directly or by using tools including [Azure PowerShell](/powershell/module/az.apimanagement/new-azapimanagementlogger), a Bicep template, or an Azure Resource Management template.
"description": "Event hub logger with connection string",
112
-
"loggerType": "azureEventHub",
113
-
"resourceId": "string"
114
109
}
115
110
}
116
111
```
117
112
---
118
113
119
114
### Logger with system-assigned managed identity credentials
120
115
116
+
See [Configure API Management managed identity](#configure-event-hub-connection-string).
117
+
118
+
#### [PowerShell](#tab/PowerShell)
119
+
120
+
Use the API Management [REST API](/rest/api/apimanagement/current-preview/logger/create-or-update) or a Bicep or ARM template to configure a logger to an event hub with system-assigned managed identity credentials.
121
+
122
+
#### [Bicep](#tab/bicep)
123
+
124
+
Include a snippet similar to the following in your Bicep template.
### Logger with user-assigned managed identity credentials
123
165
166
+
See [Configure API Management managed identity](#configure-event-hub-connection-string).
167
+
168
+
#### [PowerShell](#tab/PowerShell)
169
+
170
+
Use the API Management [REST API](/rest/api/apimanagement/current-preview/logger/create-or-update) or a Bicep or ARM template to configure a logger to an event hub with user-assigned managed identity credentials.
171
+
172
+
#### [Bicep](#tab/bicep)
173
+
174
+
Include a snippet similar the following in your Bicep template.
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.
218
+
Once your logger is configured in API Management, you can configure your [log-to-eventhub](log-to-eventhub-policy.md) 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.
128
219
129
220
1. Browse to your API Management instance.
130
221
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.
@@ -151,7 +242,7 @@ Once your logger is configured in API Management, you can configure your [log-to
151
242
1. Replace `logger-id` with the name of the logger that you created in the previous step.
152
243
1. You can use any expression that returns a string as the value for the `log-to-eventhub` element. In this example, a string in JSON format containing the date and time, service name, request ID, request IP address, and operation name is logged.
153
244
154
-
1. Select **Save** to save the updated policy configuration. As soon as it is saved, the policy is active and events are logged to the designated event hub.
245
+
1. Select **Save** to save the updated policy configuration. As soon as it's saved, the policy is active and events are logged to the designated event hub.
155
246
156
247
> [!NOTE]
157
248
> The maximum supported message size that can be sent to an event hub from this API Management policy is 200 kilobytes (KB). If a message that is sent to an event hub is larger than 200 KB, it will be automatically truncated, and the truncated message will be transferred to the event hub.
@@ -171,7 +262,6 @@ You can preview the log in Event Hubs by using [Azure Stream Analytics queries](
171
262
* [Receive messages with EventProcessorHost](../event-hubs/event-hubs-dotnet-standard-getstarted-send.md)
0 commit comments