azure-docs-sdk-java/docs-ref-autogen/com.azure.monitor.ingestion...

120 строки
18 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.monitor.ingestion.LogsIngestionClient"
fullName: "com.azure.monitor.ingestion.LogsIngestionClient"
name: "LogsIngestionClient"
nameWithType: "LogsIngestionClient"
summary: "This class provides a synchronous client for uploading custom logs to an Azure Monitor Log Analytics workspace."
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedClassMethods:
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
methodsRef:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
syntax: "public final class **LogsIngestionClient**</br> implements <a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html\">AutoCloseable</a>"
methods:
- uid: "com.azure.monitor.ingestion.LogsIngestionClient.close()"
fullName: "com.azure.monitor.ingestion.LogsIngestionClient.close()"
name: "close()"
nameWithType: "LogsIngestionClient.close()"
syntax: "public void close()"
- uid: "com.azure.monitor.ingestion.LogsIngestionClient.upload(java.lang.String,java.lang.String,java.lang.Iterable<java.lang.Object>)"
fullName: "com.azure.monitor.ingestion.LogsIngestionClient.upload(String ruleId, String streamName, Iterable<Object> logs)"
name: "upload(String ruleId, String streamName, Iterable<Object> logs)"
nameWithType: "LogsIngestionClient.upload(String ruleId, String streamName, Iterable<Object> logs)"
summary: "Uploads logs to Azure Monitor with specified data collection rule id and stream name."
parameters:
- description: "the data collection rule id that is configured to collect and transform the logs."
name: "ruleId"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the stream name configured in data collection rule that matches defines the structure of the\n logs sent in this request."
name: "streamName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the collection of logs to be uploaded."
name: "logs"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>&gt;"
syntax: "public void upload(String ruleId, String streamName, Iterable<Object> logs)"
desc: "Uploads logs to Azure Monitor with specified data collection rule id and stream name. The input logs may be too large to be sent as a single request to the Azure Monitor service. In such cases, this method will split the input logs into multiple smaller requests before sending to the service. This method will block until all the logs are uploaded or an error occurs.\n\nEach log in the input collection must be a valid JSON object. The JSON object should match the [schema defined by the stream name][]. The stream's schema can be found in the Azure portal.\n\n**Upload logs to Azure Monitor**\n\n```java\nList<Object> logs = getLogs();\n logsIngestionClient.upload(\"<data-collection-rule-id>\", \"<stream-name>\", logs);\n System.out.println(\"Logs uploaded successfully\");\n```\n\n\n[schema defined by the stream name]: https://learn.microsoft.com/azure/azure-monitor/essentials/data-collection-rule-structure#streamdeclarations"
- uid: "com.azure.monitor.ingestion.LogsIngestionClient.upload(java.lang.String,java.lang.String,java.lang.Iterable<java.lang.Object>,com.azure.monitor.ingestion.models.LogsUploadOptions)"
fullName: "com.azure.monitor.ingestion.LogsIngestionClient.upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options)"
name: "upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options)"
nameWithType: "LogsIngestionClient.upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options)"
summary: "Uploads logs to Azure Monitor with specified data collection rule id and stream name."
parameters:
- description: "the data collection rule id that is configured to collect and transform the logs."
name: "ruleId"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the stream name configured in data collection rule that matches defines the structure of the\n logs sent in this request."
name: "streamName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the collection of logs to be uploaded."
name: "logs"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>&gt;"
- description: "the options to configure the upload request."
name: "options"
type: "<xref href=\"com.azure.monitor.ingestion.models.LogsUploadOptions?alt=com.azure.monitor.ingestion.models.LogsUploadOptions&text=LogsUploadOptions\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options)"
desc: "Uploads logs to Azure Monitor with specified data collection rule id and stream name. The input logs may be too large to be sent as a single request to the Azure Monitor service. In such cases, this method will split the input logs into multiple smaller requests before sending to the service. This method will block until all the logs are uploaded or an error occurs. If an <xref uid=\"com.azure.monitor.ingestion.models.LogsUploadOptions.setLogsUploadErrorConsumer(java.util.function.Consumer<com.azure.monitor.ingestion.models.LogsUploadError>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"error handler\"></xref> is set, then the service errors are surfaced to the error handler and this method won't throw an exception.\n\nEach log in the input collection must be a valid JSON object. The JSON object should match the [schema defined by the stream name][]. The stream's schema can be found in the Azure portal.\n\n**Upload logs to Azure Monitor**\n\n```java\nList<Object> logs = getLogs();\n LogsUploadOptions logsUploadOptions = new LogsUploadOptions().setMaxConcurrency(4);\n logsIngestionClient.upload(\"<data-collection-rule-id>\", \"<stream-name>\", logs,\n logsUploadOptions, Context.NONE);\n System.out.println(\"Logs uploaded successfully\");\n```\n\n\n[schema defined by the stream name]: https://learn.microsoft.com/azure/azure-monitor/essentials/data-collection-rule-structure#streamdeclarations"
- uid: "com.azure.monitor.ingestion.LogsIngestionClient.upload(java.lang.String,java.lang.String,java.lang.Iterable<java.lang.Object>,com.azure.monitor.ingestion.models.LogsUploadOptions,com.azure.core.util.Context)"
fullName: "com.azure.monitor.ingestion.LogsIngestionClient.upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options, Context context)"
name: "upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options, Context context)"
nameWithType: "LogsIngestionClient.upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options, Context context)"
summary: "Uploads logs to Azure Monitor with specified data collection rule id and stream name."
parameters:
- description: "the data collection rule id that is configured to collect and transform the logs."
name: "ruleId"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the stream name configured in data collection rule that matches defines the structure of the\n logs sent in this request."
name: "streamName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the collection of logs to be uploaded."
name: "logs"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html\">Iterable</a>&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>&gt;"
- description: "the options to configure the upload request."
name: "options"
type: "<xref href=\"com.azure.monitor.ingestion.models.LogsUploadOptions?alt=com.azure.monitor.ingestion.models.LogsUploadOptions&text=LogsUploadOptions\" data-throw-if-not-resolved=\"False\" />"
- description: "additional context that is passed through the Http pipeline during the service call. If no\n additional context is required, pass <xref uid=\"com.azure.core.util.Context.NONE\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Context#NONE\"></xref> instead."
name: "context"
type: "<xref href=\"com.azure.core.util.Context?alt=com.azure.core.util.Context&text=Context\" data-throw-if-not-resolved=\"False\" />"
syntax: "public void upload(String ruleId, String streamName, Iterable<Object> logs, LogsUploadOptions options, Context context)"
desc: "Uploads logs to Azure Monitor with specified data collection rule id and stream name. The input logs may be too large to be sent as a single request to the Azure Monitor service. In such cases, this method will split the input logs into multiple smaller requests before sending to the service. This method will block until all the logs are uploaded or an error occurs. If an <xref uid=\"com.azure.monitor.ingestion.models.LogsUploadOptions.setLogsUploadErrorConsumer(java.util.function.Consumer<com.azure.monitor.ingestion.models.LogsUploadError>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"error handler\"></xref> is set, then the service errors are surfaced to the error handler and this method won't throw an exception.\n\nEach log in the input collection must be a valid JSON object. The JSON object should match the [schema defined by the stream name][]. The stream's schema can be found in the Azure portal.\n\n\n[schema defined by the stream name]: https://learn.microsoft.com/azure/azure-monitor/essentials/data-collection-rule-structure#streamdeclarations"
- uid: "com.azure.monitor.ingestion.LogsIngestionClient.uploadWithResponse(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)"
fullName: "com.azure.monitor.ingestion.LogsIngestionClient.uploadWithResponse(String ruleId, String streamName, BinaryData logs, RequestOptions requestOptions)"
name: "uploadWithResponse(String ruleId, String streamName, BinaryData logs, RequestOptions requestOptions)"
nameWithType: "LogsIngestionClient.uploadWithResponse(String ruleId, String streamName, BinaryData logs, RequestOptions requestOptions)"
summary: "This method is used to upload logs to Azure Monitor Log Analytics with specified data collection rule id and stream name."
parameters:
- description: "The immutable Id of the Data Collection Rule resource."
name: "ruleId"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "The streamDeclaration name as defined in the Data Collection Rule."
name: "streamName"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "An array of objects matching the schema defined by the provided stream."
name: "logs"
type: "<xref href=\"com.azure.core.util.BinaryData?alt=com.azure.core.util.BinaryData&text=BinaryData\" data-throw-if-not-resolved=\"False\" />"
- description: "The options to configure the HTTP request before HTTP client sends it."
name: "requestOptions"
type: "<xref href=\"com.azure.core.http.rest.RequestOptions?alt=com.azure.core.http.rest.RequestOptions&text=RequestOptions\" data-throw-if-not-resolved=\"False\" />"
syntax: "public Response<Void> uploadWithResponse(String ruleId, String streamName, BinaryData logs, RequestOptions requestOptions)"
desc: "This method is used to upload logs to Azure Monitor Log Analytics with specified data collection rule id and stream name. This upload method provides a more granular control of the HTTP request sent to the service. Use <xref uid=\"com.azure.core.http.rest.RequestOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"RequestOptions\"></xref> to configure the HTTP request.\n\nThe input logs should be a JSON array with each element in the array matching the [schema defined by the stream name][]. The stream's schema can be found in the Azure portal. This content will be gzipped before sending to the service. If the content is already gzipped, then set the `Content-Encoding` header to `gzip` using <xref uid=\"com.azure.core.http.rest.RequestOptions.setHeader*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"requestOptions\"></xref> and pass the content as is.\n\n**Header Parameters**\n\n | ---------------------- | ------ | -------- | ----------------- |\n | Name | Type | Required | Description |\n | Content-Encoding | String | No | gzip |\n | x-ms-client-request-id | String | No | Client request Id |\n\n**Request Body Schema**\n\n```java\n[\n Object\n ]\n```\n\n\n[schema defined by the stream name]: https://learn.microsoft.com/azure/azure-monitor/essentials/data-collection-rule-structure#streamdeclarations"
returns:
description: "the <xref uid=\"com.azure.core.http.rest.Response\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Response\"></xref>."
type: "<xref href=\"com.azure.core.http.rest.Response?alt=com.azure.core.http.rest.Response&text=Response\" data-throw-if-not-resolved=\"False\" />&lt;<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html\">Void</a>&gt;"
type: "class"
desc: "This class provides a synchronous client for uploading custom logs to an Azure Monitor Log Analytics workspace. This client encapsulates REST API calls, used to send data to a Log Analytics workspace, into a set of synchronous operations.\n\n## Getting Started ##\n\nTo create an instance of the <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"LogsIngestionClient\"></xref>, use the <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"LogsIngestionClientBuilder\"></xref> and configure the various options provided by the builder to customize the client as per your requirements. There are two required properties that should be set to build a client:\n\n1. `endpoint` \\- The [data collection endpoint][]. See <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClientBuilder.endpoint(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"endpoint\"></xref> method for more details.\n2. `credential` \\- The AAD authentication credential that has the \"Monitoring Metrics Publisher\" role assigned to it. [Azure Identity][] provides a variety of AAD credential types that can be used. See <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClientBuilder.credential(com.azure.core.credential.TokenCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"credential\"></xref> method for more details.\n\n**Instantiating a synchronous Logs ingestion client**\n\n```java\nLogsIngestionClient logsIngestionClient = new LogsIngestionClientBuilder()\n .credential(tokenCredential)\n .endpoint(\"<data-collection-endpoint>\")\n .buildClient();\n```\n\n### Client Usage ###\n\nFor additional information on how to use this client, see the following method documentation:\n\n * <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClient.upload(java.lang.String,java.lang.String,java.lang.Iterable<java.lang.Object>)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"upload(String, String, Iterable)\"></xref> \\- Uploads logs to a Log Analytics workspace.\n * <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClient.upload(java.lang.String,java.lang.String,java.lang.Iterable<java.lang.Object>,com.azure.monitor.ingestion.models.LogsUploadOptions)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"upload(String, String, Iterable, LogsUploadOptions)\"></xref> \\- Uploads logs to a Log Analytics workspace with options to configure the upload request.\n * <xref uid=\"com.azure.monitor.ingestion.LogsIngestionClient.uploadWithResponse(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"uploadWithResponse(String, String, BinaryData, RequestOptions)\"></xref> \\- Uploads logs to a Log Analytics workspace with options to configure the HTTP request.\n\n\n[data collection endpoint]: https://learn.microsoft.com/azure/azure-monitor/essentials/data-collection-endpoint-overview?tabs=portal#create-a-data-collection-endpoint\n[Azure Identity]: https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable"
implements:
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html\">AutoCloseable</a>"
metadata: {}
package: "com.azure.monitor.ingestion"
artifact: com.azure:azure-monitor-ingestion:1.2.4