Resource definition
What this resource looks like
This is the CUE shape a Praxis template uses to declare a MetricAlarm. The resource key is local to the template; metadata.name supplies its stable Praxis identity.
resources: {
highErrorAlarm: {
apiVersion: "praxis.io/alpha"
kind: "MetricAlarm"
metadata: name: "\(_naming.prefix)-high-5xx-errors"
spec: {
region: _naming.region
alarmDescription: "ALB 5xx error rate exceeds threshold"
namespace: "AWS/ApplicationELB"
metricName: "HTTPCode_ELB_5XX_Count"
statistic: "Sum"
period: 300
evaluationPeriods: 2
threshold: 50
comparisonOperator: "GreaterThanThreshold"
alarmActions: ["${resources.alertTopic.outputs.topicArn}"]
dimensions: LoadBalancer: "${resources.alb.outputs.loadBalancerArn}"
tags: #StandardTags & {purpose: "monitoring"}
}
}
}Excerpted from examples/stacks/end-to-end.cue. Open the complete example for its variables and related resources.
Desired state
Configuration
The spec block accepts 19 fields. 8 are required by the schema; fields with defaults can be omitted.
regionRequiredRegion.
stringnamespaceRequiredNamespace.
stringmetricNameRequiredMetric Name.
stringdimensionsOptionalDimensions.
[string]: stringstatisticOptionalStatistic.
"SampleCount" | "Average" | "Sum" | "Minimum" | "Maximum"extendedStatisticOptionalExtended Statistic.
string & =~"^p[0-9]+(\\.[0-9]+)?$"periodRequiredPeriod.
int & >0evaluationPeriodsRequiredEvaluation Periods.
int & >=1datapointsToAlarmOptionalDatapoints To Alarm.
int & >=1thresholdRequiredThreshold.
numbercomparisonOperatorRequiredComparison Operator.
"GreaterThanThreshold" |treatMissingDataOptionalTreat Missing Data.
"breaching" | "notBreaching" | "ignore" | "missing" | *"missing""missing"alarmDescriptionOptionalAlarm Description.
stringactionsEnabledOptionalActions Enabled.
bool | *truetruealarmActionsOptionalAlarm Actions.
[...string]okActionsOptionalOk Actions.
[...string]insufficientDataActionsOptionalInsufficient Data Actions.
[...string]unitOptionalUnit.
stringtagsRequiredTags.
[string]: stringObserved values
Outputs
Praxis records these values after observation. A dependent resource can read one with ${resources.<name>.outputs.<field>}.
alarmArnStringalarmNameStringstateValueStringstateReasonString · optionalRead without ownership
Data-source lookup
A data block reads an existing MetricAlarm and exposes its outputs without storing lifecycle state. The generic filter surface accepts id, name, and tag; supported combinations depend on the AWS identity used by this resource.
data: existing: {
kind: "MetricAlarm"
region: "us-west-2"
filter: {
name: "replace-with-provider-name"
}
}Adopt existing infrastructure
Import
Import persists Praxis state for an existing AWS resource. For this kind, supply: Provider identifier for the existing MetricAlarm. The example starts in observed mode so Praxis reports drift without correcting it.
praxis import MetricAlarm \
--id <provider-identifier> \
--region us-west-2 \
--account production \
--observeCanonical contract
Complete CUE schema
The field guide above is derived from this definition. The schema remains the source of truth for accepted values, defaults, validation constraints, and outputs in the current alpha revision.
Show the complete schema
package cloudwatch
#MetricAlarm: {
apiVersion: "praxis.io/alpha"
kind: "MetricAlarm"
metadata: {
name: string & =~"^[a-zA-Z0-9][a-zA-Z0-9_\\-]{0,254}$"
labels: [string]: string
}
spec: {
region: string
namespace: string
metricName: string
dimensions?: [string]: string
statistic?: "SampleCount" | "Average" | "Sum" | "Minimum" | "Maximum"
extendedStatistic?: string & =~"^p[0-9]+(\\.[0-9]+)?$"
period: int & >0
evaluationPeriods: int & >=1
datapointsToAlarm?: int & >=1
threshold: number
comparisonOperator: "GreaterThanThreshold" |
"GreaterThanOrEqualToThreshold" |
"LessThanThreshold" |
"LessThanOrEqualToThreshold"
treatMissingData: "breaching" | "notBreaching" | "ignore" | "missing" | *"missing"
alarmDescription?: string
actionsEnabled: bool | *true
alarmActions?: [...string]
okActions?: [...string]
insufficientDataActions?: [...string]
unit?: string
tags: [string]: string
}
outputs?: {
alarmArn: string
alarmName: string
stateValue: string
stateReason?: string
}
}