Skip to content

Workspace

Source: src/AWS/AMP/Workspace.ts

An Amazon Managed Service for Prometheus (AMP) workspace — a logical, fully-managed Prometheus-compatible metrics store. Metrics are ingested via remote-write and queried through the workspace’s Prometheus-compatible endpoint.

Basic Workspace

const workspace = yield* AMP.Workspace("Metrics", {
alias: "production-metrics",
});

Workspace with Customer-Managed Encryption

const workspace = yield* AMP.Workspace("Metrics", {
alias: "production-metrics",
kmsKeyArn: key.keyArn,
tags: { team: "observability" },
});

Workspace with Custom Retention and Series Limits

const workspace = yield* AMP.Workspace("Metrics", {
alias: "production-metrics",
retentionPeriod: "30 days",
limitsPerLabelSet: [
{ labelSet: { team: "billing" }, maxSeries: 100_000 },
{ labelSet: {}, maxSeries: 1_000_000 }, // default bucket
],
});
// prometheusEndpoint ends in a trailing slash; append `api/v1/remote_write`
const remoteWrite = `${workspace.prometheusEndpoint}api/v1/remote_write`;
// inside a Lambda Function's effect (provide the *Http layers):
const remoteWrite = yield* AMP.RemoteWrite(workspace);
const metrics = yield* AMP.QueryMetrics(workspace);
yield* remoteWrite({
timeseries: [{ name: "jobs_done_total", samples: [{ value: 1 }] }],
});
const result = yield* metrics.query({ query: "jobs_done_total" });