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: sdk/monitor/Azure.Monitor.Ingestion/README.md
+78-1Lines changed: 78 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,8 @@ We guarantee that all client instance methods are thread-safe and independent of
88
88
89
89
-[Register the client with dependency injection](#register-the-client-with-dependency-injection)
90
90
-[Upload custom logs](#upload-custom-logs)
91
+
-[Upload custom logs as IEnumerable](#upload-custom-logs-ienumerable)
92
+
-[Upload custom logs as IEnumerable with EventHandler](#upload-custom-logs-ienumerable-eventhandler)
91
93
-[Verify logs](#verify-logs)
92
94
93
95
You can familiarize yourself with different APIs using [samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/monitor/Azure.Monitor.Ingestion/samples).
@@ -98,7 +100,7 @@ To register `LogsIngestionClient` with the dependency injection (DI) container,
98
100
99
101
### Upload custom logs
100
102
101
-
You can upload logs using either the `LogsIngestionClient.Upload` or the `LogsIngestionClient.UploadAsync` method. Note the data ingestion [limits](https://learn.microsoft.com/azure/azure-monitor/service-limits#custom-logs).
103
+
You can upload logs using either the `LogsIngestionClient.Upload` or the `LogsIngestionClient.UploadAsync` method. Note the data ingestion [limits](https://learn.microsoft.com/azure/azure-monitor/service-limits#custom-logs). This method has an optional parameter: string contentEncoding. This refers to the encoding of the RequestContent that is being passed in. If you are passing in content that is already manipulated, set the contentEncoding parameter. For example if your content is gzipped, set contentEncoding to be "gzip". The default behavior if this parameter is not set is to `gzip` all input.
You can also upload logs using either the `LogsIngestionClient.Upload` or the `LogsIngestionClient.UploadAsync` method in which logs are passed in a generic `IEnumerable` type along with an optional `LogsUploadOptions` parameter. The `LogsUploadOptions` parameter includes a serializer, concurrency, and an EventHandler.
### Upload custom logs as IEnumerable with EventHandler
183
+
184
+
You can upload logs using either the `LogsIngestionClient.Upload` or the `LogsIngestionClient.UploadAsync` method. In these two methods, logs are passed in a generic `IEnumerable` type. Additionally, there's an `LogsUploadOptions`-typed parameter in which a serializer, concurrency, and EventHandler can be set. The default serializer is set to `System.Text.Json`, but you can pass in the serializer you would like used. The `MaxConcurrency` property sets the number of threads that will be used in the `UploadAsync` method. The default value is 5, and this parameter is unused in the `Upload` method. The EventHandler is used for error handling. It gives the user the option to abort the upload if a batch fails and access the failed logs and corresponding exception. Without the EventHandler, if an upload fails, an `AggregateException` will be thrown.
// Throw exception from EventHandler to stop Upload if there is a failure
218
+
IReadOnlyList<object>failedLogs=e.FailedLogs;
219
+
// 413 status is RequestTooLarge - don't throw here because other batches can successfully upload
220
+
if ((e.ExceptionisRequestFailedException) && (((RequestFailedException)e.Exception).Status!=413))
221
+
throwe.Exception;
222
+
else
223
+
returnTask.CompletedTask;
224
+
}
225
+
```
226
+
150
227
### Verify logs
151
228
152
229
You can verify that your data has been uploaded correctly by using the [Azure Monitor Query](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.Query/README.md#install-the-package) library. Run the [Upload custom logs](#upload-custom-logs) sample first before verifying the logs.
0 commit comments