/// <summary> /// Publishes raw metric data points to the Monitoring service. /// For more information about publishing metrics, see [Publishing Custom Metrics](https://docs.cloud.oracle.com/iaas/Content/Monitoring/Tasks/publishingcustommetrics.htm). /// For important limits information, see [Limits on Monitoring](https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits). /// <br/> /// Per-call limits information follows. /// <br/> /// * Dimensions per metric group*. Maximum: 20. Minimum: 1. /// * Unique metric streams*. Maximum: 50. /// * Transactions Per Second (TPS) per-tenancy limit for this operation: 50. /// <br/> /// *A metric group is the combination of a given metric, metric namespace, and tenancy for the purpose of determining limits. /// A dimension is a qualifier provided in a metric definition. /// A metric stream is an individual set of aggregated data for a metric, typically specific to a resource. /// For more information about metric-related concepts, see [Monitoring Concepts](https://docs.cloud.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#concepts). /// <br/> /// The endpoints for this operation differ from other Monitoring operations. Replace the string `telemetry` with `telemetry-ingestion` in the endpoint, as in the following example: /// <br/> /// https://telemetry-ingestion.eu-frankfurt-1.oraclecloud.com /// /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/monitoring/PostMetricData.cs.html">here</a> to see an example of how to use PostMetricData API.</example> public async Task <PostMetricDataResponse> PostMetricData(PostMetricDataRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called postMetricData"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/metrics".Trim('/'))); HttpMethod method = new HttpMethod("POST"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false); } else { responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false); } this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage); return(Converter.FromHttpResponseMessage <PostMetricDataResponse>(responseMessage)); } catch (Exception e) { logger.Error($"PostMetricData failed with error: {e.Message}"); throw; } }
protected override void ProcessRecord() { base.ProcessRecord(); PostMetricDataRequest request; try { request = new PostMetricDataRequest { PostMetricDataDetails = PostMetricDataDetails, OpcRequestId = OpcRequestId }; response = client.PostMetricData(request).GetAwaiter().GetResult(); WriteOutput(response, response.PostMetricDataResponseDetails); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Publishes raw metric data points to the Monitoring service. /// For more information about publishing metrics, see Publishing Custom Metrics. For important limits information, see Limits on Monitoring. /// /// Per-call limits information follows. /// * Dimensions per metric group*. Maximum: 20. Minimum: 1. /// * Unique metric streams*. Maximum: 50. /// * Transactions Per Second (TPS) per-tenancy limit for this operation: 50. /// /// A metric group is the combination of a given metric, metric namespace, and tenancy for the purpose of determining limits. /// A dimension is a qualifier provided in a metric definition. A metric stream is an individual set of aggregated data for a metric, /// typically specific to a resource. For more information about metric-related concepts, see Monitoring Concepts. /// /// The endpoints for this operation differ from other Monitoring operations. /// Replace the string telemetry with telemetry-ingestion in the endpoint, as in the following example: /// https://telemetry-ingestion.eu-frankfurt-1.oraclecloud.com /// </summary> /// <param name="param"></param> /// <returns></returns> public async Task <PostMetricDataResponse> PostMetricData(PostMetricDataRequest param) { var uri = new Uri($"https://" + $"{Config.GetHostName(IngestionServiceName, this.Region)}/" + $"{Config.GetServiceVersion(ServiceName)}/" + $"{MonitoringServices.Metrics}"); using (var webResponse = await this.RestClientAsync.Post(uri, param.PostMetricDataDetails, new HttpRequestHeaderParam() { OpcRequestId = param.OpcRequestId })) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = await reader.ReadToEndAsync(); return(new PostMetricDataResponse() { PostMetricDataResponseDetails = JsonSerializer.Deserialize <PostMetricDataResponseDetails>(response), OpcRequestId = webResponse.Headers.Get("opc-request-id") }); } }