CloudWatch · Operations

Dashboard

Manage CloudWatch dashboard bodies as declared infrastructure.

Generic driverUniform lifecycle
Scope
Global
Spec fields
2
Outputs
2
Lookup
Supported

Resource definition

What this resource looks like

This is the CUE shape a Praxis template uses to declare a Dashboard. The resource key is local to the template; metadata.name supplies its stable Praxis identity.

CUE example
resources: {
  platformDashboard: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "Dashboard"
  	metadata: name: "\(_naming.prefix)-dashboard"
  	spec: {
  		region: _naming.region
  		dashboardBody: json.Marshal({
  			widgets: [
  				{
  					type: "metric"
  					x: 0, y: 0, width: 12, height: 6
  					properties: {
  						metrics: [
  							["AWS/ApplicationELB", "RequestCount", "LoadBalancer", "\(_naming.prefix)-alb"],
  							["AWS/ApplicationELB", "HTTPCode_ELB_5XX_Count", "LoadBalancer", "\(_naming.prefix)-alb"],
  						]
  						period: 300
  						stat:   "Sum"
  						region: _naming.region
  						title:  "ALB Traffic & Errors"
  					}
  				},
  				{
  					type: "metric"
  					x: 12, y: 0, width: 12, height: 6
  					properties: {
  						metrics: [
  							["AWS/RDS", "CPUUtilization", "DBInstanceIdentifier", "\(_naming.prefix)-db"],
  							["AWS/RDS", "FreeableMemory", "DBInstanceIdentifier", "\(_naming.prefix)-db"],
  						]
  						period: 300
  						stat:   "Average"
  						region: _naming.region
  						title:  "RDS Performance"
  					}
  				},
  				{
  					type: "metric"
  					x: 0, y: 6, width: 12, height: 6
  					properties: {
  						metrics: [
  							["AWS/Lambda", "Invocations", "FunctionName", "\(_naming.prefix)-worker"],
  							["AWS/Lambda", "Errors", "FunctionName", "\(_naming.prefix)-worker"],
  						]
  						period: 300
  						stat:   "Sum"
  						region: _naming.region
  						title:  "Lambda Worker"
  					}
  				},
  			]
  		})
  	}
  }
}

Excerpted from examples/stacks/end-to-end.cue. Open the complete example for its variables and related resources.

Complete examples in the repository

Desired state

Configuration

The spec block accepts 2 fields. 2 are required by the schema; fields with defaults can be omitted.

regionRequired

Region.

string
String
dashboardBodyRequired

Dashboard Body.

string
String

Observed values

Outputs

Praxis records these values after observation. A dependent resource can read one with ${resources.<name>.outputs.<field>}.

dashboardArnString
dashboardNameString

Read without ownership

Data-source lookup

A data block reads an existing Dashboard 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.

CUE data source
data: existing: {
  kind: "Dashboard"
  region: "us-west-2"
  filter: {
    name: "replace-with-provider-name"
  }
}

Understand data sources and filters →

Adopt existing infrastructure

Import

Import persists Praxis state for an existing AWS resource. For this kind, supply: Provider identifier for the existing Dashboard. The example starts in observed mode so Praxis reports drift without correcting it.

CLI
praxis import Dashboard \
  --id <provider-identifier> \
  --region us-west-2 \
  --account production \
  --observe

Choose managed or observed ownership →

Canonical 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
schemas/aws/cloudwatch/dashboard.cue
package cloudwatch

#Dashboard: {
	apiVersion: "praxis.io/alpha"
	kind:       "Dashboard"

	metadata: {
		name: string & =~"^[a-zA-Z0-9_\\-]{1,255}$"
		labels: [string]: string
	}

	spec: {
		region:        string
		dashboardBody: string
	}

	outputs?: {
		dashboardArn:  string
		dashboardName: string
	}
}

View this schema on GitHub →