@SdkInternalApi
    final PutMetricStreamResult executePutMetricStream(PutMetricStreamRequest putMetricStreamRequest) {

        ExecutionContext executionContext = createExecutionContext(putMetricStreamRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<PutMetricStreamRequest> request = null;
        Response<PutMetricStreamResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new PutMetricStreamRequestMarshaller().marshall(super.beforeMarshalling(putMetricStreamRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "CloudWatch");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PutMetricStream");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            StaxResponseHandler<PutMetricStreamResult> responseHandler = new StaxResponseHandler<PutMetricStreamResult>(
                    new PutMetricStreamResultStaxUnmarshaller());

            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
Creates or updates a metric stream. Metric streams can automatically stream CloudWatch metrics to Amazon Web
Services destinations, including Amazon S3, and to many third-party solutions.
</p>
<p>
For more information, see <a
href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Metric-Streams.html"> Using
Metric Streams</a>.
</p>
<p>
To create a metric stream, you must be signed in to an account that has the <code>iam:PassRole</code> permission
and either the <code>CloudWatchFullAccess</code> policy or the <code>cloudwatch:PutMetricStream</code>
permission.
</p>
<p>
When you create or update a metric stream, you choose one of the following:
</p>
<ul>
<li>
<p>
Stream metrics from all metric namespaces in the account.
</p>
</li>
<li>
<p>
Stream metrics from all metric namespaces in the account, except for the namespaces that you list in
<code>ExcludeFilters</code>.
</p>
</li>
<li>
<p>
Stream metrics from only the metric namespaces that you list in <code>IncludeFilters</code>.
</p>
</li>
</ul>
<p>
By default, a metric stream always sends the <code>MAX</code>, <code>MIN</code>, <code>SUM</code>, and
<code>SAMPLECOUNT</code> statistics for each metric that is streamed. You can use the
<code>StatisticsConfigurations</code> parameter to have the metric stream send additional statistics in the
stream. Streaming additional statistics incurs additional costs. For more information, see <a
href="https://aws.amazon.com/cloudwatch/pricing/">Amazon CloudWatch Pricing</a>.
</p>
<p>
When you use <code>PutMetricStream</code> to create a new metric stream, the stream is created in the
<code>running</code> state. If you use it to update an existing stream, the state of the stream is not changed.
</p>
<p>
If you are using CloudWatch cross-account observability and you create a metric stream in a monitoring account,
you can choose whether to include metrics from source accounts in the stream. For more information, see <a
href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html"
>CloudWatch cross-account observability</a>.
</p>

@param putMetricStreamRequest
@return Result of the PutMetricStream operation returned by the service.
@throws ConcurrentModificationException
        More than one process tried to modify a resource at the same time.
@throws InternalServiceException
        Request processing has failed due to some unknown error, exception, or failure.
@throws InvalidParameterValueException
        The value of an input parameter is bad or out-of-range.
@throws MissingRequiredParameterException
        An input parameter that is required is missing.
@throws InvalidParameterCombinationException
        Parameters were used together that cannot be used together.
@sample AmazonCloudWatch.PutMetricStream
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/monitoring-2010-08-01/PutMetricStream" target="_top">AWS API
     Documentation</a>
aws-java-sdk-cloudwatch/src/main/java/com/amazonaws/services/cloudwatch/AmazonCloudWatchClient.java