Skip to content

Commit cfc32c4

Browse files
thesollyztothmano
andauthored
aws: Cloudwatch Forwarder terraform module (#103)
Co-authored-by: Mano Toth <mano@axiom.co> Co-authored-by: Mano Toth <71388581+tothmano@users.noreply.github.com>
1 parent d0aa7df commit cfc32c4

File tree

1 file changed

+79
-3
lines changed

1 file changed

+79
-3
lines changed

send-data/cloudwatch.mdx

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
title: 'Send data from Amazon CloudWatch to Axiom'
33
description: 'This page explains how to send data from Amazon CloudWatch to Axiom.'
44
sidebarTitle: Amazon CloudWatch
5-
tags:
5+
tags:
66
['axiom documentation', 'documentation', 'axiom', 'Amazon cloudwatch', 'aws s3', 'aws lambda', 'cloudwatch log groups']
77
---
88

99
import Prerequisites from "/snippets/standard-prerequisites.mdx"
1010
import AwsDisclaimer from "/snippets/aws-disclaimer.mdx"
11+
import Replacement from "/snippets/standard-replacement.mdx"
1112

1213
Axiom CloudWatch Forwarder is a set of easy-to-use AWS CloudFormation stacks designed to forward logs from Amazon CloudWatch to Axiom. It includes a Lambda function to handle the forwarding and stacks to create Amazon CloudWatch log group subscription filters for both existing and future log groups.
1314

@@ -28,12 +29,76 @@ Axiom CloudWatch Forwarder includes templates for the following CloudFormation s
2829
{/* list separator */}
2930
- [Create an account on AWS Cloud](https://signin.aws.amazon.com/signup?request_type=register).
3031

31-
## Setup
32+
## Installation
33+
34+
To install the Axiom CloudWatch Forwarder, choose one of the following:
35+
36+
- [Cloudformation stacks](#install-with-cloudformation-stacks)
37+
- [Terraform module](#install-with-terraform-module)
38+
39+
### Install with Cloudformation stacks
3240

3341
1. [Launch the Forwarder stack template on AWS](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-forwarder&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-forwarder-v1.1.1-cloudformation-stack.yaml). Copy the Forwarder Lambda ARN because it’s referenced in the Subscriber stack.
3442
1. [Launch the Subscriber stack template on AWS](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-subscriber&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-subscriber-v1.1.1-cloudformation-stack.yaml).
3543
1. [Launch the Listener stack template on AWS](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-listener&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-listener-v1.1.1-cloudformation-stack.yaml).
3644

45+
### Install with Terraform module
46+
47+
<Steps>
48+
<Step>
49+
50+
Create a new Forwarder module in your Terraform file in the following way:
51+
52+
```hcl
53+
module "forwarder" {
54+
source = "axiomhq/axiom-cloudwatch-forwarder/aws//modules/forwarder"
55+
axiom_dataset = "DATASET_NAME"
56+
axiom_token = "API_TOKEN"
57+
prefix = "axiom-cloudwatch-forwarder"
58+
}
59+
```
60+
61+
<Replacement />
62+
63+
Alternatively, create a dataset with the [Axiom Terraform provider](/docs/apps/terraform#create-dataset).
64+
65+
</Step>
66+
<Step>
67+
68+
Create a new Subscriber module in your Terraform file in the following way:
69+
70+
``` hcl
71+
module "subscriber" {
72+
source = "axiomhq/axiom-cloudwatch-forwarder/aws//modules/subscriber"
73+
prefix = "axiom-cloudwatch-forwarder"
74+
forwarder_lambda_arn = module.forwarder.lambda_arn
75+
log_groups_prefix = "/aws/lambda/"
76+
}
77+
```
78+
79+
</Step>
80+
<Step>
81+
82+
Create a new Listener module in your Terraform file in the following way:
83+
84+
```hcl
85+
module "listener" {
86+
source = "axiomhq/axiom-cloudwatch-forwarder/aws//modules/listener"
87+
prefix = "axiom-cloudwatch-forwarder"
88+
forwarder_lambda_arn = module.forwarder.lambda_arn
89+
log_groups_prefix = "/aws/lambda/"
90+
}
91+
```
92+
93+
</Step>
94+
<Step>
95+
In your terminal, go to the folder of your main Terraform file, and then run `terraform init`.
96+
</Step>
97+
<Step>
98+
Run `terraform plan` to check the changes, and then run `terraform apply`.
99+
</Step>
100+
</Steps>
101+
37102
## Filter Amazon CloudWatch log groups
38103

39104
The Subscriber and Unsubscriber stacks allow you to filter the log groups by a combination of names, prefix, and regular expression filters. If no filters are specified, the stacks subscribe to or unsubscribe from all log groups. You can also whitelist a specific set of log groups using filters in the CloudFormation stack parameters. The log group names, prefix, and regular expression filters included are additive, meaning the union of all provided inputs is matched.
@@ -69,4 +134,15 @@ The optional Listener stack does the following:
69134

70135
To remove subscription filters for one or more log groups, [launch the Unsubscriber stack template on AWS](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=axiom-cloudwatch-subscriber&templateURL=https://axiom-cloudformation.s3.amazonaws.com/stacks/axiom-cloudwatch-unsubscriber-v1.1.1-cloudformation-stack.yaml).
71136

72-
The log group filtering works the same way as the Subscriber stack. You can filter the log groups by a combination of names, prefix, and regular expression filters.
137+
The log group filtering works the same way as the Subscriber stack. You can filter the log groups by a combination of names, prefix, and regular expression filters.
138+
139+
Alternatively, to turn off log forwarding to Axiom, create a new Unsubscriber module in your Terraform file in the following way:
140+
141+
```hcl
142+
module "unsubscriber" {
143+
source = "axiomhq/axiom-cloudwatch-forwarder/aws//modules/unsubscriber"
144+
prefix = "axiom-cloudwatch-forwarder"
145+
forwarder_lambda_arn = module.forwarder.lambda_arn
146+
log_groups_prefix = "/aws/lambda/"
147+
}
148+
```

0 commit comments

Comments
 (0)