Skip to content

Commit

Permalink
Add AWS CloudWatch Kamelet
Browse files Browse the repository at this point in the history
  • Loading branch information
claudio4j authored and oscerd committed Jun 15, 2021
1 parent 6ad61c3 commit f9a150b
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 1 deletion.
131 changes: 131 additions & 0 deletions aws-cloudwatch-sink.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: aws-cloudwatch-sink
annotations:
camel.apache.org/kamelet.support.level: "Preview"
camel.apache.org/catalog.version: "main-SNAPSHOT"
camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIwNyIgaGVpZ2h0PSIyNTAwIiB2aWV3Qm94PSIwIDAgMjU2IDI5MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+PHBhdGggZD0iTTI1NiAxOTkuMzA1bC0xMjcuOTU3LTE4Ljc5N0wwIDE5OS4zMjlsMTI4LjAxIDQ3LjQzOUwyNTYgMTk5LjMwNSIgZmlsbD0iI0I3Q0E5RCIvPjxwYXRoIGQ9Ik0yNS42MjEgMTk3LjExM2wyMS42MyA2Ljc2MSAxLjk3MS0yLjIzOFY1MC4yODRsLTEuOTcxLTIuNTg1LTIxLjYzIDguMjc0djE0MS4xNCIgZmlsbD0iIzRCNjEyQyIvPjxwYXRoIGQ9Ik0xMjMuODMyIDE5MC40MjNsLTc2LjU4MSAxMy40NTFWNDcuNzAzbDc2LjU4MSAxNy4yMjJ2MTI1LjQ5OCIgZmlsbD0iIzc1OUMzRSIvPjxwYXRoIGQ9Ik04OS42ODYgMjE2Ljg4OWwtMjkuODQ4LTkuMjAxVjE0LjkyOEw4OS42ODYuMDA0bDIuNjEyIDIuODQ1djIxMC44NThsLTIuNjEyIDMuMTgyIiBmaWxsPSIjNEI2MTJDIi8+PHBhdGggZD0iTTE5MS45NjcgMTkyLjg5NEw4OS42ODYgMjE2Ljg4OVYwbDEwMi4yODEgMzkuODY2djE1My4wMjgiIGZpbGw9IiM3NTlDM0UiLz48cGF0aCBkPSJNMTI3Ljk2NSAyNDQuNzE0TDAgMTk5LjMyOXYyNi4zMjRsMTI3Ljk2NSA2My45ODN2LTQ0LjkyMiIgZmlsbD0iIzRCNjEyQyIvPjxwYXRoIGQ9Ik0yNTYgMjI1LjYyMmwtMTI4LjAzNSA2NC4wMTR2LTQ0LjkyMkwyNTYgMTk5LjMwNXYyNi4zMTciIGZpbGw9IiM3NTlDM0UiLz48cGF0aCBkPSJNMjIwLjAzOSAxNTUuNjkyaC0zMS4wMjZsLTg4LjQ0NSA2LjAyNkwxMjggMTY2Ljc3NWw5Mi4wMzktMTEuMDgzIiBmaWxsPSIjQjdDQTlEIi8+PHBhdGggZD0iTTEwMC41NjggMjE5LjkwNmwyNy40MiA4LjIyNi43ODktLjg0OS0uMDIzLTYxLjg0OS0uNzg5LS43NTgtMjcuMzk3LTIuOTU4djU4LjE4OCIgZmlsbD0iIzRCNjEyQyIvPjxwYXRoIGQ9Ik0yMjAuMDM5IDE1NS42OTJsLTkyLjA3NCA4Ljk4LjAyMyA2My40NiA5Mi4wNTEtMjcuNzExdi00NC43MjkiIGZpbGw9IiM3NTlDM0UiLz48L3N2Zz4K"
camel.apache.org/provider: "Apache Software Foundation"
camel.apache.org/kamelet.group: "AWS Cloudwatch"
labels:
camel.apache.org/kamelet.type: "sink"
spec:
definition:
title: "AWS CloudWatch Metrics Sink"
description: |-
Send messages to AWS CloudWatch metrics.
There are several properties you can set in the headers, such as:
`metric-name` / `ce-metric-name` for the metric name.
`metric-value` / `ce-metric-value` for the metric value.
`metric-unit` / `ce-metric-unit` for the metric unit.
`metric-timestamp` / `ce-metric-timestamp` for the metric timestamp.
`metric-dimension-name` / `ce-metric-dimension-name` for the dimension name.
`metric-dimension-value` / `ce-metric-dimension-value` for the dimension value.
required:
- cw_namespace
- accessKey
- secretKey
- region
type: object
properties:
cw_namespace:
title: Cloud Watch Namespace
description: The cloud watch metric namespace.
type: string
accessKey:
title: Access Key
description: The access key obtained from AWS.
type: string
format: password
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
secretKey:
title: Secret Key
description: The secret key obtained from AWS.
type: string
format: password
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:password
region:
title: AWS Region
description: The AWS region to connect to.
type: string
example: eu-west-1
dependencies:
- "camel:aws2-cw"
- "camel:kamelet"
flow:
from:
uri: kamelet:source
steps:
- choice:
when:
- simple: "${header[metric-name]}"
steps:
- set-header:
name: CamelAwsCwMetricName
simple: "${header[metric-name]}"
- simple: "${header[ce-metric-name]}"
steps:
- set-header:
name: CamelAwsCwMetricName
simple: "${header[ce-metric-name]}"
- simple: "${header[metric-value]}"
steps:
- set-header:
name: CamelAwsCwMetricValue
simple: "${header[metric-value]}"
- simple: "${header[ce-metric-value]}"
steps:
- set-header:
name: CamelAwsCwMetricValue
simple: "${header[ce-metric-value]}"
- simple: "${header[metric-unit]}"
steps:
- set-header:
name: CamelAwsCwMetricUnit
simple: "${header[metric-unit]}"
- simple: "${header[ce-metric-unit]}"
steps:
- set-header:
name: CamelAwsCwMetricUnit
simple: "${header[ce-metric-unit]}"
- simple: "${header[metric-timestamp]}"
steps:
- set-header:
name: CamelAwsCwMetricTimestamp
simple: "${header[metric-timestamp]}"
- simple: "${header[ce-metric-timestamp]}"
steps:
- set-header:
name: CamelAwsCwMetricTimestamp
simple: "${header[ce-metric-timestamp]}"
- simple: "${header[metric-dimension-name]}"
steps:
- set-header:
name: CamelAwsCwMetricDimensionName
simple: "${header[metric-dimension-name]}"
- simple: "${header[ce-metric-dimension-name]}"
steps:
- set-header:
name: CamelAwsCwMetricDimensionName
simple: "${header[ce-metric-dimension-name]}"
- simple: "${header[metric-dimension-value]}"
steps:
- set-header:
name: CamelAwsCwMetricDimensionValue
simple: "${header[metric-dimension-value]}"
- simple: "${header[ce-metric-dimension-value]}"
steps:
- set-header:
name: CamelAwsCwMetricDimensionValue
simple: "${header[ce-metric-dimension-value]}"
- to:
uri: "aws2-cw:{{cw_namespace}}"
parameters:
secretKey: "{{secretKey}}"
accessKey: "{{accessKey}}"
region: "{{region}}"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
* xref:ROOT:avro-deserialize-action.adoc[image:kamelets/avro-deserialize-action.svg[] Avro Deserialize Action]
* xref:ROOT:avro-serialize-action.adoc[image:kamelets/avro-serialize-action.svg[] Avro Serialize Action]
* xref:ROOT:aws-cloudwatch-sink.adoc[image:kamelets/aws-cloudwatch-sink.svg[] AWS CloudWatch Metrics Sink]
* xref:ROOT:aws-ddb-streams-source.adoc[image:kamelets/aws-ddb-streams-source.svg[] AWS DynamoDB Streams Source]
* xref:ROOT:aws-kinesis-firehose-sink.adoc[image:kamelets/aws-kinesis-firehose-sink.svg[] AWS Kinesis Firehose Sink]
* xref:ROOT:aws-kinesis-sink.adoc[image:kamelets/aws-kinesis-sink.svg[] AWS Kinesis Sink]
Expand Down
77 changes: 77 additions & 0 deletions docs/modules/ROOT/pages/aws-cloudwatch-sink.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/aws-cloudwatch-sink.svg[] AWS CloudWatch Metrics Sink

