/* * Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.logs.model; import java.io.Serializable; import javax.annotation.Generated; import com.amazonaws.protocol.StructuredPojo; import com.amazonaws.protocol.ProtocolMarshaller; /** *
* Indicates how to transform ingested log events to metric data in a CloudWatch metric. *
* * @see AWS API * Documentation */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class MetricTransformation implements Serializable, Cloneable, StructuredPojo { /** ** The name of the CloudWatch metric. *
*/ private String metricName; /** ** A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are * similar. For more information, see Namespaces. *
*/ private String metricNamespace; /** ** The value to publish to the CloudWatch metric when a filter pattern matches a log event. *
*/ private String metricValue; /** ** (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. *
*/ private Double defaultValue; /** ** The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not
* specify high-cardinality fields such as IPAddress
or requestID
as dimensions. Each
* different value found for a dimension is treated as a separate metric and accrues charges as a separate custom
* metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified * dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, * see * Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
*
* The unit to assign to the metric. If you omit this, the unit is set as None
.
*
* The name of the CloudWatch metric. *
* * @param metricName * The name of the CloudWatch metric. */ public void setMetricName(String metricName) { this.metricName = metricName; } /** ** The name of the CloudWatch metric. *
* * @return The name of the CloudWatch metric. */ public String getMetricName() { return this.metricName; } /** ** The name of the CloudWatch metric. *
* * @param metricName * The name of the CloudWatch metric. * @return Returns a reference to this object so that method calls can be chained together. */ public MetricTransformation withMetricName(String metricName) { setMetricName(metricName); return this; } /** ** A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are * similar. For more information, see Namespaces. *
* * @param metricNamespace * A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are * similar. For more information, see Namespaces. */ public void setMetricNamespace(String metricNamespace) { this.metricNamespace = metricNamespace; } /** ** A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are * similar. For more information, see Namespaces. *
* * @return A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that * are similar. For more information, see Namespaces. */ public String getMetricNamespace() { return this.metricNamespace; } /** ** A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are * similar. For more information, see Namespaces. *
* * @param metricNamespace * A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are * similar. For more information, see Namespaces. * @return Returns a reference to this object so that method calls can be chained together. */ public MetricTransformation withMetricNamespace(String metricNamespace) { setMetricNamespace(metricNamespace); return this; } /** ** The value to publish to the CloudWatch metric when a filter pattern matches a log event. *
* * @param metricValue * The value to publish to the CloudWatch metric when a filter pattern matches a log event. */ public void setMetricValue(String metricValue) { this.metricValue = metricValue; } /** ** The value to publish to the CloudWatch metric when a filter pattern matches a log event. *
* * @return The value to publish to the CloudWatch metric when a filter pattern matches a log event. */ public String getMetricValue() { return this.metricValue; } /** ** The value to publish to the CloudWatch metric when a filter pattern matches a log event. *
* * @param metricValue * The value to publish to the CloudWatch metric when a filter pattern matches a log event. * @return Returns a reference to this object so that method calls can be chained together. */ public MetricTransformation withMetricValue(String metricValue) { setMetricValue(metricValue); return this; } /** ** (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. *
* * @param defaultValue * (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. */ public void setDefaultValue(Double defaultValue) { this.defaultValue = defaultValue; } /** ** (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. *
* * @return (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. */ public Double getDefaultValue() { return this.defaultValue; } /** ** (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. *
* * @param defaultValue * (Optional) The value to emit when a filter pattern does not match a log event. This value can be null. * @return Returns a reference to this object so that method calls can be chained together. */ public MetricTransformation withDefaultValue(Double defaultValue) { setDefaultValue(defaultValue); return this; } /** ** The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not
* specify high-cardinality fields such as IPAddress
or requestID
as dimensions. Each
* different value found for a dimension is treated as a separate metric and accrues charges as a separate custom
* metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified * dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, * see * Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do
* not specify high-cardinality fields such as IPAddress
or requestID
as
* dimensions. Each different value found for a dimension is treated as a separate metric and accrues
* charges as a separate custom metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your * specified dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more * information, see Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
*/ public java.util.Map* The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not
* specify high-cardinality fields such as IPAddress
or requestID
as dimensions. Each
* different value found for a dimension is treated as a separate metric and accrues charges as a separate custom
* metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified * dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, * see * Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do
* not specify high-cardinality fields such as IPAddress
or requestID
as
* dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges
* as a separate custom metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your * specified dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more * information, see Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
*/ public void setDimensions(java.util.Map* The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not
* specify high-cardinality fields such as IPAddress
or requestID
as dimensions. Each
* different value found for a dimension is treated as a separate metric and accrues charges as a separate custom
* metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified * dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, * see * Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
*
* Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do
* not specify high-cardinality fields such as IPAddress
or requestID
as
* dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges
* as a separate custom metric.
*
* CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your * specified dimensions within a certain amount of time. This helps to prevent accidental high charges. *
** You can also set up a billing alarm to alert you if your charges are higher than expected. For more * information, see Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges. *
* @return Returns a reference to this object so that method calls can be chained together. */ public MetricTransformation withDimensions(java.util.Map
* The unit to assign to the metric. If you omit this, the unit is set as None
.
*
None
.
* @see StandardUnit
*/
public void setUnit(String unit) {
this.unit = unit;
}
/**
*
* The unit to assign to the metric. If you omit this, the unit is set as None
.
*
None
.
* @see StandardUnit
*/
public String getUnit() {
return this.unit;
}
/**
*
* The unit to assign to the metric. If you omit this, the unit is set as None
.
*
None
.
* @return Returns a reference to this object so that method calls can be chained together.
* @see StandardUnit
*/
public MetricTransformation withUnit(String unit) {
setUnit(unit);
return this;
}
/**
*
* The unit to assign to the metric. If you omit this, the unit is set as None
.
*
None
.
* @return Returns a reference to this object so that method calls can be chained together.
* @see StandardUnit
*/
public MetricTransformation withUnit(StandardUnit unit) {
this.unit = unit.toString();
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getMetricName() != null)
sb.append("MetricName: ").append(getMetricName()).append(",");
if (getMetricNamespace() != null)
sb.append("MetricNamespace: ").append(getMetricNamespace()).append(",");
if (getMetricValue() != null)
sb.append("MetricValue: ").append(getMetricValue()).append(",");
if (getDefaultValue() != null)
sb.append("DefaultValue: ").append(getDefaultValue()).append(",");
if (getDimensions() != null)
sb.append("Dimensions: ").append(getDimensions()).append(",");
if (getUnit() != null)
sb.append("Unit: ").append(getUnit());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof MetricTransformation == false)
return false;
MetricTransformation other = (MetricTransformation) obj;
if (other.getMetricName() == null ^ this.getMetricName() == null)
return false;
if (other.getMetricName() != null && other.getMetricName().equals(this.getMetricName()) == false)
return false;
if (other.getMetricNamespace() == null ^ this.getMetricNamespace() == null)
return false;
if (other.getMetricNamespace() != null && other.getMetricNamespace().equals(this.getMetricNamespace()) == false)
return false;
if (other.getMetricValue() == null ^ this.getMetricValue() == null)
return false;
if (other.getMetricValue() != null && other.getMetricValue().equals(this.getMetricValue()) == false)
return false;
if (other.getDefaultValue() == null ^ this.getDefaultValue() == null)
return false;
if (other.getDefaultValue() != null && other.getDefaultValue().equals(this.getDefaultValue()) == false)
return false;
if (other.getDimensions() == null ^ this.getDimensions() == null)
return false;
if (other.getDimensions() != null && other.getDimensions().equals(this.getDimensions()) == false)
return false;
if (other.getUnit() == null ^ this.getUnit() == null)
return false;
if (other.getUnit() != null && other.getUnit().equals(this.getUnit()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getMetricName() == null) ? 0 : getMetricName().hashCode());
hashCode = prime * hashCode + ((getMetricNamespace() == null) ? 0 : getMetricNamespace().hashCode());
hashCode = prime * hashCode + ((getMetricValue() == null) ? 0 : getMetricValue().hashCode());
hashCode = prime * hashCode + ((getDefaultValue() == null) ? 0 : getDefaultValue().hashCode());
hashCode = prime * hashCode + ((getDimensions() == null) ? 0 : getDimensions().hashCode());
hashCode = prime * hashCode + ((getUnit() == null) ? 0 : getUnit().hashCode());
return hashCode;
}
@Override
public MetricTransformation clone() {
try {
return (MetricTransformation) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.logs.model.transform.MetricTransformationMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}