Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions azure/specs/service-spec.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@
{
"type":"Control",
"scope":"#/properties/autoscaling/properties/target_cpu_utilization"
},
{
"type": "Control",
"scope": "#/properties/autoscaling/properties/target_memory_enabled"
},
{
"rule": {
"effect": "SHOW",
"condition": {
"scope": "#/properties/autoscaling/properties/target_memory_enabled",
"schema": {
"const": true
}
}
},
"type": "Control",
"scope": "#/properties/autoscaling/properties/target_memory_utilization"
}
]
}
Expand Down Expand Up @@ -363,6 +380,19 @@
"maximum":90,
"minimum":50,
"description":"CPU utilization threshold that triggers scaling"
},
"target_memory_enabled": {
"type": "boolean",
"title": "Scale by memory",
"default": false
},
"target_memory_utilization": {
"type": "integer",
"title": "Target memory utilization (%)",
"default": 70,
"maximum": 90,
"minimum": 30,
"description": "Memory utilization threshold that triggers scaling"
}
}
},
Expand Down
47 changes: 47 additions & 0 deletions datadog/metric/build_context
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

SCOPE_ID=$(echo "$CONTEXT" | jq -r '.arguments.scope_id // empty')

if [[ -z "$DATADOG_API_KEY" ]] || [[ -z "$DATADOG_APP_KEY" ]]; then
NRN=$(np scope read --id "$SCOPE_ID" --format json | jq -r .nrn)

PROVIDERS=$(np provider list --categories metrics --nrn "$NRN" --format json)


DATADOG_API_KEY=${DATADOG_API_KEY:-$(echo "$PROVIDERS" | jq -r '.results[0].attributes.credentials.api_key // empty')}
DATADOG_APP_KEY=${DATADOG_APP_KEY:-$(echo "$PROVIDERS" | jq -r '.results[0].attributes.credentials.app_key // empty')}
DATADOG_SITE=${DATADOG_SITE:-$(echo "$PROVIDERS" | jq -r '.results[0].attributes.settings.site // "datadoghq.com"')}

else
DATADOG_SITE=${DATADOG_SITE:-"datadoghq.com"}
fi

if [[ -z "$DATADOG_API_KEY" ]]; then
echo "There is no Datadog provider configured. Please configure Datadog in Platform settings and try again." >&2
exit 1
fi

if [[ -z "$DATADOG_APP_KEY" ]]; then
echo "Datadog App Key is required. Please configure App Key in Platform settings and try again." >&2
exit 1
fi

while read -r line; do
eval "$line"
done < <(echo "$CONTEXT" | jq -r '.arguments | to_entries[] |
if (.value | type) == "array" then
"export \(.key | ascii_upcase)=\(.value | join(","))"
else
"export \(.key | ascii_upcase)=\(.value)"
end')

if [[ -n "$METRIC" ]]; then
export METRIC_NAME="$METRIC"
fi

export DATADOG_API_KEY
export DATADOG_APP_KEY
export DATADOG_SITE
export SCOPE_ID
export SERVICE_NAME
export ENVIRONMENT
55 changes: 55 additions & 0 deletions datadog/metric/list
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

echo '{
"results": [
{
"name": "http.rpm",
"title": "Throughput",
"unit": "rpm",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["instance_id"]
},
{
"name": "http.response_time",
"title": "Response time",
"unit": "ms",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["instance_id"]
},
{
"name": "http.error_rate",
"title": "Error rate",
"unit": "%",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["instance_id"]
},
{
"name": "system.cpu_usage_percentage",
"title": "Cpu usage",
"unit": "%",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["instance_id"]
},
{
"name": "system.memory_usage_percentage",
"title": "Memory usage",
"unit": "%",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["scope_id", "instance_id"]
},
{
"name": "http.healthcheck_count",
"title": "Healthcheck",
"unit": "check",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["instance_id"]
},
{
"name": "http.healthcheck_fail",
"title": "Healthcheck failures",
"unit": "count",
"available_filters": ["scope_id", "instance_id"],
"available_group_by": ["instance_id"]
}
]
}'
Loading