Prometheus & Grafana
If your team already speaks Prometheus, AWS runs it for you. An Amazon Managed Service for Prometheus (AMP) workspace stores Prometheus metrics and answers PromQL, with the same query and remote-write APIs as Prometheus itself. A scraper fills it from a Kubernetes cluster, and your own code can write to it directly. An Amazon Managed Grafana workspace runs Grafana with AWS’s data sources built in.
Create a workspace
Section titled “Create a workspace”const metrics = yield* AWS.AMP.Workspace("Metrics", { alias: "production-metrics", retentionPeriod: "30 days",});prometheusEndpoint is the workspace’s Prometheus URL. Append api/v1/remote_write for an agent’s remote-write URL, or api/v1/query for queries. Requests are signed with SigV4.
Scrape a cluster
Section titled “Scrape a cluster”A scraper is an agentless collector AWS runs for you. It reads an EKS cluster’s Prometheus endpoints from inside its subnets, using a standard Prometheus scrape configuration:
yield* AWS.AMP.Scraper("ClusterScraper", { alias: "eks-metrics", scrapeConfiguration: scrapeConfigYaml, source: { eksConfiguration: { clusterArn: cluster.clusterArn, subnetIds: [subnetA.subnetId, subnetB.subnetId], }, }, destinationWorkspaceArn: metrics.workspaceArn,});See EKS for the cluster.
Write from your code
Section titled “Write from your code”The RemoteWrite binding sends samples from a runtime, signed with its role. You pass metric names, labels and values:
Effect.gen(function* () { const remoteWrite = yield* AWS.AMP.RemoteWrite(Metrics); return { fetch: Effect.gen(function* () { yield* remoteWrite({ timeseries: [{ name: "jobs_processed_total", labels: { queue: "default" }, samples: [{ value: 42 }] }], }); return HttpServerResponse.text("ok"); }), };});The QueryMetrics binding runs PromQL against the workspace from a runtime: metrics.query({ query: "up" }).
Record and alert with rules
Section titled “Record and alert with rules”Rule groups run on a schedule inside the workspace: recording rules save a query’s result as a new series, and alerting rules fire alerts:
yield* AWS.AMP.RuleGroupsNamespace("Rules", { workspaceId: metrics.workspaceId, name: "default", definition: `groups: - name: jobs rules: - record: jobs:processed:rate5m expr: rate(jobs_processed_total[5m])`,});Alerts go to the workspace’s Alertmanager, configured with AWS.AMP.AlertManagerDefinition in Alertmanager’s own YAML.
Graph it in Grafana
Section titled “Graph it in Grafana”A Grafana workspace signs people in through IAM Identity Center or SAML, and can read AMP and CloudWatch with its own service-managed role:
yield* AWS.Grafana.Workspace("Dashboards", { accountAccessType: "CURRENT_ACCOUNT", authenticationProviders: ["AWS_SSO"], permissionType: "SERVICE_MANAGED", dataSources: ["PROMETHEUS", "CLOUDWATCH"],});AWS_SSO needs IAM Identity Center turned on for the account or its organization. See Accounts and regions.
Prometheus metrics live in AMP, apart from CloudWatch. To keep your telemetry in CloudWatch instead, export OpenTelemetry: CloudWatch answers PromQL over those metrics too.