Autoscaling: Add metrics for E2 target tracking scaling (#6314)
This commit is contained in:
parent
f7b2478726
commit
523225d6e9
@ -1022,6 +1022,38 @@ DESCRIBE_SCALING_POLICIES_TEMPLATE = """<DescribePoliciesResponse xmlns="http://
|
|||||||
{% if policy.target_tracking_config["CustomizedMetricSpecification"].get("Unit") %}
|
{% if policy.target_tracking_config["CustomizedMetricSpecification"].get("Unit") %}
|
||||||
<Unit>{{ policy.target_tracking_config["CustomizedMetricSpecification"].get("Unit") }}</Unit>
|
<Unit>{{ policy.target_tracking_config["CustomizedMetricSpecification"].get("Unit") }}</Unit>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if policy.target_tracking_config["CustomizedMetricSpecification"].get("Metrics") %}
|
||||||
|
<Metrics>
|
||||||
|
{% for metric in policy.target_tracking_config["CustomizedMetricSpecification"].get("Metrics", []) %}
|
||||||
|
<member>
|
||||||
|
<Id>{{ metric.get("Id") }}</Id>
|
||||||
|
{% if metric.get("MetricStat") is none %}
|
||||||
|
<Expression>{{ metric.get("Expression") }}</Expression>
|
||||||
|
{% endif %}
|
||||||
|
{% if metric.get("Expression") is none %}
|
||||||
|
<MetricStat>
|
||||||
|
<Metric>
|
||||||
|
<Namespace>{{ metric.get("MetricStat", {}).get("Metric", {}).get("Namespace") }}</Namespace>
|
||||||
|
<MetricName>{{ metric.get("MetricStat", {}).get("Metric", {}).get("MetricName") }}</MetricName>
|
||||||
|
<Dimensions>
|
||||||
|
{% for dim in metric.get("MetricStat", {}).get("Metric", {}).get("Dimensions", []) %}
|
||||||
|
<member>
|
||||||
|
<Name>{{ dim.get("Name") }}</Name>
|
||||||
|
<Value>{{ dim.get("Value") }}</Value>
|
||||||
|
</member>
|
||||||
|
{% endfor %}
|
||||||
|
</Dimensions>
|
||||||
|
</Metric>
|
||||||
|
<Stat>{{ metric.get("MetricStat", {}).get("Stat") }}</Stat>
|
||||||
|
<Unit>{{ metric.get("MetricStat", {}).get("Unit") }}</Unit>
|
||||||
|
</MetricStat>
|
||||||
|
{% endif %}
|
||||||
|
<Label>{{ metric.get("Label") }}</Label>
|
||||||
|
<ReturnData>{{ 'true' if metric.get("ReturnData") is none else metric.get("ReturnData") }}</ReturnData>
|
||||||
|
</member>
|
||||||
|
{% endfor %}
|
||||||
|
</Metrics>
|
||||||
|
{% endif %}
|
||||||
</CustomizedMetricSpecification>
|
</CustomizedMetricSpecification>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<TargetValue>{{ policy.target_tracking_config.get("TargetValue") }}</TargetValue>
|
<TargetValue>{{ policy.target_tracking_config.get("TargetValue") }}</TargetValue>
|
||||||
|
@ -771,6 +771,30 @@ def test_create_autoscaling_policy_with_policytype__targettrackingscaling():
|
|||||||
"PredefinedMetricType": "ASGAverageNetworkIn",
|
"PredefinedMetricType": "ASGAverageNetworkIn",
|
||||||
},
|
},
|
||||||
"TargetValue": 1000000.0,
|
"TargetValue": 1000000.0,
|
||||||
|
"CustomizedMetricSpecification": {
|
||||||
|
"Metrics": [
|
||||||
|
{
|
||||||
|
"Label": "Get ASGAverageCPUUtilization",
|
||||||
|
"Id": "cpu",
|
||||||
|
"MetricStat": {
|
||||||
|
"Metric": {
|
||||||
|
"MetricName": "CPUUtilization",
|
||||||
|
"Namespace": "AWS/EC2",
|
||||||
|
"Dimensions": [
|
||||||
|
{"Name": "AutoScalingGroupName", "Value": asg_name}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"Stat": "Average",
|
||||||
|
},
|
||||||
|
"ReturnData": False,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Label": "Calculate square cpu",
|
||||||
|
"Id": "load",
|
||||||
|
"Expression": "cpu^2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -786,6 +810,36 @@ def test_create_autoscaling_policy_with_policytype__targettrackingscaling():
|
|||||||
"PredefinedMetricSpecification": {
|
"PredefinedMetricSpecification": {
|
||||||
"PredefinedMetricType": "ASGAverageNetworkIn",
|
"PredefinedMetricType": "ASGAverageNetworkIn",
|
||||||
},
|
},
|
||||||
|
"CustomizedMetricSpecification": {
|
||||||
|
"MetricName": "None",
|
||||||
|
"Namespace": "None",
|
||||||
|
"Dimensions": [],
|
||||||
|
"Statistic": "None",
|
||||||
|
"Metrics": [
|
||||||
|
{
|
||||||
|
"Label": "Get ASGAverageCPUUtilization",
|
||||||
|
"Id": "cpu",
|
||||||
|
"MetricStat": {
|
||||||
|
"Metric": {
|
||||||
|
"MetricName": "CPUUtilization",
|
||||||
|
"Namespace": "AWS/EC2",
|
||||||
|
"Dimensions": [
|
||||||
|
{"Name": "AutoScalingGroupName", "Value": asg_name}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"Stat": "Average",
|
||||||
|
"Unit": "None",
|
||||||
|
},
|
||||||
|
"ReturnData": False,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Label": "Calculate square cpu",
|
||||||
|
"Id": "load",
|
||||||
|
"Expression": "cpu^2",
|
||||||
|
"ReturnData": True,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
"TargetValue": 1000000.0,
|
"TargetValue": 1000000.0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user