*Provided by: "Apache Software Foundation"*

*Support Level for this Kamelet is: "Preview"*

Send messages to AWS CloudWatch metrics.

There are several properties you can set in the headers, such as:

`metric-name` / `ce-metric-name` for the metric name.
`metric-value` / `ce-metric-value` for the metric value.
`metric-unit` / `ce-metric-unit` for the metric unit.
`metric-timestamp` / `ce-metric-timestamp` for the metric timestamp.
`metric-dimension-name` / `ce-metric-dimension-name` for the dimension name.
`metric-dimension-value` / `ce-metric-dimension-value` for the dimension value.

== Configuration Options

The following table summarizes the configuration options available for the `aws-cloudwatch-sink` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *accessKey {empty}* *| Access Key| The access key obtained from AWS.| string| |
| *cw_namespace {empty}* *| Cloud Watch Namespace| The cloud watch metric namespace.| string| |
| *region {empty}* *| AWS Region| The AWS region to connect to.| string| | `"eu-west-1"`
| *secretKey {empty}* *| Secret Key| The secret key obtained from AWS.| string| |
|===

NOTE: Fields marked with ({empty}*) are mandatory.

== Usage

This section summarizes how the `aws-cloudwatch-sink` can be used in various contexts.

=== Knative Sink

The `aws-cloudwatch-sink` Kamelet can be used as Knative sink by binding it to a Knative object.

.aws-cloudwatch-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: aws-cloudwatch-sink-binding
spec:
source:
ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1
name: mychannel
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: aws-cloudwatch-sink
properties:
accessKey: "The Access Key"
cw_namespace: "The Cloud Watch Namespace"
region: "eu-west-1"
secretKey: "The Secret Key"
----

Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `aws-cloudwatch-sink-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the sink using the following command:

[source,shell]
----
kubectl apply -f aws-cloudwatch-sink-binding.yaml
----
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT

0 comments on commit f9a150b

Please sign in to comment.