aws_sdk_cloudwatchlogs/operation/create_log_anomaly_detector/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_log_anomaly_detector::_create_log_anomaly_detector_output::CreateLogAnomalyDetectorOutputBuilder;
3
4pub use crate::operation::create_log_anomaly_detector::_create_log_anomaly_detector_input::CreateLogAnomalyDetectorInputBuilder;
5
6impl crate::operation::create_log_anomaly_detector::builders::CreateLogAnomalyDetectorInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_log_anomaly_detector();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateLogAnomalyDetector`.
24///
25/// <p>Creates an <i>anomaly detector</i> that regularly scans one or more log groups and look for patterns and anomalies in the logs.</p>
26/// <p>An anomaly detector can help surface issues by automatically discovering anomalies in your log event traffic. An anomaly detector uses machine learning algorithms to scan log events and find <i>patterns</i>. A pattern is a shared text structure that recurs among your log fields. Patterns provide a useful tool for analyzing large sets of logs because a large number of log events can often be compressed into a few patterns.</p>
27/// <p>The anomaly detector uses pattern recognition to find <code>anomalies</code>, which are unusual log events. It uses the <code>evaluationFrequency</code> to compare current log events and patterns with trained baselines.</p>
28/// <p>Fields within a pattern are called <i>tokens</i>. Fields that vary within a pattern, such as a request ID or timestamp, are referred to as <i>dynamic tokens</i> and represented by <code>&lt;*&gt;</code>.</p>
29/// <p>The following is an example of a pattern:</p>
30/// <p><code>\[INFO\] Request time: &lt;*&gt; ms</code></p>
31/// <p>This pattern represents log events like <code>\[INFO\] Request time: 327 ms</code> and other similar log events that differ only by the number, in this csse 327. When the pattern is displayed, the different numbers are replaced by <code>&lt;*&gt;</code></p><note>
32/// <p>Any parts of log events that are masked as sensitive data are not scanned for anomalies. For more information about masking sensitive data, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/mask-sensitive-log-data.html">Help protect sensitive log data with masking</a>.</p>
33/// </note>
34#[derive(::std::clone::Clone, ::std::fmt::Debug)]
35pub struct CreateLogAnomalyDetectorFluentBuilder {
36    handle: ::std::sync::Arc<crate::client::Handle>,
37    inner: crate::operation::create_log_anomaly_detector::builders::CreateLogAnomalyDetectorInputBuilder,
38    config_override: ::std::option::Option<crate::config::Builder>,
39}
40impl
41    crate::client::customize::internal::CustomizableSend<
42        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorOutput,
43        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorError,
44    > for CreateLogAnomalyDetectorFluentBuilder
45{
46    fn send(
47        self,
48        config_override: crate::config::Builder,
49    ) -> crate::client::customize::internal::BoxFuture<
50        crate::client::customize::internal::SendResult<
51            crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorOutput,
52            crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorError,
53        >,
54    > {
55        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
56    }
57}
58impl CreateLogAnomalyDetectorFluentBuilder {
59    /// Creates a new `CreateLogAnomalyDetectorFluentBuilder`.
60    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
61        Self {
62            handle,
63            inner: ::std::default::Default::default(),
64            config_override: ::std::option::Option::None,
65        }
66    }
67    /// Access the CreateLogAnomalyDetector as a reference.
68    pub fn as_input(&self) -> &crate::operation::create_log_anomaly_detector::builders::CreateLogAnomalyDetectorInputBuilder {
69        &self.inner
70    }
71    /// Sends the request and returns the response.
72    ///
73    /// If an error occurs, an `SdkError` will be returned with additional details that
74    /// can be matched against.
75    ///
76    /// By default, any retryable failures will be retried twice. Retry behavior
77    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
78    /// set when configuring the client.
79    pub async fn send(
80        self,
81    ) -> ::std::result::Result<
82        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorOutput,
83        ::aws_smithy_runtime_api::client::result::SdkError<
84            crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorError,
85            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
86        >,
87    > {
88        let input = self
89            .inner
90            .build()
91            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
92        let runtime_plugins = crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetector::operation_runtime_plugins(
93            self.handle.runtime_plugins.clone(),
94            &self.handle.conf,
95            self.config_override,
96        );
97        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetector::orchestrate(&runtime_plugins, input).await
98    }
99
100    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
101    pub fn customize(
102        self,
103    ) -> crate::client::customize::CustomizableOperation<
104        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorOutput,
105        crate::operation::create_log_anomaly_detector::CreateLogAnomalyDetectorError,
106        Self,
107    > {
108        crate::client::customize::CustomizableOperation::new(self)
109    }
110    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
111        self.set_config_override(::std::option::Option::Some(config_override.into()));
112        self
113    }
114
115    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
116        self.config_override = config_override;
117        self
118    }
119    ///
120    /// Appends an item to `logGroupArnList`.
121    ///
122    /// To override the contents of this collection use [`set_log_group_arn_list`](Self::set_log_group_arn_list).
123    ///
124    /// <p>An array containing the ARN of the log group that this anomaly detector will watch. You can specify only one log group ARN.</p>
125    pub fn log_group_arn_list(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
126        self.inner = self.inner.log_group_arn_list(input.into());
127        self
128    }
129    /// <p>An array containing the ARN of the log group that this anomaly detector will watch. You can specify only one log group ARN.</p>
130    pub fn set_log_group_arn_list(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
131        self.inner = self.inner.set_log_group_arn_list(input);
132        self
133    }
134    /// <p>An array containing the ARN of the log group that this anomaly detector will watch. You can specify only one log group ARN.</p>
135    pub fn get_log_group_arn_list(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
136        self.inner.get_log_group_arn_list()
137    }
138    /// <p>A name for this anomaly detector.</p>
139    pub fn detector_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
140        self.inner = self.inner.detector_name(input.into());
141        self
142    }
143    /// <p>A name for this anomaly detector.</p>
144    pub fn set_detector_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
145        self.inner = self.inner.set_detector_name(input);
146        self
147    }
148    /// <p>A name for this anomaly detector.</p>
149    pub fn get_detector_name(&self) -> &::std::option::Option<::std::string::String> {
150        self.inner.get_detector_name()
151    }
152    /// <p>Specifies how often the anomaly detector is to run and look for anomalies. Set this value according to the frequency that the log group receives new logs. For example, if the log group receives new log events every 10 minutes, then 15 minutes might be a good setting for <code>evaluationFrequency</code> .</p>
153    pub fn evaluation_frequency(mut self, input: crate::types::EvaluationFrequency) -> Self {
154        self.inner = self.inner.evaluation_frequency(input);
155        self
156    }
157    /// <p>Specifies how often the anomaly detector is to run and look for anomalies. Set this value according to the frequency that the log group receives new logs. For example, if the log group receives new log events every 10 minutes, then 15 minutes might be a good setting for <code>evaluationFrequency</code> .</p>
158    pub fn set_evaluation_frequency(mut self, input: ::std::option::Option<crate::types::EvaluationFrequency>) -> Self {
159        self.inner = self.inner.set_evaluation_frequency(input);
160        self
161    }
162    /// <p>Specifies how often the anomaly detector is to run and look for anomalies. Set this value according to the frequency that the log group receives new logs. For example, if the log group receives new log events every 10 minutes, then 15 minutes might be a good setting for <code>evaluationFrequency</code> .</p>
163    pub fn get_evaluation_frequency(&self) -> &::std::option::Option<crate::types::EvaluationFrequency> {
164        self.inner.get_evaluation_frequency()
165    }
166    /// <p>You can use this parameter to limit the anomaly detection model to examine only log events that match the pattern you specify here. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html">Filter and Pattern Syntax</a>.</p>
167    pub fn filter_pattern(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
168        self.inner = self.inner.filter_pattern(input.into());
169        self
170    }
171    /// <p>You can use this parameter to limit the anomaly detection model to examine only log events that match the pattern you specify here. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html">Filter and Pattern Syntax</a>.</p>
172    pub fn set_filter_pattern(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
173        self.inner = self.inner.set_filter_pattern(input);
174        self
175    }
176    /// <p>You can use this parameter to limit the anomaly detection model to examine only log events that match the pattern you specify here. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html">Filter and Pattern Syntax</a>.</p>
177    pub fn get_filter_pattern(&self) -> &::std::option::Option<::std::string::String> {
178        self.inner.get_filter_pattern()
179    }
180    /// <p>Optionally assigns a KMS key to secure this anomaly detector and its findings. If a key is assigned, the anomalies found and the model used by this detector are encrypted at rest with the key. If a key is assigned to an anomaly detector, a user must have permissions for both this key and for the anomaly detector to retrieve information about the anomalies that it finds.</p>
181    /// <p>Make sure the value provided is a valid KMS key ARN. For more information about using a KMS key and to see the required IAM policy, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/LogsAnomalyDetection-KMS.html">Use a KMS key with an anomaly detector</a>.</p>
182    pub fn kms_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
183        self.inner = self.inner.kms_key_id(input.into());
184        self
185    }
186    /// <p>Optionally assigns a KMS key to secure this anomaly detector and its findings. If a key is assigned, the anomalies found and the model used by this detector are encrypted at rest with the key. If a key is assigned to an anomaly detector, a user must have permissions for both this key and for the anomaly detector to retrieve information about the anomalies that it finds.</p>
187    /// <p>Make sure the value provided is a valid KMS key ARN. For more information about using a KMS key and to see the required IAM policy, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/LogsAnomalyDetection-KMS.html">Use a KMS key with an anomaly detector</a>.</p>
188    pub fn set_kms_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
189        self.inner = self.inner.set_kms_key_id(input);
190        self
191    }
192    /// <p>Optionally assigns a KMS key to secure this anomaly detector and its findings. If a key is assigned, the anomalies found and the model used by this detector are encrypted at rest with the key. If a key is assigned to an anomaly detector, a user must have permissions for both this key and for the anomaly detector to retrieve information about the anomalies that it finds.</p>
193    /// <p>Make sure the value provided is a valid KMS key ARN. For more information about using a KMS key and to see the required IAM policy, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/LogsAnomalyDetection-KMS.html">Use a KMS key with an anomaly detector</a>.</p>
194    pub fn get_kms_key_id(&self) -> &::std::option::Option<::std::string::String> {
195        self.inner.get_kms_key_id()
196    }
197    /// <p>The number of days to have visibility on an anomaly. After this time period has elapsed for an anomaly, it will be automatically baselined and the anomaly detector will treat new occurrences of a similar anomaly as normal. Therefore, if you do not correct the cause of an anomaly during the time period specified in <code>anomalyVisibilityTime</code>, it will be considered normal going forward and will not be detected as an anomaly.</p>
198    pub fn anomaly_visibility_time(mut self, input: i64) -> Self {
199        self.inner = self.inner.anomaly_visibility_time(input);
200        self
201    }
202    /// <p>The number of days to have visibility on an anomaly. After this time period has elapsed for an anomaly, it will be automatically baselined and the anomaly detector will treat new occurrences of a similar anomaly as normal. Therefore, if you do not correct the cause of an anomaly during the time period specified in <code>anomalyVisibilityTime</code>, it will be considered normal going forward and will not be detected as an anomaly.</p>
203    pub fn set_anomaly_visibility_time(mut self, input: ::std::option::Option<i64>) -> Self {
204        self.inner = self.inner.set_anomaly_visibility_time(input);
205        self
206    }
207    /// <p>The number of days to have visibility on an anomaly. After this time period has elapsed for an anomaly, it will be automatically baselined and the anomaly detector will treat new occurrences of a similar anomaly as normal. Therefore, if you do not correct the cause of an anomaly during the time period specified in <code>anomalyVisibilityTime</code>, it will be considered normal going forward and will not be detected as an anomaly.</p>
208    pub fn get_anomaly_visibility_time(&self) -> &::std::option::Option<i64> {
209        self.inner.get_anomaly_visibility_time()
210    }
211    ///
212    /// Adds a key-value pair to `tags`.
213    ///
214    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
215    ///
216    /// <p>An optional list of key-value pairs to associate with the resource.</p>
217    /// <p>For more information about tagging, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services resources</a></p>
218    pub fn tags(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
219        self.inner = self.inner.tags(k.into(), v.into());
220        self
221    }
222    /// <p>An optional list of key-value pairs to associate with the resource.</p>
223    /// <p>For more information about tagging, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services resources</a></p>
224    pub fn set_tags(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
225        self.inner = self.inner.set_tags(input);
226        self
227    }
228    /// <p>An optional list of key-value pairs to associate with the resource.</p>
229    /// <p>For more information about tagging, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services resources</a></p>
230    pub fn get_tags(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
231        self.inner.get_tags()
232    }
233}