> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon CloudWatch

> Client-mode REST API connector for a curated Amazon CloudWatch slice: PutMetricData, GetMetricData, PutLogEvents, and CreateLogStream from MQTT; SNS alarm notification is an ENABLE_SERVER companion

Technical Preview

## Overview

A client-mode connector for a **curated observability / ITSM** slice of [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) and [CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html):

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| POST PutMetricData | `POST /` on `monitoring.{region}.amazonaws.com` | JSON + `X-Amz-Target: GraniteServiceVersion20100801.PutMetricData`; SigV4 service `monitoring`; expect **200** |
| GetMetricData | `POST /` (same host) | Catalog said GET; official JSON protocol is POST `GetMetricData`; preferred auth smoke → **200** |
| POST PutLogEvents | `POST /` on `logs.{region}.amazonaws.com` | `Content-Type: application/x-amz-json-1.1`; `X-Amz-Target: Logs_20140328.PutLogEvents`; SigV4 service `logs` |
| CreateLogStream | `POST /` (logs host) | Helper so PutLogEvents is usable |
| SNS alarm notification | inbound HTTPS | **ENABLE\_SERVER companion** (docs only — not in this client `.lot`) |

Default `BASE_ADDRESS` is `https://monitoring.eu-west-1.amazonaws.com`. Topics use `itsm/amazon-cloudwatch/<object>/<verb>`. Switch BASE to `https://logs.{region}.amazonaws.com` for Logs events.

> [!NOTE]
>
> Prefer Hub secrets for `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_REGION` used by an upstream SigV4 signer. Pass `Authorization`, `x-amz-date`, and `x-amz-content-sha256` on each MQTT payload — this is **not** Bearer auth. This template has not been verified against a live AWS account. Status remains blocked until an authenticated live smoke succeeds.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Amazon CloudWatch (metrics + logs)
# Auth: SigV4 headers from MQTT payload (NOT Bearer)
# BASE_ADDRESS: https://monitoring.eu-west-1.amazonaws.com

DEFINE ROUTE AmazonCloudWatchRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://monitoring.eu-west-1.amazonaws.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Putmetricdata
        WITH SOURCE_TOPIC "itsm/amazon-cloudwatch/metric/put"
        WITH DESTINATION_TOPIC "itsm/amazon-cloudwatch/metric/put/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Content-Encoding" "amz-1.0"
            ADD "X-Amz-Target" "GraniteServiceVersion20100801.PutMetricData"
            ADD "Authorization" "{value.json.authorization}"
            ADD "x-amz-date" "{value.json.x_amz_date}"
            ADD "x-amz-content-sha256" "{value.json.x_amz_content_sha256}"
        WITH BODY "{payload}"
    ADD EVENT Getmetricdata
        WITH SOURCE_TOPIC "itsm/amazon-cloudwatch/metric/get"
        WITH DESTINATION_TOPIC "itsm/amazon-cloudwatch/metric/get/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Content-Encoding" "amz-1.0"
            ADD "X-Amz-Target" "GraniteServiceVersion20100801.GetMetricData"
            ADD "Authorization" "{value.json.authorization}"
            ADD "x-amz-date" "{value.json.x_amz_date}"
            ADD "x-amz-content-sha256" "{value.json.x_amz_content_sha256}"
        WITH BODY "{payload}"
    ADD EVENT Putlogevents
        WITH SOURCE_TOPIC "itsm/amazon-cloudwatch/log/put"
        WITH DESTINATION_TOPIC "itsm/amazon-cloudwatch/log/put/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/x-amz-json-1.1"
            ADD "X-Amz-Target" "Logs_20140328.PutLogEvents"
            ADD "Authorization" "{value.json.authorization}"
            ADD "x-amz-date" "{value.json.x_amz_date}"
            ADD "x-amz-content-sha256" "{value.json.x_amz_content_sha256}"
        WITH BODY "{payload}"
    ADD EVENT Createlogstream
        WITH SOURCE_TOPIC "itsm/amazon-cloudwatch/log/create-stream"
        WITH DESTINATION_TOPIC "itsm/amazon-cloudwatch/log/create-stream/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/x-amz-json-1.1"
            ADD "X-Amz-Target" "Logs_20140328.CreateLogStream"
            ADD "Authorization" "{value.json.authorization}"
            ADD "x-amz-date" "{value.json.x_amz_date}"
            ADD "x-amz-content-sha256" "{value.json.x_amz_content_sha256}"
        WITH BODY "{payload}"
```

## Authentication

| Mode | Header | Notes |
| - | - | - |
| AWS Signature Version 4 | `Authorization: {value.json.authorization}` (+ `x-amz-date`, `x-amz-content-sha256`) | Default in this template — **not** Bearer |

Sign with service name `monitoring` (metrics host) or `logs` (Logs host). Store `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_REGION` (optional `AWS_SESSION_TOKEN`) in Hub secrets and resolve via an upstream signer + `GET SECRET` — never commit credentials.

## MQTT examples

**PutMetricData** (BASE = monitoring):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "Namespace": "Coreflux/Plant",
  "MetricData": [
    {
      "MetricName": "vibration_rms",
      "Value": 12.4,
      "Unit": "None",
      "Dimensions": [{ "Name": "line", "Value": "a" }]
    }
  ]
}
```

Publish with SigV4 headers. Expect **HTTP 200**.

**GetMetricData** (auth smoke; BASE = monitoring):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "StartTime": "2026-10-04T16:00:00Z",
  "EndTime": "2026-10-04T17:00:00Z",
  "MetricDataQueries": [
    {
      "Id": "m1",
      "MetricStat": {
        "Metric": {
          "Namespace": "AWS/EC2",
          "MetricName": "CPUUtilization",
          "Dimensions": [{ "Name": "InstanceId", "Value": "i-0123456789abcdef0" }]
        },
        "Period": 300,
        "Stat": "Average"
      }
    }
  ]
}
```

Expect **HTTP 200**.

**PutLogEvents** (BASE = `logs.{region}.amazonaws.com`):

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "logGroupName": "coreflux/plant",
  "logStreamName": "line-a",
  "logEvents": [
    { "timestamp": 1728057600000, "message": "vibration_rms=12.4" }
  ]
}
```

Expect **HTTP 200** with `nextSequenceToken`. Create the stream first via `Createlogstream` if needed.

## ENABLE\_SERVER companion

CloudWatch Alarms → SNS → HTTPS subscription can POST notification JSON to an inbound endpoint. Package that as a separate `ENABLE_SERVER` connector — not included in the client `.lot`.

## Sources

* [https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API\_PutMetricData.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html)
* [https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API\_GetMetricData.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html)
* [https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/making-api-requests.html](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/making-api-requests.html)
* [https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API\_PutLogEvents.html](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html)
* [https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API\_CreateLogStream.html](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateLogStream.html)
* [https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html](https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html)

## Related

* [REST API connectors overview](/latest/lot-language/routes/rest-api-routes)
* [Azure Monitor](/latest/lot-language/routes/rest-api-apps/azure-monitor)
* [Datadog](/latest/lot-language/routes/rest-api-apps/datadog)
* [AWS IoT Core](/latest/lot-language/routes/rest-api-apps/aws-iot-core)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.