# CloudWatch Logs

Kubemq cloudwatch-logs target connector allows services using kubemq server to access aws cloudwatch-logs service.

## Prerequisites

The following required to run the aws-cloudwatch-logs target connector:

* kubemq cluster
* aws account with cloudwatch-logs active service
* some action will need cloudwatch-logs permission (IAM User)
* kubemq-source deployment

## Configuration

cloudwatch-logs target connector configuration properties:

| Properties Key   | Required | Description                       | Example                        |
| ---------------- | -------- | --------------------------------- | ------------------------------ |
| aws\_key         | yes      | aws key                           | aws key supplied by aws        |
| aws\_secret\_key | yes      | aws secret key                    | aws secret key supplied by aws |
| region           | yes      | region                            | aws region                     |
| token            | no       | aws token ("default" empty string | aws token                      |

Example:

```yaml
bindings:
  - name: kubemq-query-aws-cloudwatch-logs
    source:
      kind: kubemq.query
      name: kubemq-query
      properties:
        address: "kubemq-cluster:50000"
        client_id: "kubemq-query-aws-cloudwatch-logs"
        auth_token: ""
        channel: "query.aws.cloudwatch.logs"
        group:   ""
        auto_reconnect: "true"
        reconnect_interval_seconds: "1"
        max_reconnects: "0"
    target:
      kind: aws.cloudwatch.logs
      name: aws-cloudwatch-logs
      properties:
        aws_key: "id"
        aws_secret_key: 'json'
        region:  "region"
        token: ""
```

## Usage

### Create log Stream

create a new log stream

Create log Stream:

| Metadata Key      | Required | Description         | Possible values              |
| ----------------- | -------- | ------------------- | ---------------------------- |
| method            | yes      | type of method      | "create\_log\_event\_stream" |
| log\_stream\_name | yes      | aws log stream name | "string"                     |
| log\_group\_name  | yes      | aws log group name  | "string"                     |

Example:

```javascript
{
  "metadata": {
    "method": "create_log_event_stream",
    "log_stream_name": "my_stream_name",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```

### Describe log Stream

describe a selected log stream by group\_name

Describe log Stream:

| Metadata Key     | Required | Description        | Possible values                |
| ---------------- | -------- | ------------------ | ------------------------------ |
| method           | yes      | type of method     | "describe\_log\_event\_stream" |
| log\_group\_name | yes      | aws log group name | "string"                       |

Example:

```javascript
{
  "metadata": {
    "method": "describe_log_event_stream",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```

### Delete log Stream

delete log stream

Delete log Stream:

| Metadata Key      | Required | Description         | Possible values              |
| ----------------- | -------- | ------------------- | ---------------------------- |
| method            | yes      | type of method      | "delete\_log\_event\_stream" |
| log\_stream\_name | yes      | aws log stream name | "string"                     |
| log\_group\_name  | yes      | aws log group name  | "string"                     |

Example:

```javascript
{
  "metadata": {
    "method": "delete_log_event_stream",
    "log_stream_name": "my_stream_name",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```

### Get log Event

get log event

Get log Stream:

| Metadata Key      | Required | Description         | Possible values   |
| ----------------- | -------- | ------------------- | ----------------- |
| method            | yes      | type of method      | "get\_log\_event" |
| log\_stream\_name | yes      | aws log stream name | "string"          |
| log\_group\_name  | yes      | aws log group name  | "string"          |

Example:

```javascript
{
  "metadata": {
    "method": "get_log_event",
    "log_stream_name": "my_stream_name",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```

### Create Log Event Group

create a new log event group

Create Log Event Group:

| Metadata Key     | Required | Description        | Possible values              |
| ---------------- | -------- | ------------------ | ---------------------------- |
| method           | yes      | type of method     | "create\_log\_group"         |
| log\_group\_name | yes      | aws log group name | "string"                     |
| data             | no       | aws tags           | key value pair string string |

Example:

```javascript
{
  "metadata": {
    "method": "create_log_group",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```

### Put Log

put a log in log stream

Put Log Event:

| Metadata Key      | Required | Description                                            | Possible values   |
| ----------------- | -------- | ------------------------------------------------------ | ----------------- |
| method            | yes      | type of method                                         | "put\_log\_event" |
| log\_stream\_name | yes      | aws log stream name                                    | "string"          |
| log\_group\_name  | yes      | aws log group name                                     | "string"          |
| sequence\_token   | yes      | aws stream sequence token                              | "string"          |
| data              | yes      | key value pair of int-string int-time - string-Message | "string"          |

Example:

```javascript
{
  "metadata": {
    "method": "put_log_event",
    "log_group_name": "my_group_name",
    "sequence_token": "my_token_from_aws"
  },
  "data": "eyIxNTk3MjM1NTU4NTEyIjoibXkgZmlyc3QgbWVzc2FnZSB0byBzZW5kIiwiMTU5NzIzNTU1ODUyNyI6Im15IHNlY29uZCBtZXNzYWdlIHRvIHNlbmQifQ=="
}
```

### Describe Log Event Group

describe log event group

Describe Log Event Group:

| Metadata Key       | Required | Description          | Possible values        |
| ------------------ | -------- | -------------------- | ---------------------- |
| method             | yes      | type of method       | "describe\_log\_group" |
| log\_group\_prefix | yes      | aws log group prefix | "string"               |

Example:

```javascript
{
  "metadata": {
    "method": "describe_log_group",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```

### Delete Log Event Group

delete log event group

Delete Log Event Group:

| Metadata Key     | Required | Description        | Possible values      |
| ---------------- | -------- | ------------------ | -------------------- |
| method           | yes      | type of method     | "delete\_log\_group" |
| log\_group\_name | yes      | aws log group name | "string"             |

Example:

```javascript
{
  "metadata": {
    "method": "delete_log_group",
    "log_group_name": "my_group_name"
  },
  "data": null
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kubemq.io/configuration/connectors/kubemq-targets/aws/cloudwatch-logs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
