Cameleer

AWS CloudWatch component

The aws2-cw component publishes custom metrics to Amazon CloudWatch.

Scheme: aws2-cw: · Crate: cameleer-cloud · Cargo feature: cloud · Consumer: no · Producer: yes · Apache Camel: AWS CloudWatch

When to use it

  • Count business events (orders received, failed payments) and alarm on them.
  • Publish sensor or gateway readings from edge devices as metrics.
  • Track route health (queue depth, processing time) next to your AWS dashboards.

URI format

text
aws2-cw://namespace[?options]

Example

Count every order received, with the order's sales channel as a dimension. The queue messages are small JSON objects such as {"channel":"web"}; after unmarshal the map is used as the dimensions:

yaml example: aws2-cw-count-orders-by-channel
- route:
    id: order-metrics-by-channel
    from:
      uri: "aws2-sqs://orders?region={{env:AWS_REGION:us-east-1}}"
      steps:
        - unmarshal:
            json: {}
        - setHeader:
            name: CamelAwsCwMetricDimensions
            simple: "${body}"
        - to: "aws2-cw://Shop/Orders?region={{env:AWS_REGION:us-east-1}}&name=OrdersReceived&value=1&unit=Count"

Rust DSL

rust
ctx.add_routes(|b| {
    b.from("aws2-sqs://orders?region={{env:AWS_REGION:us-east-1}}")
        .unmarshal("json")
        .set_header("CamelAwsCwMetricDimensions", simple("${body}"))
        .to("aws2-cw://Shop/Orders?region={{env:AWS_REGION:us-east-1}}&name=OrdersReceived&value=1&unit=Count");
})?;

Options

Common AWS options (region, credentials, endpoint override, proxy) are listed in Cloud credentials.

optiondefaultdescription
nameMetric name.
value1.0Metric value.
unitCountUnit (Count, Seconds, Milliseconds, Bytes, Percent, ...).
timestampnowTimestamp (epoch millis or ISO 8601).

Each exchange is one PutMetricData call. An array body sends several data, each an object {name, value, unit, timestamp, dimensions}.

Message headers

headerdirectiondescription
CamelAwsCwMetricNamespaceinOverrides the namespace.
CamelAwsCwMetricName, CamelAwsCwMetricValue, CamelAwsCwMetricUnit, CamelAwsCwMetricTimestampinOverride the options.
CamelAwsCwMetricDimensionsinDimensions (map name to value).
CamelAwsCwMetricDimensionName, CamelAwsCwMetricDimensionValueinA single dimension.

Run it with Docker

sh
docker run --rm -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \
  -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/metrics.camel.yaml

Common questions

How do I publish a measured value?

Set CamelAwsCwMetricValue from the message, for example ${header.durationMs}, with unit=Milliseconds.

Can I read metrics or alarms?

No. The component only publishes metrics (PutMetricData), as in Apache Camel.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub