diff --git a/README.md b/README.md
index 4ee57e9..36dd7f8 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,15 @@ visit the [Amazon EKS cluster monitoring documentation](https://aws-observabilit
The sections below demonstrate how you can leverage AWS Observability Accelerator
to enable monitoring to an existing EKS cluster.
+### v2.x changes
+
+v2+ releases introduces couple of breaking changes compared to previous versions:
+
+- `modules/workloads/infra` module moves to `modules/eks-monitoring`
+- All EKS configuration options moves from the base module to the `eks-monitoring` module
+- All EKS workload modules `modules/workloads/{java,nginx}` merge into `eks-monitoring` as configuration options (patterns), see [examples](./examples) to provide a more complete visiblity.
+- All examples have been updated to reflect these changes
+
### Base Module
The base module allows you to configure the AWS Observability services for your cluster and
@@ -38,7 +47,7 @@ and ADOT Operator deployed for you and ready to receive your data.
The base module serve as an anchor to the workload modules and cannot run on its own.
```hcl
-module "eks_observability_accelerator" {
+module "aws_observability_accelerator" {
# use release tags and check for the latest versions
# https://github.com/aws-observability/terraform-aws-observability-accelerator/releases
source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v1.6.1"
@@ -46,7 +55,7 @@ module "eks_observability_accelerator" {
aws_region = "eu-west-1"
eks_cluster_id = "my-eks-cluster"
- # As Grafana shares a different lifecycle, it's best to use an existing workspace.
+ # As Grafana shares a different lifecycle, we recommend using an existing workspace.
managed_grafana_workspace_id = var.managed_grafana_workspace_id
grafana_api_key = var.grafana_api_key
}
@@ -55,7 +64,7 @@ module "eks_observability_accelerator" {
You can optionally reuse an existing Amazon Managed Servce for Prometheus Workspace:
```hcl
-module "eks_observability_accelerator" {
+module "aws_observability_accelerator" {
# use release tags and check for the latest versions
# https://github.com/aws-observability/terraform-aws-observability-accelerator/releases
source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v1.6.1"
@@ -78,10 +87,9 @@ View all the configuration options in the module documentation below.
### Workload modules
-[Workloads modules](./modules/workloads) are provided, which essentially provide curated
+[Workloads modules](./modules) are provided, which essentially provide curated
metrics collection, alerting rule and Grafana dashboards.
-
#### Infrastructure monitoring
```hcl
@@ -143,7 +151,6 @@ If you are interested in contributing, see the [Contribution guide](https://gith
| Name | Source | Version |
|------|--------|---------|
| [managed\_grafana](#module\_managed\_grafana) | terraform-aws-modules/managed-service-grafana/aws | ~> 1.3 |
-| [operator](#module\_operator) | ./modules/add-ons/adot-operator | n/a |
## Resources
@@ -153,10 +160,7 @@ If you are interested in contributing, see the [Contribution guide](https://gith
| [aws_prometheus_workspace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_workspace) | resource |
| [grafana_data_source.amp](https://registry.terraform.io/providers/grafana/grafana/1.25.0/docs/resources/data_source) | resource |
| [grafana_folder.this](https://registry.terraform.io/providers/grafana/grafana/1.25.0/docs/resources/folder) | resource |
-| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
-| [aws_eks_cluster.eks_cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
| [aws_grafana_workspace.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/grafana_workspace) | data source |
-| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
## Inputs
@@ -164,15 +168,10 @@ If you are interested in contributing, see the [Contribution guide](https://gith
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [aws\_region](#input\_aws\_region) | AWS Region | `string` | n/a | yes |
-| [eks\_cluster\_id](#input\_eks\_cluster\_id) | Name of the EKS cluster | `string` | n/a | yes |
| [enable\_alertmanager](#input\_enable\_alertmanager) | Creates Amazon Managed Service for Prometheus AlertManager for all workloads | `bool` | `false` | no |
-| [enable\_amazon\_eks\_adot](#input\_enable\_amazon\_eks\_adot) | Enables the ADOT Operator on the EKS Cluster | `bool` | `true` | no |
-| [enable\_cert\_manager](#input\_enable\_cert\_manager) | Allow reusing an existing installation of cert-manager | `bool` | `true` | no |
| [enable\_managed\_grafana](#input\_enable\_managed\_grafana) | Creates a new Amazon Managed Grafana Workspace | `bool` | `true` | no |
| [enable\_managed\_prometheus](#input\_enable\_managed\_prometheus) | Creates a new Amazon Managed Service for Prometheus Workspace | `bool` | `true` | no |
| [grafana\_api\_key](#input\_grafana\_api\_key) | Grafana API key for the Amazon Managed Grafana workspace | `string` | n/a | yes |
-| [irsa\_iam\_permissions\_boundary](#input\_irsa\_iam\_permissions\_boundary) | IAM permissions boundary for IRSA roles | `string` | `null` | no |
-| [irsa\_iam\_role\_path](#input\_irsa\_iam\_role\_path) | IAM role path for IRSA roles | `string` | `"/"` | no |
| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana Workspace ID | `string` | `""` | no |
| [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Service for Prometheus Workspace ID | `string` | `""` | no |
| [managed\_prometheus\_workspace\_region](#input\_managed\_prometheus\_workspace\_region) | Region where Amazon Managed Service for Prometheus is deployed | `string` | `null` | no |
@@ -183,9 +182,8 @@ If you are interested in contributing, see the [Contribution guide](https://gith
| Name | Description |
|------|-------------|
| [aws\_region](#output\_aws\_region) | AWS Region |
-| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
-| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [grafana\_dashboards\_folder\_id](#output\_grafana\_dashboards\_folder\_id) | Grafana folder ID for automatic dashboards. Required by workload modules |
+| [grafana\_prometheus\_datasource\_test](#output\_grafana\_prometheus\_datasource\_test) | Grafana save & test URL for Amazon Managed Prometheus workspace |
| [managed\_grafana\_workspace\_endpoint](#output\_managed\_grafana\_workspace\_endpoint) | Amazon Managed Grafana workspace endpoint |
| [managed\_grafana\_workspace\_id](#output\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana workspace ID |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
diff --git a/docs/concepts.md b/docs/concepts.md
index 9b5ef00..0ed2af3 100644
--- a/docs/concepts.md
+++ b/docs/concepts.md
@@ -31,6 +31,18 @@ you need to track changes as part of a Git repository or CI/CD pipeline.
!!! warning
When using `tfvars` files, always be careful to not store and commit any secrets (keys, passwords, ...)
+
+## v2.x changes
+
+v2.x [releases](https://github.com/aws-observability/terraform-aws-observability-accelerator/releases) introduce
+couple of breaking changes compared to previous versions:
+
+- `modules/workloads/infra` module moves to `modules/eks-monitoring`
+- EKS configuration options moves from the base module to the `eks-monitoring` module
+- EKS workload modules **java,nginx** merge into `eks-monitoring` as configuration options (patterns),
+see [examples](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/examples)
+- Examples have been updated to reflect these changes
+
## Base module
The base module allows you to configure the AWS Observability services for your cluster and
@@ -41,7 +53,7 @@ and ADOT Operator deployed for you and ready to receive your data.
The base module serve as an anchor to the workload modules and cannot run on its own.
```hcl
-module "eks_observability_accelerator" {
+module "aws_observability_accelerator" {
# use release tags and check for the latest versions
# https://github.com/aws-observability/terraform-aws-observability-accelerator/releases
source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v1.6.1"
@@ -49,7 +61,7 @@ module "eks_observability_accelerator" {
aws_region = "eu-west-1"
eks_cluster_id = "my-eks-cluster"
- # As Grafana shares a different lifecycle, it's best to use an existing workspace.
+ # As Grafana shares a different lifecycle, we recommend using an existing workspace.
managed_grafana_workspace_id = var.managed_grafana_workspace_id
grafana_api_key = var.grafana_api_key
}
@@ -58,7 +70,7 @@ module "eks_observability_accelerator" {
You can optionally reuse an existing Amazon Managed Service for Prometheus Workspace:
```hcl
-module "eks_observability_accelerator" {
+module "aws_observability_accelerator" {
# use release tags and check for the latest versions
# https://github.com/aws-observability/terraform-aws-observability-accelerator/releases
source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v1.6.1"
@@ -83,7 +95,7 @@ View all the configuration options in the [module's documentation](https://githu
Workloads modules are focused Terraform modules provided in this repository. They essentially provide curated metrics collection, alerts and Grafana dashboards according to the use case. Most of those modules require the base module.
-You can check the full workload modules list and their documentation [here](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/workloads).
+You can check the full workload modules list and their documentation [here](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/).
All the modules come with end-to-end deployable examples.
diff --git a/docs/eks/destroy.md b/docs/eks/destroy.md
index ca07449..389fcc8 100644
--- a/docs/eks/destroy.md
+++ b/docs/eks/destroy.md
@@ -15,11 +15,9 @@ terraform destroy
To remove resources from your Terraform state, run
```bash
-# grafana workspace
-terraform state rm "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"
-
# prometheus workspace
terraform state rm "module.eks_observability_accelerator.aws_prometheus_workspace.this[0]"
```
-> **Note:** To view all the features proposed by this module, visit the [module documentation](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/workloads/infra).
+!!! note
+ To view all the features proposed by this module, visit the [module documentation](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/workloads/infra).
diff --git a/docs/eks/index.md b/docs/eks/index.md
index faa69f7..e3e9c79 100644
--- a/docs/eks/index.md
+++ b/docs/eks/index.md
@@ -2,7 +2,7 @@
This example demonstrates how to monitor your Amazon Elastic Kubernetes Service
(Amazon EKS) cluster with the Observability Accelerator's EKS
-[infrastructure module](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/workloads/infra).
+[infrastructure module](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/feat/modules-composition/modules/eks-monitoring).
Monitoring Amazon Elastic Kubernetes Service (Amazon EKS) for metrics has two categories:
the control plane and the Amazon EKS nodes (with Kubernetes objects).
@@ -72,24 +72,17 @@ aws amp create-workspace --alias observability-accelerator --query '.workspaceId
### 5. Amazon Managed Grafana workspace
-To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, edit and run:
+To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, create an environment variable as described below.
+To create a new workspace, visit our Amazon Managed Grafana [documentation](https://docs.aws.amazon.com/grafana/latest/userguide/getting-started-with-AMG.html).
+Make sure to provide the workspace with Amazon Managed Service for Prometheus read permissions.
+
+!!! note
+ For the URL `https://g-xyz.grafana-workspace.eu-central-1.amazonaws.com`, the workspace ID would be `g-xyz`
```bash
export TF_VAR_managed_grafana_workspace_id=g-xxx
```
-To create a new one, within this example's Terraform state (sharing the same lifecycle with all the
-other resources created by Terraform):
-
-- Edit main.tf and set `enable_managed_grafana = true`
-- Run
-
-```bash
-terraform init
-terraform apply -target "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"
-export TF_VAR_managed_grafana_workspace_id=$(terraform output --raw managed_grafana_workspace_id)
-```
-
### 6. Grafana API Key
Amazon Managed Grafana provides a control plane API for generating Grafana API keys.
@@ -114,7 +107,13 @@ terraform apply
1. Prometheus datasource on Grafana
-Open your Grafana workspace and under Configuration -> Data sources, you should see `aws-observability-accelerator`. Open and click `Save & test`. You should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+Make sure to open the link in the output. After a successful deployment, this will open
+the Prometheus datasource configuration on Grafana.
+Click `Save & test` and you should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+
+```bash
+terraform output grafana_prometheus_datasource_test
+```
2. Grafana dashboards
@@ -126,7 +125,7 @@ Open a specific dashboard and you should be able to view its visualization
-2. Amazon Managed Service for Prometheus rules and alerts
+3. Amazon Managed Service for Prometheus rules and alerts
Open the Amazon Managed Service for Prometheus console and view the details of your workspace. Under the `Rules management` tab, you should find new rules deployed.
diff --git a/docs/eks/java.md b/docs/eks/java.md
new file mode 100644
index 0000000..c863970
--- /dev/null
+++ b/docs/eks/java.md
@@ -0,0 +1,120 @@
+# Monitor Java/JMX applications running on Amazon EKS
+
+!!! note
+ Since v2.x, Java based applications monitoring on EKS has been merged within
+ the [eks-monitoring module](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/feat/modules-composition/modules/eks-monitoring)
+ to allow visibility both on the cluster and the workloads, [#59](https://github.com/aws-observability/terraform-aws-observability-accelerator/issues/59).
+
+In addition to EKS infrastructure monitoring, the current example provides
+curated Grafana dashboards, Prometheus alerting and recording rules with multiple
+configuration options for Java based workloads on EKS.
+
+## Setup
+
+### 1. Add Java metrics, dashboards and alerts
+
+From the [previous example's](https://aws-observability.github.io/terraform-aws-observability-accelerator/eks/) configuration,
+simply enable the Java pattern's flag.
+
+```hcl
+
+module "eks_monitoring" {
+ ...
+ enable_java = true
+}
+```
+
+You can further customize the Java pattern by providing `java_config` [options](https://github.com/aws-observability/terraform-aws-observability-accelerator/blob/feat/modules-composition/modules/eks-monitoring/README.md#input_java_config).
+
+### 2. Grafana API key
+
+Make sure to refresh your temporary Grafana API key
+
+```bash
+export TF_VAR_managed_grafana_workspace_id=g-xxx
+export TF_VAR_grafana_api_key=`aws grafana create-workspace-api-key --key-name "observability-accelerator-$(date +%s)" --key-role ADMIN --seconds-to-live 1200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`
+```
+
+## Deploy
+
+Simply run this command to deploy.
+
+```bash
+terraform apply
+```
+
+!!! note
+ To see the complete Java example, open the [example on the repository](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/examples/existing-cluster-java)
+
+## Visualization
+
+1. Grafana dashboards
+
+Go to the Dashboards panel of your Grafana workspace. There will be a folder called `Observability Accelerator Dashboards`
+
+
+
+Open the "Java/JMX" dashboard to view its visualization
+
+
+
+2. Amazon Managed Service for Prometheus rules and alerts
+
+Open the Amazon Managed Service for Prometheus console and view the details of your workspace. Under the `Rules management` tab, you will find new rules deployed.
+
+
+
+!!! note
+ To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
+
+
+## Deploy an example Java application
+
+In this section we will reuse an example from the AWS OpenTelemetry collector [repository](https://github.com/aws-observability/aws-otel-collector/blob/main/docs/developers/container-insights-eks-jmx.md). For convenience, the steps can be found below.
+
+1. Clone [this repository](https://github.com/aws-observability/aws-otel-test-framework) and navigate to the `sample-apps/jmx/` directory.
+
+2. Authenticate to Amazon ECR
+
+```sh
+export AWS_ACCOUNT_ID=`aws sts get-caller-identity --query Account --output text`
+export AWS_REGION={region}
+aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
+```
+
+3. Create an Amazon ECR repository
+
+```sh
+aws ecr create-repository --repository-name prometheus-sample-tomcat-jmx \
+ --image-scanning-configuration scanOnPush=true \
+ --region $AWS_REGION
+```
+
+4. Build Docker image and push to ECR.
+
+```sh
+docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/prometheus-sample-tomcat-jmx:latest .
+docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/prometheus-sample-tomcat-jmx:latest
+```
+
+5. Install sample application
+
+```sh
+export SAMPLE_TRAFFIC_NAMESPACE=javajmx-sample
+curl https://raw.githubusercontent.com/aws-observability/aws-otel-test-framework/terraform/sample-apps/jmx/examples/prometheus-metrics-sample.yaml > metrics-sample.yaml
+sed -i "s/{{aws_account_id}}/$AWS_ACCOUNT_ID/g" metrics-sample.yaml
+sed -i "s/{{region}}/$AWS_REGION/g" metrics-sample.yaml
+sed -i "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" metrics-sample.yaml
+kubectl apply -f metrics-sample.yaml
+```
+
+Verify that the sample application is running:
+
+```sh
+kubectl get pods -n $SAMPLE_TRAFFIC_NAMESPACE
+
+NAME READY STATUS RESTARTS AGE
+tomcat-bad-traffic-generator 1/1 Running 0 11s
+tomcat-example-7958666589-2q755 0/1 ContainerCreating 0 11s
+tomcat-traffic-generator 1/1 Running 0 11s
+```
diff --git a/docs/eks/nginx.md b/docs/eks/nginx.md
new file mode 100644
index 0000000..dca713b
--- /dev/null
+++ b/docs/eks/nginx.md
@@ -0,0 +1,120 @@
+# Monitor Nginx applications running on Amazon EKS
+
+!!! note
+ Since v2.x, NGINX based applications monitoring on EKS has been merged within
+ the [eks-monitoring module](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/feat/modules-composition/modules/eks-monitoring)
+ to allow visibility both on the cluster and the workloads, [#59](https://github.com/aws-observability/terraform-aws-observability-accelerator/issues/59).
+
+In addition to EKS infrastructure monitoring, the current example provides
+curated Grafana dashboards, Prometheus alerting and recording rules with multiple
+configuration options for NGINX based workloads on EKS.
+
+## Setup
+
+### 1. Add NGINX metrics, dashboards and alerts
+
+From the [EKS cluster monitoring example's](https://aws-observability.github.io/terraform-aws-observability-accelerator/eks/) configuration,
+simply enable the NGINX pattern's flag.
+
+```hcl
+
+module "eks_monitoring" {
+ ...
+ enable_nginx = true
+}
+```
+
+You can further customize the NGINX pattern by providing `nginx_config` [options](https://github.com/aws-observability/terraform-aws-observability-accelerator/blob/feat/modules-composition/modules/eks-monitoring/README.md#input_nginx_config).
+
+### 2. Grafana API key
+
+Make sure to refresh your temporary Grafana API key
+
+```bash
+export TF_VAR_managed_grafana_workspace_id=g-xxx
+export TF_VAR_grafana_api_key=`aws grafana create-workspace-api-key --key-name "observability-accelerator-$(date +%s)" --key-role ADMIN --seconds-to-live 1200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`
+```
+
+## Deploy
+
+Simply run this command to deploy.
+
+```bash
+terraform apply
+```
+
+!!! note
+ To see the complete NGINX example, open the [example on the repository](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/examples/existing-cluster-nginx)
+
+## Visualization
+
+1. Grafana dashboards
+
+Go to the Dashboards panel of your Grafana workspace. You will see a list of dashboards under the `Observability Accelerator Dashboards`
+
+
+
+Open the NGINX dashboard and you will be able to view its visualization
+
+
+
+2. Amazon Managed Service for Prometheus rules and alerts
+
+Open the Amazon Managed Service for Prometheus console and view the details of your workspace. Under the `Rules management` tab, you will find new rules deployed.
+
+
+
+!!! note
+ To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
+
+## Deploy an example application to visualize metrics
+
+In this section we will deploy sample application and extract metrics using AWS OpenTelemetry collector
+
+### 1. Add the helm incubator repo:
+
+```sh
+helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
+```
+
+### 2. Enter the following command to create a new namespace:
+
+```sh
+kubectl create namespace nginx-ingress-sample
+```
+
+### 3. Enter the following commands to install NGINX:
+
+```sh
+helm install my-nginx ingress-nginx/ingress-nginx \
+--namespace nginx-ingress-sample \
+--set controller.metrics.enabled=true \
+--set-string controller.metrics.service.annotations."prometheus\.io/port"="10254" \
+--set-string controller.metrics.service.annotations."prometheus\.io/scrape"="true"
+```
+
+### 4. Set an EXTERNAL-IP variable to the value of the EXTERNAL-IP column in the row of the NGINX ingress controller.
+
+```sh
+EXTERNAL_IP=your-nginx-controller-external-ip
+```
+
+### 5. Start some sample NGINX traffic by entering the following command.
+
+```sh
+SAMPLE_TRAFFIC_NAMESPACE=nginx-sample-traffic
+curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/sample_traffic/nginx-traffic/nginx-traffic-sample.yaml |
+sed "s/{{external_ip}}/$EXTERNAL_IP/g" |
+sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" |
+kubectl apply -f -
+```
+
+### 6. Verify if the application is running
+
+```sh
+kubectl get pods -n nginx-ingress-sample
+```
+
+### 7. Visualize the Application's dashboard
+
+Log back into your Managed Grafana Workspace and navigate to the dashboard side panel, click on `Observability Accelerator Dashboards` Folder and open the `NGINX` Dashboard.
diff --git a/docs/images/example-diagram.svg b/docs/images/example-diagram.svg
index 2d77f3b..c1364f4 100644
--- a/docs/images/example-diagram.svg
+++ b/docs/images/example-diagram.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/docs/index.md b/docs/index.md
index 4967afd..5dd031c 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -31,7 +31,7 @@ to be deployed in our packaged
We have supporting examples for quick setup such as:
- Creating an empty Amazon EKS cluster and a VPC
- - Creating and configure an Amazon Managed Grafana workspace with SSO
+ - Creating and configure an Amazon Managed Grafana workspace with SSO (coming soon)
## Motivation
diff --git a/docs/support.md b/docs/support.md
new file mode 100644
index 0000000..82164b3
--- /dev/null
+++ b/docs/support.md
@@ -0,0 +1,9 @@
+# Support & Feedback
+
+AWS Observability Accelerator for Terraform is maintained by AWS Solution Architects.
+It is not part of an AWS service and support is provided best-effort by the
+AWS Observability Accelerator community.
+
+To post feedback, submit feature ideas, or report bugs, please use the [issues](https://github.com/aws-observability/terraform-aws-observability-accelerator/issues) section of this GitHub repo.
+
+If you are interested in contributing, see the [contribution guide](https://github.com/aws-observability/terraform-aws-observability-accelerator/blob/main/CONTRIBUTING.md).
diff --git a/docs/workloads/java.md b/docs/workloads/java.md
deleted file mode 100644
index 9a1c113..0000000
--- a/docs/workloads/java.md
+++ /dev/null
@@ -1,196 +0,0 @@
-# Monitor Java/JMX applications running on Amazon EKS
-
-The current example deploys the [java workload module](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/workloads/java),
-to provide to an existing EKS cluster with an OpenTelemetry collector,
-curated Grafana dashboards, Prometheus alerting and recording rules with multiple
-configuration options on the cluster infrastructure.
-
-## Prerequisites
-
-!!! note
- Make sure to complete the [prerequisites section](https://aws-observability.github.io/terraform-aws-observability-accelerator/concepts/#prerequisites) before proceeding.
-
-## Setup
-
-### 1. Download sources and initialize Terraform
-
-```bash
-git clone https://github.com/aws-observability/terraform-aws-observability-accelerator.git
-cd examples/existing-cluster-java
-terraform init
-```
-
-### 2. AWS Region
-
-Specify the AWS Region where the resources will be deployed:
-
-```bash
-export TF_VAR_aws_region=xxx
-```
-
-### 3. Amazon EKS Cluster
-
-To run this example, you need to provide your EKS cluster name. If you don't
-have a cluster ready, visit [this example](https://aws-observability.github.io/terraform-aws-observability-accelerator/helpers/new-eks-cluster/)
-first to create a new one.
-
-Specify your cluster name:
-
-```bash
-export TF_VAR_eks_cluster_id=xxx
-```
-
-### 4. Amazon Managed Service for Prometheus workspace (optional)
-
-By default, we create an Amazon Managed Service for Prometheus workspace for you.
-However, if you have an existing workspace you want to reuse, edit and run:
-
-```bash
-export TF_VAR_managed_prometheus_workspace_id=ws-xxx
-```
-
-To create a workspace outside of Terraform's state, simply run:
-
-```bash
-aws amp create-workspace --alias observability-accelerator --query '.workspaceId' --output text
-```
-
-### 5. Amazon Managed Grafana workspace
-
-To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, edit and run:
-
-```bash
-export TF_VAR_managed_grafana_workspace_id=g-xxx
-```
-
-To create a new one, within this example's Terraform state (sharing the same lifecycle with all the other resources):
-
-- Edit main.tf and set `enable_managed_grafana = true`
-- Run
-
-```bash
-terraform init
-terraform apply -target "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"
-export TF_VAR_managed_grafana_workspace_id=$(terraform output --raw managed_grafana_workspace_id)
-```
-
-### 6. Grafana API Key
-
-Amazon Managed Grafana provides a control plane API for generating Grafana API keys.
-As a security best practice, we will provide to Terraform a short lived API key to
-run the `apply` or `destroy` command.
-
-Ensure you have necessary IAM permissions (`CreateWorkspaceApiKey, DeleteWorkspaceApiKey`)
-
-```bash
-export TF_VAR_grafana_api_key=`aws grafana create-workspace-api-key --key-name "observability-accelerator-$(date +%s)" --key-role ADMIN --seconds-to-live 1200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`
-```
-
-## Deploy
-
-Simply run this command to deploy.
-
-```bash
-terraform apply
-```
-
-## Visualization
-
-1. Prometheus datasource on Grafana
-
-Open your Grafana workspace and under Configuration -> Data sources, you will see `aws-observability-accelerator`. Open and click `Save & test`. You will then see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
-
-2. Grafana dashboards
-
-Go to the Dashboards panel of your Grafana workspace. There will be a folder called `Observability Accelerator Dashboards`
-
-
-
-Open the "Java/JMX" dashboard to view its visualization
-
-
-
-2. Amazon Managed Service for Prometheus rules and alerts
-
-Open the Amazon Managed Service for Prometheus console and view the details of your workspace. Under the `Rules management` tab, you will find new rules deployed.
-
-
-
-!!! note
- To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
-
-
-## Deploy an Example Java Application
-
-In this section we will reuse an example from the AWS OpenTelemetry collector [repository](https://github.com/aws-observability/aws-otel-collector/blob/main/docs/developers/container-insights-eks-jmx.md). For convenience, the steps can be found below.
-
-1. Clone [this repository](https://github.com/aws-observability/aws-otel-test-framework) and navigate to the `sample-apps/jmx/` directory.
-
-2. Authenticate to Amazon ECR
-
-```sh
-export AWS_ACCOUNT_ID=`aws sts get-caller-identity --query Account --output text`
-export AWS_REGION={region}
-aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
-```
-
-3. Create an Amazon ECR repository
-
-```sh
-aws ecr create-repository --repository-name prometheus-sample-tomcat-jmx \
- --image-scanning-configuration scanOnPush=true \
- --region $AWS_REGION
-```
-
-4. Build Docker image and push to ECR.
-
-```sh
-docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/prometheus-sample-tomcat-jmx:latest .
-docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/prometheus-sample-tomcat-jmx:latest
-```
-
-5. Install sample application
-
-```sh
-export SAMPLE_TRAFFIC_NAMESPACE=javajmx-sample
-curl https://raw.githubusercontent.com/aws-observability/aws-otel-test-framework/terraform/sample-apps/jmx/examples/prometheus-metrics-sample.yaml > metrics-sample.yaml
-sed -i "s/{{aws_account_id}}/$AWS_ACCOUNT_ID/g" metrics-sample.yaml
-sed -i "s/{{region}}/$AWS_REGION/g" metrics-sample.yaml
-sed -i "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" metrics-sample.yaml
-kubectl apply -f metrics-sample.yaml
-```
-
-Verify that the sample application is running:
-
-```sh
-kubectl get pods -n $SAMPLE_TRAFFIC_NAMESPACE
-
-NAME READY STATUS RESTARTS AGE
-tomcat-bad-traffic-generator 1/1 Running 0 11s
-tomcat-example-7958666589-2q755 0/1 ContainerCreating 0 11s
-tomcat-traffic-generator 1/1 Running 0 11s
-```
-
-## Destroy resources
-
-If you leave this stack running, you will continue to incur charges. To remove all resources
-created by Terraform, [refresh your Grafana API key](#6-grafana-api-key) and run the command below.
-
-!!! warning
- Be careful, this command will removing everything created by Terraform. If you wish
- to keep your Amazon Managed Grafana or Amazon Managed Service for Prometheus workspaces. Remove them
- from your terraform state before running the destroy command.
-
-```bash
-terraform destroy
-```
-
-To remove resources from your Terraform state, run
-
-```bash
-# grafana workspace
-terraform state rm "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"
-
-# prometheus workspace
-terraform state rm "module.eks_observability_accelerator.aws_prometheus_workspace.this[0]"
-```
diff --git a/docs/workloads/nginx.md b/docs/workloads/nginx.md
deleted file mode 100644
index e5aad86..0000000
--- a/docs/workloads/nginx.md
+++ /dev/null
@@ -1,198 +0,0 @@
-# Monitor Nginx applications running on Amazon EKS
-
-The current example deploys the [nginx workload module](https://github.com/aws-observability/terraform-aws-observability-accelerator/tree/main/modules/workloads/nginx),
-to provide an existing EKS cluster with an OpenTelemetry collector,
-curated Grafana dashboards, Prometheus alerting and recording rules with multiple
-configuration options on the cluster infrastructure.
-
-
-## Prerequisites
-
-!!! note
- Make sure to complete the [prerequisites section](https://aws-observability.github.io/terraform-aws-observability-accelerator/concepts/#prerequisites) before proceeding.
-
-## Setup
-
-
-### 1. Download sources and initialize Terraform
-
-```bash
-git clone https://github.com/aws-observability/terraform-aws-observability-accelerator.git
-cd examples/existing-cluster-nginx
-terraform init
-```
-
-### 2. AWS Region
-
-Specify the AWS Region where the resources will be deployed:
-
-```bash
-export TF_VAR_aws_region=xxx
-```
-
-### 3. Amazon EKS Cluster
-
-To run this example, you need to provide your EKS cluster name. If you don't
-have a cluster ready, visit [this example](https://aws-observability.github.io/terraform-aws-observability-accelerator/helpers/new-eks-cluster/)
-first to create a new one.
-
-Specify your cluster name:
-
-```bash
-export TF_VAR_eks_cluster_id=xxx
-```
-
-### 4. Amazon Managed Service for Prometheus workspace (optional)
-
-By default, we create an Amazon Managed Service for Prometheus workspace for you.
-However, if you have an existing workspace you want to reuse, edit and run:
-
-```bash
-export TF_VAR_managed_prometheus_workspace_id=ws-xxx
-```
-
-To create a workspace outside of Terraform's state, simply run:
-
-```bash
-aws amp create-workspace --alias observability-accelerator --query '.workspaceId' --output text
-```
-
-### 5. Amazon Managed Grafana workspace
-
-To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, edit and run:
-
-```bash
-export TF_VAR_managed_grafana_workspace_id=g-xxx
-```
-
-To create a new one, within this example's Terraform state (sharing the same lifecycle with all the other resources):
-
-- Edit main.tf and set `enable_managed_grafana = true`
-- Run
-
-```bash
-terraform init
-terraform apply -target "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"
-export TF_VAR_managed_grafana_workspace_id=$(terraform output --raw managed_grafana_workspace_id)
-```
-
-### 6. Grafana API Key
-
-Amazon Managed Grafana provides a control plane API for generating Grafana API keys.
-As a security best practice, we will provide to Terraform a short lived API key to
-run the `apply` or `destroy` command.
-
-Ensure you have necessary IAM permissions (`CreateWorkspaceApiKey, DeleteWorkspaceApiKey`)
-
-```bash
-export TF_VAR_grafana_api_key=`aws grafana create-workspace-api-key --key-name "observability-accelerator-$(date +%s)" --key-role ADMIN --seconds-to-live 1200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`
-```
-
-## Deploy
-
-Simply run this command to deploy.
-
-```bash
-terraform apply
-```
-
-## Visualization
-
-### 1. Prometheus datasource on Grafana
-
-Open your Grafana workspace and under Configuration -> Data sources, you will see `aws-observability-accelerator`. Open and click `Save & test`. You will see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
-
-### 2. Grafana dashboards
-
-Go to the Dashboards panel of your Grafana workspace. You will see a list of dashboards under the `Observability Accelerator Dashboards`
-
-
-
-Open the NGINX dashboard and you will be able to view its visualization
-
-
-
-### 3. Amazon Managed Service for Prometheus rules and alerts
-
-Open the Amazon Managed Service for Prometheus console and view the details of your workspace. Under the `Rules management` tab, you will find new rules deployed.
-
-
-
-!!! note
- To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
-
-## Deploy an Example Application to Visualize
-
-In this section we will deploy sample application and extract metrics using AWS OpenTelemetry collector
-
-### 1. Add the helm incubator repo:
-
-```sh
-helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
-```
-
-### 2. Enter the following command to create a new namespace:
-
-```sh
-kubectl create namespace nginx-ingress-sample
-```
-
-### 3. Enter the following commands to install NGINX:
-
-```sh
-helm install my-nginx ingress-nginx/ingress-nginx \
---namespace nginx-ingress-sample \
---set controller.metrics.enabled=true \
---set-string controller.metrics.service.annotations."prometheus\.io/port"="10254" \
---set-string controller.metrics.service.annotations."prometheus\.io/scrape"="true"
-```
-
-### 4. Set an EXTERNAL-IP variable to the value of the EXTERNAL-IP column in the row of the NGINX ingress controller.
-
-```sh
-EXTERNAL_IP=your-nginx-controller-external-ip
-```
-
-### 5. Start some sample NGINX traffic by entering the following command.
-
-```sh
-SAMPLE_TRAFFIC_NAMESPACE=nginx-sample-traffic
-curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/sample_traffic/nginx-traffic/nginx-traffic-sample.yaml |
-sed "s/{{external_ip}}/$EXTERNAL_IP/g" |
-sed "s/{{namespace}}/$SAMPLE_TRAFFIC_NAMESPACE/g" |
-kubectl apply -f -
-```
-
-### 6. Verify if the application is running
-
-```sh
-kubectl get pods -n nginx-ingress-sample
-```
-
-### 7. Visualize the Application's dashboard
-
-Log back into your Managed Grafana Workspace and navigate to the dashboard side panel, click on `Observability Accelerator Dashboards` Folder and open the `NGINX` Dashboard.
-
-## Destroy resources
-
-If you leave this stack running, you will continue to incur charges. To remove all resources
-created by Terraform, [refresh your Grafana API key](#6-grafana-api-key) and run the command below.
-
-!!! warning
- Be careful, this command will removing everything created by Terraform. If you wish
- to keep your Amazon Managed Grafana or Amazon Managed Service for Prometheus workspaces. Remove them
- from your terraform state before running the destroy command.
-
-```bash
-terraform destroy
-```
-
-To remove resources from your Terraform state, run
-
-```bash
-# grafana workspace
-terraform state rm "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"
-
-# prometheus workspace
-terraform state rm "module.eks_observability_accelerator.aws_prometheus_workspace.this[0]"
-```
diff --git a/examples/existing-cluster-java/README.md b/examples/existing-cluster-java/README.md
index e507c48..03a3cbf 100644
--- a/examples/existing-cluster-java/README.md
+++ b/examples/existing-cluster-java/README.md
@@ -1,15 +1,16 @@
-# Existing Cluster with the AWS Observability accelerator base module and Java monitoring
-
+# Monitor Java applications running on Amazon EKS
This example demonstrates how to use the AWS Observability Accelerator Terraform
-modules with Java monitoring enabled.
-The current example deploys the [AWS Distro for OpenTelemetry Operator](https://docs.aws.amazon.com/eks/latest/userguide/opentelemetry.html) for Amazon EKS with its requirements and make use of existing
-Amazon Managed Service for Prometheus and Amazon Managed Grafana workspaces.
+modules to monitor EKS infrastructure and Java based workloads.
+The current example deploys the [AWS Distro for OpenTelemetry Operator](https://docs.aws.amazon.com/eks/latest/userguide/opentelemetry.html)
+for Amazon EKS with its requirements and make use of an existing Amazon Managed Grafana workspace.
+It creates a new Amazon Managed Service for Prometheus workspace unless provided with an existing one to reuse.
-It is based on the `java module`, one of our [workloads modules](../../modules/workloads/)
+Since v2.x releases, it uses the `EKS monitoring` [module](../../modules/eks-monitoring/)
to provide an existing EKS cluster with an OpenTelemetry collector,
curated Grafana dashboards, Prometheus alerting and recording rules with multiple
configuration options on the cluster infrastructure.
+You will gain both visibility on the cluster and Java based applications.
## Prerequisites
@@ -39,11 +40,7 @@ cd examples/existing-cluster-java
terraform init
```
-3. AWS Region
-
-Specify the AWS Region where the resources will be deployed. Edit the `terraform.tfvars` file and modify `aws_region="..."`. You can also use environement variables `export TF_VAR_aws_region=xxx`.
-
-4. Amazon EKS Cluster
+3. Amazon EKS Cluster
To run this example, you need to provide your EKS cluster name.
If you don't have a cluster ready, visit [this example](../eks-cluster-with-vpc)
@@ -51,18 +48,15 @@ first to create a new one.
Add your cluster name for `eks_cluster_id="..."` to the `terraform.tfvars` or use an environment variable `export TF_VAR_eks_cluster_id=xxx`.
-5. Amazon Managed Service for Prometheus workspace (optional)
+4. Amazon Managed Grafana workspace
-If you have an existing workspace, add `managed_prometheus_workspace_id=ws-xxx`
-or use an environment variable `export TF_VAR_managed_prometheus_workspace_id=ws-xxx`.
+To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, create an environment variable `export TF_VAR_managed_grafana_workspace_id=g-xxx`.
+To create a new one, visit our Amazon Managed Grafana [documentation](https://docs.aws.amazon.com/grafana/latest/userguide/getting-started-with-AMG.html).
+Make sure to provide the workspace with Amazon Managed Service for Prometheus read permissions.
-If you don't specify anything a new workspace will be created for you.
+> In the URL `https://g-xyz.grafana-workspace.eu-central-1.amazonaws.com`, the workspace ID would be `g-xyz`
-6. Amazon Managed Grafana workspace
-
-If you have an existing workspace, create an environment variable `export TF_VAR_managed_grafana_workspace_id=g-xxx`.
-
-7. Grafana API Key
+5. Grafana API Key
Amazon Managed Service for Grafana provides a control plane API for generating Grafana API keys. We will provide to Terraform
a short lived API key to run the `apply` or `destroy` command.
@@ -84,11 +78,31 @@ or if you had only setup environment variables, run
terraform apply
```
+## Additional configuration
+
+For the purpose of the example, we have provided default values for some of the variables.
+
+1. AWS Region
+
+Specify the AWS Region where the resources will be deployed. Edit the `terraform.tfvars` file and modify `aws_region="..."`. You can also use environement variables `export TF_VAR_aws_region=xxx`.
+
+
+2. Amazon Managed Service for Prometheus workspace
+
+If you have an existing workspace, add `managed_prometheus_workspace_id=ws-xxx`
+or use an environment variable `export TF_VAR_managed_prometheus_workspace_id=ws-xxx`.
+
## Visualization
1. Prometheus datasource on Grafana
-Open your Grafana workspace and under Configuration -> Data sources, you will see `aws-observability-accelerator`. Open and click `Save & test`. You will then see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+Make sure to open the link in the output. After a successful deployment, this will open
+the Prometheus datasource configuration on Grafana.
+Click `Save & test` and you should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+
+```bash
+terraform output grafana_prometheus_datasource_test
+```
2. Grafana dashboards
@@ -109,7 +123,7 @@ Open the Amazon Managed Service for Prometheus console and view the details of y
To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
-## Deploy an Example Java Application
+## Deploy an example Java application
In this section we will reuse an example from the AWS OpenTelemetry collector [repository](https://github.com/aws-observability/aws-otel-collector/blob/main/docs/developers/container-insights-eks-jmx.md). For convenience, the steps can be found below.
@@ -160,18 +174,6 @@ tomcat-example-7958666589-2q755 0/1 ContainerCreating 0 11s
tomcat-traffic-generator 1/1 Running 0 11s
```
-## Advanced configuration
-
-1. Cross-region Amazon Managed Prometheus workspace
-
-If your existing Amazon Managed Prometheus workspace is in another AWS Region,
-add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws-xxx`.
-
-2. Cross-region Amazon Managed Grafana workspace
-
-If your existing Amazon Managed Prometheus workspace is in another AWS Region,
-add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws-xxx`.
-
## Destroy resources
If you leave this stack running, you will continue to incur charges. To remove all resources
@@ -204,8 +206,8 @@ terraform destroy -var-file=terraform.tfvars
| Name | Source | Version |
|------|--------|---------|
-| [eks\_observability\_accelerator](#module\_eks\_observability\_accelerator) | ../../ | n/a |
-| [workloads\_java](#module\_workloads\_java) | ../../modules/workloads/java | n/a |
+| [aws\_observability\_accelerator](#module\_aws\_observability\_accelerator) | ../../ | n/a |
+| [eks\_monitoring](#module\_eks\_monitoring) | ../../modules/eks-monitoring | n/a |
## Resources
@@ -220,8 +222,8 @@ terraform destroy -var-file=terraform.tfvars
|------|-------------|------|---------|:--------:|
| [aws\_region](#input\_aws\_region) | AWS Region | `string` | n/a | yes |
| [eks\_cluster\_id](#input\_eks\_cluster\_id) | Name of the EKS cluster | `string` | n/a | yes |
-| [grafana\_api\_key](#input\_grafana\_api\_key) | API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana | `string` | `""` | no |
-| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana Workspace ID | `string` | `""` | no |
+| [grafana\_api\_key](#input\_grafana\_api\_key) | API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana | `string` | n/a | yes |
+| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana Workspace ID | `string` | n/a | yes |
| [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Service for Prometheus Workspace ID | `string` | `""` | no |
## Outputs
@@ -232,6 +234,7 @@ terraform destroy -var-file=terraform.tfvars
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [grafana\_dashboard\_urls](#output\_grafana\_dashboard\_urls) | URLs for dashboards created |
+| [grafana\_prometheus\_datasource\_test](#output\_grafana\_prometheus\_datasource\_test) | Grafana save & test URL for Amazon Managed Prometheus workspace |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
diff --git a/examples/existing-cluster-java/main.tf b/examples/existing-cluster-java/main.tf
index 23716b6..71b385f 100644
--- a/examples/existing-cluster-java/main.tf
+++ b/examples/existing-cluster-java/main.tf
@@ -34,28 +34,17 @@ locals {
}
# deploys the base module
-module "eks_observability_accelerator" {
- # source = "aws-observability/terrarom-aws-observability-accelerator"
+module "aws_observability_accelerator" {
source = "../../"
+ # source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v2.0.0"
- aws_region = var.aws_region
- eks_cluster_id = var.eks_cluster_id
-
- # deploys AWS Distro for OpenTelemetry operator into the cluster
- enable_amazon_eks_adot = true
-
- # reusing existing certificate manager? defaults to true
- enable_cert_manager = true
+ aws_region = var.aws_region
# creates a new Amazon Managed Prometheus workspace, defaults to true
enable_managed_prometheus = local.create_new_workspace
# reusing existing Amazon Managed Prometheus if specified
- managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
- managed_prometheus_workspace_region = null # defaults to the current region, useful for cross region scenarios (same account)
-
- # sets up the Amazon Managed Prometheus alert manager at the workspace level
- enable_alertmanager = true
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
# reusing existing Amazon Managed Grafana workspace
enable_managed_grafana = false
@@ -70,20 +59,24 @@ module "eks_observability_accelerator" {
# any provider blocks.
# This allows forcing dependency between base and workloads module
provider "grafana" {
- url = module.eks_observability_accelerator.managed_grafana_workspace_endpoint
+ url = module.aws_observability_accelerator.managed_grafana_workspace_endpoint
auth = var.grafana_api_key
}
-module "workloads_java" {
- source = "../../modules/workloads/java"
+module "eks_monitoring" {
+ source = "../../modules/eks-monitoring"
+ # source = "github.com/aws-observability/terraform-aws-observability-accelerator//modules/eks-monitoring?ref=v2.0.0"
- eks_cluster_id = module.eks_observability_accelerator.eks_cluster_id
+ # enable java metrics collection, dashboards and alerts rules creation
+ enable_java = true
- dashboards_folder_id = module.eks_observability_accelerator.grafana_dashboards_folder_id
- managed_prometheus_workspace_id = module.eks_observability_accelerator.managed_prometheus_workspace_id
+ eks_cluster_id = var.eks_cluster_id
- managed_prometheus_workspace_endpoint = module.eks_observability_accelerator.managed_prometheus_workspace_endpoint
- managed_prometheus_workspace_region = module.eks_observability_accelerator.managed_prometheus_workspace_region
+ dashboards_folder_id = module.aws_observability_accelerator.grafana_dashboards_folder_id
+ managed_prometheus_workspace_id = module.aws_observability_accelerator.managed_prometheus_workspace_id
+
+ managed_prometheus_workspace_endpoint = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
+ managed_prometheus_workspace_region = module.aws_observability_accelerator.managed_prometheus_workspace_region
# optional, defaults to 60s interval and 15s timeout
prometheus_config = {
@@ -95,6 +88,6 @@ module "workloads_java" {
tags = local.tags
depends_on = [
- module.eks_observability_accelerator
+ module.aws_observability_accelerator
]
}
diff --git a/examples/existing-cluster-java/outputs.tf b/examples/existing-cluster-java/outputs.tf
index 2a73bdb..586cffd 100644
--- a/examples/existing-cluster-java/outputs.tf
+++ b/examples/existing-cluster-java/outputs.tf
@@ -1,29 +1,34 @@
-output "eks_cluster_id" {
- description = "EKS Cluster Id"
- value = module.eks_observability_accelerator.eks_cluster_id
-}
-
output "aws_region" {
description = "AWS Region"
- value = module.eks_observability_accelerator.aws_region
-}
-
-output "eks_cluster_version" {
- description = "EKS Cluster version"
- value = module.eks_observability_accelerator.eks_cluster_version
+ value = module.aws_observability_accelerator.aws_region
}
output "managed_prometheus_workspace_endpoint" {
description = "Amazon Managed Prometheus workspace endpoint"
- value = module.eks_observability_accelerator.managed_prometheus_workspace_endpoint
+ value = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
}
output "managed_prometheus_workspace_id" {
description = "Amazon Managed Prometheus workspace ID"
- value = module.eks_observability_accelerator.managed_prometheus_workspace_id
+ value = module.aws_observability_accelerator.managed_prometheus_workspace_id
}
output "grafana_dashboard_urls" {
description = "URLs for dashboards created"
- value = module.workloads_java.grafana_dashboard_urls
+ value = module.eks_monitoring.grafana_dashboard_urls
+}
+
+output "grafana_prometheus_datasource_test" {
+ description = "Grafana save & test URL for Amazon Managed Prometheus workspace"
+ value = module.aws_observability_accelerator.grafana_prometheus_datasource_test
+}
+
+output "eks_cluster_version" {
+ description = "EKS Cluster version"
+ value = module.eks_monitoring.eks_cluster_version
+}
+
+output "eks_cluster_id" {
+ description = "EKS Cluster Id"
+ value = module.eks_monitoring.eks_cluster_id
}
diff --git a/examples/existing-cluster-java/variables.tf b/examples/existing-cluster-java/variables.tf
index 74d795f..73aa65d 100644
--- a/examples/existing-cluster-java/variables.tf
+++ b/examples/existing-cluster-java/variables.tf
@@ -14,11 +14,9 @@ variable "managed_prometheus_workspace_id" {
variable "managed_grafana_workspace_id" {
description = "Amazon Managed Grafana Workspace ID"
type = string
- default = ""
}
variable "grafana_api_key" {
description = "API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana"
type = string
- default = ""
sensitive = true
}
diff --git a/examples/existing-cluster-nginx/README.md b/examples/existing-cluster-nginx/README.md
index 3618d30..037a84b 100644
--- a/examples/existing-cluster-nginx/README.md
+++ b/examples/existing-cluster-nginx/README.md
@@ -1,16 +1,16 @@
-# Existing Cluster with the AWS Observability accelerator base module and Nginx monitoring
-
+# Monitor NGINX applications running on Amazon EKS
This example demonstrates how to use the AWS Observability Accelerator Terraform
-modules with Nginx monitoring enabled.
-The current example deploys the [AWS Distro for OpenTelemetry Operator](https://docs.aws.amazon.com/eks/latest/userguide/opentelemetry.html) for Amazon EKS with its requirements and make use of existing
-Amazon Managed Service for Prometheus and Amazon Managed Grafana workspaces.
+modules to monitor EKS infrastructure and NGINX workloads.
+The current example deploys the [AWS Distro for OpenTelemetry Operator](https://docs.aws.amazon.com/eks/latest/userguide/opentelemetry.html)
+for Amazon EKS with its requirements and make use of an existing Amazon Managed Grafana workspace.
+It creates a new Amazon Managed Service for Prometheus workspace unless provided with an existing one to reuse.
-It is based on the `nginx module`, one of our [workload modules](../../modules/workloads/)
+Since v2.x releases, it uses the `EKS monitoring` [module](../../modules/eks-monitoring/)
to provide an existing EKS cluster with an OpenTelemetry collector,
curated Grafana dashboards, Prometheus alerting and recording rules with multiple
configuration options on the cluster infrastructure.
-
+You will gain both visibility on the cluster and NGINX based applications.
## Prerequisites
@@ -39,11 +39,7 @@ cd examples/existing-cluster-nginx
terraform init
```
-3. AWS Region
-
-Specify the AWS Region where the resources will be deployed. Edit the `terraform.tfvars` file and modify `aws_region="..."`. You can also use environement variables `export TF_VAR_aws_region=xxx`.
-
-4. Amazon EKS Cluster
+3. Amazon EKS Cluster
To run this example, you need to provide your EKS cluster name.
If you don't have a cluster ready, visit [this example](https://github.com/aws-ia/terraform-aws-eks-blueprints/tree/v4.13.1/examples/eks-cluster-with-new-vpc)
@@ -51,30 +47,23 @@ first to create a new one.
Add your cluster name for `eks_cluster_id="..."` to the `terraform.tfvars` or use an environment variable `export TF_VAR_eks_cluster_id=xxx`.
-5. Amazon Managed Service for Prometheus workspace (optional)
+4. Amazon Managed Grafana workspace
-If you have an existing workspace, add `managed_prometheus_workspace_id=ws-xxx`
-or use an environment variable `export TF_VAR_managed_prometheus_workspace_id=ws-xxx`.
+To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, create an environment variable `export TF_VAR_managed_grafana_workspace_id=g-xxx`.
+To create a new one, visit our Amazon Managed Grafana [documentation](https://docs.aws.amazon.com/grafana/latest/userguide/getting-started-with-AMG.html).
+Make sure to provide the workspace with Amazon Managed Service for Prometheus read permissions.
-If you don't specify anything a new workspace will be created for you.
+> In the URL `https://g-xyz.grafana-workspace.eu-central-1.amazonaws.com`, the workspace ID would be `g-xyz`
-6. Amazon Managed Grafana workspace
+5. Grafana API Key
-If you have an existing workspace, add `managed_grafana_workspace_id=g-xxx`
-or use an environment variable `export TF_VAR_managed_grafana_workspace_id=g-xxx`.
-
-7. Grafana API Key
-
-- Give admin access to the SSO user you set up when creating the Amazon Managed Grafana Workspace:
-- In the AWS Console, navigate to Amazon Grafana. In the left navigation bar, click **All workspaces**, then click on the workspace name you are using for this example.
-- Under **Authentication** within **AWS Single Sign-On (SSO)**, click **Configure users and user groups**
-- Check the box next to the SSO user you created and click **Make admin**
-- From the workspace in the AWS console, click on the `Grafana workspace URL` to open the workspace
-- If you don't see the gear icon in the left navigation bar, log out and log back in.
-- Click on the gear icon, then click on the **API keys** tab.
-- Click **Add API key**, fill in the _Key name_ field and select _Admin_ as the Role.
-- Copy your API key into `terraform.tfvars` under the `grafana_api_key` variable (`grafana_api_key="xxx"`) or set as an environment variable on your CLI (`export TF_VAR_grafana_api_key="xxx"`)
+Amazon Managed Service for Grafana provides a control plane API for generating Grafana API keys. We will provide to Terraform
+a short lived API key to run the `apply` or `destroy` command.
+Ensure you have necessary IAM permissions (`CreateWorkspaceApiKey, DeleteWorkspaceApiKey`)
+```sh
+export TF_VAR_grafana_api_key=`aws grafana create-workspace-api-key --key-name "observability-accelerator-$(date +%s)" --key-role ADMIN --seconds-to-live 1200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`
+```
## Deploy
@@ -88,11 +77,31 @@ or if you had setup environment variables, run
terraform apply
```
+## Additional configuration
+
+For the purpose of the example, we have provided default values for some of the variables.
+
+1. AWS Region
+
+Specify the AWS Region where the resources will be deployed. Edit the `terraform.tfvars` file and modify `aws_region="..."`. You can also use environement variables `export TF_VAR_aws_region=xxx`.
+
+
+2. Amazon Managed Service for Prometheus workspace
+
+If you have an existing workspace, add `managed_prometheus_workspace_id=ws-xxx`
+or use an environment variable `export TF_VAR_managed_prometheus_workspace_id=ws-xxx`.
+
## Visualization
1. Prometheus datasource on Grafana
-Open your Grafana workspace and under Configuration -> Data sources, you should see `aws-observability-accelerator`. Open and click `Save & test`. You should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+Make sure to open the link in the output. After a successful deployment, this will open
+the Prometheus datasource configuration on Grafana.
+Click `Save & test` and you should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+
+```bash
+terraform output grafana_prometheus_datasource_test
+```
2. Grafana dashboards
@@ -113,7 +122,7 @@ Open the Amazon Managed Service for Prometheus console and view the details of y
To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
-## Deploy an Example Application to Visualize
+## Deploy an example application to visualize metrics
In this section we will deploy sample application and extract metrics using AWS OpenTelemetry collector
@@ -161,7 +170,7 @@ kubectl apply -f -
kubectl get pods -n nginx-ingress-sample
```
-#### Visualize the Application's dashboard
+#### Visualize the application's dashboard
Log back into your Managed Grafana Workspace and navigate to the dashboard side panel, click on `Observability Accelerator Dashboards` Folder and open the `NGINX` Dashboard.
@@ -208,8 +217,8 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws
| Name | Source | Version |
|------|--------|---------|
-| [eks\_observability\_accelerator](#module\_eks\_observability\_accelerator) | ../../ | n/a |
-| [workloads\_nginx](#module\_workloads\_nginx) | ../../modules/workloads/nginx | n/a |
+| [aws\_observability\_accelerator](#module\_aws\_observability\_accelerator) | ../../ | n/a |
+| [eks\_monitoring](#module\_eks\_monitoring) | ../../modules/eks-monitoring | n/a |
## Resources
@@ -224,8 +233,8 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws
|------|-------------|------|---------|:--------:|
| [aws\_region](#input\_aws\_region) | AWS Region | `string` | n/a | yes |
| [eks\_cluster\_id](#input\_eks\_cluster\_id) | EKS Cluster Id | `string` | n/a | yes |
-| [grafana\_api\_key](#input\_grafana\_api\_key) | API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana | `string` | `""` | no |
-| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana (AMG) workspace ID | `string` | `""` | no |
+| [grafana\_api\_key](#input\_grafana\_api\_key) | API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana | `string` | n/a | yes |
+| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana (AMG) workspace ID | `string` | n/a | yes |
| [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Service for Prometheus (AMP) workspace ID | `string` | `""` | no |
## Outputs
@@ -236,6 +245,7 @@ add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [grafana\_dashboard\_urls](#output\_grafana\_dashboard\_urls) | URLs for dashboards created |
+| [grafana\_prometheus\_datasource\_test](#output\_grafana\_prometheus\_datasource\_test) | Grafana save & test URL for Amazon Managed Prometheus workspace |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
diff --git a/examples/existing-cluster-nginx/main.tf b/examples/existing-cluster-nginx/main.tf
index 9e9eebb..fa4f844 100644
--- a/examples/existing-cluster-nginx/main.tf
+++ b/examples/existing-cluster-nginx/main.tf
@@ -25,8 +25,7 @@ provider "helm" {
}
locals {
- region = var.aws_region
-
+ region = var.aws_region
eks_cluster_endpoint = data.aws_eks_cluster.this.endpoint
create_new_workspace = var.managed_prometheus_workspace_id == "" ? true : false
@@ -35,28 +34,17 @@ locals {
}
}
-module "eks_observability_accelerator" {
- # source = "aws-observability/terrarom-aws-observability-accelerator"
+module "aws_observability_accelerator" {
source = "../../"
+ # source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v2.0.0"
- aws_region = var.aws_region
- eks_cluster_id = var.eks_cluster_id
-
- # deploys AWS Distro for OpenTelemetry operator into the cluster
- enable_amazon_eks_adot = true
-
- # reusing existing certificate manager? defaults to true
- enable_cert_manager = true
+ aws_region = var.aws_region
# creates a new AMP workspace, defaults to true
enable_managed_prometheus = local.create_new_workspace
# reusing existing AMP if specified
- managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
- managed_prometheus_workspace_region = null # defaults to the current region, useful for cross region scenarios (same account)
-
- # sets up the AMP alert manager at the workspace level
- enable_alertmanager = true
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
# reusing existing Amazon Managed Grafana workspace
enable_managed_grafana = false
@@ -67,24 +55,28 @@ module "eks_observability_accelerator" {
}
provider "grafana" {
- url = module.eks_observability_accelerator.managed_grafana_workspace_endpoint
+ url = module.aws_observability_accelerator.managed_grafana_workspace_endpoint
auth = var.grafana_api_key
}
-module "workloads_nginx" {
- source = "../../modules/workloads/nginx"
+module "eks_monitoring" {
+ source = "../../modules/eks-monitoring"
+ # source = "github.com/aws-observability/terraform-aws-observability-accelerator//modules/eks-monitoring?ref=v2.0.0"
- eks_cluster_id = module.eks_observability_accelerator.eks_cluster_id
+ # enable NGINX metrics collection, dashboards and alerts rules creation
+ enable_nginx = true
- dashboards_folder_id = module.eks_observability_accelerator.grafana_dashboards_folder_id
- managed_prometheus_workspace_id = module.eks_observability_accelerator.managed_prometheus_workspace_id
+ eks_cluster_id = var.eks_cluster_id
- managed_prometheus_workspace_endpoint = module.eks_observability_accelerator.managed_prometheus_workspace_endpoint
- managed_prometheus_workspace_region = module.eks_observability_accelerator.managed_prometheus_workspace_region
+ dashboards_folder_id = module.aws_observability_accelerator.grafana_dashboards_folder_id
+ managed_prometheus_workspace_id = module.aws_observability_accelerator.managed_prometheus_workspace_id
+
+ managed_prometheus_workspace_endpoint = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
+ managed_prometheus_workspace_region = module.aws_observability_accelerator.managed_prometheus_workspace_region
tags = local.tags
depends_on = [
- module.eks_observability_accelerator
+ module.aws_observability_accelerator
]
}
diff --git a/examples/existing-cluster-nginx/outputs.tf b/examples/existing-cluster-nginx/outputs.tf
index ec4cd48..586cffd 100644
--- a/examples/existing-cluster-nginx/outputs.tf
+++ b/examples/existing-cluster-nginx/outputs.tf
@@ -1,29 +1,34 @@
-output "eks_cluster_id" {
- description = "EKS Cluster Id"
- value = module.eks_observability_accelerator.eks_cluster_id
-}
-
output "aws_region" {
description = "AWS Region"
- value = module.eks_observability_accelerator.aws_region
-}
-
-output "eks_cluster_version" {
- description = "EKS Cluster version"
- value = module.eks_observability_accelerator.eks_cluster_version
+ value = module.aws_observability_accelerator.aws_region
}
output "managed_prometheus_workspace_endpoint" {
description = "Amazon Managed Prometheus workspace endpoint"
- value = module.eks_observability_accelerator.managed_prometheus_workspace_endpoint
+ value = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
}
output "managed_prometheus_workspace_id" {
description = "Amazon Managed Prometheus workspace ID"
- value = module.eks_observability_accelerator.managed_prometheus_workspace_id
+ value = module.aws_observability_accelerator.managed_prometheus_workspace_id
}
output "grafana_dashboard_urls" {
description = "URLs for dashboards created"
- value = module.workloads_nginx.grafana_dashboard_urls
+ value = module.eks_monitoring.grafana_dashboard_urls
+}
+
+output "grafana_prometheus_datasource_test" {
+ description = "Grafana save & test URL for Amazon Managed Prometheus workspace"
+ value = module.aws_observability_accelerator.grafana_prometheus_datasource_test
+}
+
+output "eks_cluster_version" {
+ description = "EKS Cluster version"
+ value = module.eks_monitoring.eks_cluster_version
+}
+
+output "eks_cluster_id" {
+ description = "EKS Cluster Id"
+ value = module.eks_monitoring.eks_cluster_id
}
diff --git a/examples/existing-cluster-nginx/variables.tf b/examples/existing-cluster-nginx/variables.tf
index 284d486..f49bfd8 100644
--- a/examples/existing-cluster-nginx/variables.tf
+++ b/examples/existing-cluster-nginx/variables.tf
@@ -14,11 +14,9 @@ variable "managed_prometheus_workspace_id" {
variable "managed_grafana_workspace_id" {
description = "Amazon Managed Grafana (AMG) workspace ID"
type = string
- default = ""
}
variable "grafana_api_key" {
description = "API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana"
type = string
- default = ""
sensitive = true
}
diff --git a/examples/existing-cluster-with-base-and-infra/README.md b/examples/existing-cluster-with-base-and-infra/README.md
index 3268d55..2fcda38 100644
--- a/examples/existing-cluster-with-base-and-infra/README.md
+++ b/examples/existing-cluster-with-base-and-infra/README.md
@@ -1,17 +1,16 @@
# Existing Cluster with the AWS Observability accelerator base module and Infrastructure monitoring
-
This example demonstrates how to use the AWS Observability Accelerator Terraform
modules with Infrastructure monitoring enabled.
-The current example deploys the [AWS Distro for OpenTelemetry Operator](https://docs.aws.amazon.com/eks/latest/userguide/opentelemetry.html) for Amazon EKS with its requirements and make use of existing
-Amazon Managed Service for Prometheus and Amazon Managed Grafana workspaces.
+The current example deploys the [AWS Distro for OpenTelemetry Operator](https://docs.aws.amazon.com/eks/latest/userguide/opentelemetry.html)
+for Amazon EKS with its requirements and make use of an existing Amazon Managed Grafana workspace.
+It creates a new Amazon Managed Service for Prometheus workspace unless provided with an existing one to reuse.
-It is based on the `infrastructure monitoring`, one of our [workloads modules](../../modules/workloads/)
+It uses the `EKS monitoring` [module](../../modules/eks-monitoring/)
to provide an existing EKS cluster with an OpenTelemetry collector,
curated Grafana dashboards, Prometheus alerting and recording rules with multiple
configuration options on the cluster infrastructure.
-
## Prerequisites
Ensure that you have the following tools installed locally:
@@ -20,7 +19,6 @@ Ensure that you have the following tools installed locally:
2. [kubectl](https://kubernetes.io/docs/tasks/tools/)
3. [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli)
-
## Setup
This example uses a local terraform state. If you need states to be saved remotely,
@@ -39,11 +37,7 @@ cd examples/existing-cluster-with-base-and-infra
terraform init
```
-3. AWS Region
-
-Specify the AWS Region where the resources will be deployed. Edit the `terraform.tfvars` file and modify `aws_region="..."`. You can also use environement variables `export TF_VAR_aws_region=xxx`.
-
-4. Amazon EKS Cluster
+3. Amazon EKS Cluster
To run this example, you need to provide your EKS cluster name.
If you don't have a cluster ready, visit [this example](../eks-cluster-with-vpc)
@@ -51,24 +45,15 @@ first to create a new one.
Add your cluster name for `eks_cluster_id="..."` to the `terraform.tfvars` or use an environment variable `export TF_VAR_eks_cluster_id=xxx`.
-5. Amazon Managed Service for Prometheus workspace (optional)
-
-If you have an existing workspace, add `managed_prometheus_workspace_id=ws-xxx`
-or use an environment variable `export TF_VAR_managed_prometheus_workspace_id=ws-xxx`.
-
-If you don't specify anything a new workspace will be created for you.
-
-6. Amazon Managed Grafana workspace
+4. Amazon Managed Grafana workspace
To run this example you need an Amazon Managed Grafana workspace. If you have an existing workspace, create an environment variable `export TF_VAR_managed_grafana_workspace_id=g-xxx`.
+To create a new one, visit our Amazon Managed Grafana [documentation](https://docs.aws.amazon.com/grafana/latest/userguide/getting-started-with-AMG.html).
+Make sure to provide the workspace with Amazon Managed Service for Prometheus read permissions.
-To create a new one, within this example's Terraform state (sharing the same lifecycle with all the other resources):
+> In the URL `https://g-xyz.grafana-workspace.eu-central-1.amazonaws.com`, the workspace ID would be `g-xyz`
-- Edit main.tf and set `enable_managed_grafana = true`
-- Run `terraform apply -target "module.eks_observability_accelerator.module.managed_grafana[0].aws_grafana_workspace.this[0]"`.
-- Run `export TF_VAR_managed_grafana_workspace_id=$(terraform output --raw managed_grafana_workspace_id)`.
-
-7. Grafana API Key
+5. Grafana API Key
Amazon Managed Service for Grafana provides a control plane API for generating Grafana API keys. We will provide to Terraform
a short lived API key to run the `apply` or `destroy` command.
@@ -90,11 +75,31 @@ or if you had only setup environment variables, run
terraform apply
```
+## Additional configuration
+
+For the purpose of the example, we have provided default values for some of the variables.
+
+1. AWS Region
+
+Specify the AWS Region where the resources will be deployed. Edit the `terraform.tfvars` file and modify `aws_region="..."`. You can also use environement variables `export TF_VAR_aws_region=xxx`.
+
+
+2. Amazon Managed Service for Prometheus workspace
+
+If you have an existing workspace, add `managed_prometheus_workspace_id=ws-xxx`
+or use an environment variable `export TF_VAR_managed_prometheus_workspace_id=ws-xxx`.
+
## Visualization
1. Prometheus datasource on Grafana
-Open your Grafana workspace and under Configuration -> Data sources, you should see `aws-observability-accelerator`. Open and click `Save & test`. You should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+Make sure to open the link in the output. After a successful deployment, this will open
+the Prometheus datasource configuration on Grafana.
+Click `Save & test` and you should see a notification confirming that the Amazon Managed Service for Prometheus workspace is ready to be used on Grafana.
+
+```bash
+terraform output grafana_prometheus_datasource_test
+```
2. Grafana dashboards
@@ -115,17 +120,6 @@ Open the Amazon Managed Service for Prometheus console and view the details of y
To setup your alert receiver, with Amazon SNS, follow [this documentation](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-alertmanager-receiver.html)
-## Advanced configuration
-
-1. Cross-region Amazon Managed Prometheus workspace
-
-If your existing Amazon Managed Prometheus workspace is in another AWS Region,
-add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws-xxx`.
-
-2. Cross-region Amazon Managed Grafana workspace
-
-If your existing Amazon Managed Prometheus workspace is in another AWS Region,
-add this `managed_prometheus_region=xxx` and `managed_prometheus_workspace_id=ws-xxx`.
## Destroy resources
@@ -159,8 +153,8 @@ terraform destroy -var-file=terraform.tfvars
| Name | Source | Version |
|------|--------|---------|
-| [eks\_observability\_accelerator](#module\_eks\_observability\_accelerator) | ../../ | n/a |
-| [workloads\_infra](#module\_workloads\_infra) | ../../modules/workloads/infra | n/a |
+| [aws\_observability\_accelerator](#module\_aws\_observability\_accelerator) | ../../ | n/a |
+| [eks\_monitoring](#module\_eks\_monitoring) | ../../modules/eks-monitoring | n/a |
## Resources
@@ -175,8 +169,8 @@ terraform destroy -var-file=terraform.tfvars
|------|-------------|------|---------|:--------:|
| [aws\_region](#input\_aws\_region) | AWS Region | `string` | n/a | yes |
| [eks\_cluster\_id](#input\_eks\_cluster\_id) | Name of the EKS cluster | `string` | n/a | yes |
-| [grafana\_api\_key](#input\_grafana\_api\_key) | API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana | `string` | `""` | no |
-| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana Workspace ID | `string` | `""` | no |
+| [grafana\_api\_key](#input\_grafana\_api\_key) | API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana | `string` | n/a | yes |
+| [managed\_grafana\_workspace\_id](#input\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana Workspace ID | `string` | n/a | yes |
| [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Service for Prometheus Workspace ID | `string` | `""` | no |
## Outputs
@@ -187,6 +181,7 @@ terraform destroy -var-file=terraform.tfvars
| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [grafana\_dashboard\_urls](#output\_grafana\_dashboard\_urls) | URLs for dashboards created |
+| [grafana\_prometheus\_datasource\_test](#output\_grafana\_prometheus\_datasource\_test) | Grafana save & test URL for Amazon Managed Prometheus workspace |
| [managed\_grafana\_workspace\_id](#output\_managed\_grafana\_workspace\_id) | Amazon Managed Grafana workspace ID |
| [managed\_prometheus\_workspace\_endpoint](#output\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus workspace endpoint |
| [managed\_prometheus\_workspace\_id](#output\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus workspace ID |
diff --git a/examples/existing-cluster-with-base-and-infra/main.tf b/examples/existing-cluster-with-base-and-infra/main.tf
index 42512b5..523c9c6 100644
--- a/examples/existing-cluster-with-base-and-infra/main.tf
+++ b/examples/existing-cluster-with-base-and-infra/main.tf
@@ -34,25 +34,17 @@ locals {
}
# deploys the base module
-module "eks_observability_accelerator" {
- # source = "aws-observability/terrarom-aws-observability-accelerator"
+module "aws_observability_accelerator" {
source = "../../"
+ # source = "github.com/aws-observability/terraform-aws-observability-accelerator?ref=v2.0.0"
- aws_region = var.aws_region
- eks_cluster_id = var.eks_cluster_id
-
- # deploys AWS Distro for OpenTelemetry operator into the cluster
- enable_amazon_eks_adot = true
-
- # reusing existing certificate manager? defaults to true
- enable_cert_manager = true
+ aws_region = var.aws_region
# creates a new Amazon Managed Prometheus workspace, defaults to true
enable_managed_prometheus = local.create_new_workspace
# reusing existing Amazon Managed Prometheus if specified
- managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
- managed_prometheus_workspace_region = null # defaults to the current region, useful for cross region scenarios (same account)
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
# sets up the Amazon Managed Prometheus alert manager at the workspace level
enable_alertmanager = true
@@ -70,20 +62,27 @@ module "eks_observability_accelerator" {
# any provider blocks.
# This allows forcing dependency between base and workloads module
provider "grafana" {
- url = module.eks_observability_accelerator.managed_grafana_workspace_endpoint
+ url = module.aws_observability_accelerator.managed_grafana_workspace_endpoint
auth = var.grafana_api_key
}
-module "workloads_infra" {
- source = "../../modules/workloads/infra"
+module "eks_monitoring" {
+ source = "../../modules/eks-monitoring"
+ # source = "github.com/aws-observability/terraform-aws-observability-accelerator//modules/eks-monitoring?ref=v2.0.0"
- eks_cluster_id = module.eks_observability_accelerator.eks_cluster_id
+ eks_cluster_id = var.eks_cluster_id
- dashboards_folder_id = module.eks_observability_accelerator.grafana_dashboards_folder_id
- managed_prometheus_workspace_id = module.eks_observability_accelerator.managed_prometheus_workspace_id
+ # deploys AWS Distro for OpenTelemetry operator into the cluster
+ enable_amazon_eks_adot = true
- managed_prometheus_workspace_endpoint = module.eks_observability_accelerator.managed_prometheus_workspace_endpoint
- managed_prometheus_workspace_region = module.eks_observability_accelerator.managed_prometheus_workspace_region
+ # reusing existing certificate manager? defaults to true
+ enable_cert_manager = true
+
+ dashboards_folder_id = module.aws_observability_accelerator.grafana_dashboards_folder_id
+ managed_prometheus_workspace_id = module.aws_observability_accelerator.managed_prometheus_workspace_id
+
+ managed_prometheus_workspace_endpoint = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
+ managed_prometheus_workspace_region = module.aws_observability_accelerator.managed_prometheus_workspace_region
# optional, defaults to 60s interval and 15s timeout
prometheus_config = {
@@ -94,6 +93,6 @@ module "workloads_infra" {
tags = local.tags
depends_on = [
- module.eks_observability_accelerator
+ module.aws_observability_accelerator
]
}
diff --git a/examples/existing-cluster-with-base-and-infra/outputs.tf b/examples/existing-cluster-with-base-and-infra/outputs.tf
index a70260d..b05adf7 100644
--- a/examples/existing-cluster-with-base-and-infra/outputs.tf
+++ b/examples/existing-cluster-with-base-and-infra/outputs.tf
@@ -1,34 +1,38 @@
-output "eks_cluster_id" {
- description = "EKS Cluster Id"
- value = module.eks_observability_accelerator.eks_cluster_id
-}
-
output "aws_region" {
description = "AWS Region"
- value = module.eks_observability_accelerator.aws_region
-}
-
-output "eks_cluster_version" {
- description = "EKS Cluster version"
- value = module.eks_observability_accelerator.eks_cluster_version
+ value = module.aws_observability_accelerator.aws_region
}
output "managed_prometheus_workspace_endpoint" {
description = "Amazon Managed Prometheus workspace endpoint"
- value = module.eks_observability_accelerator.managed_prometheus_workspace_endpoint
+ value = module.aws_observability_accelerator.managed_prometheus_workspace_endpoint
}
output "managed_prometheus_workspace_id" {
description = "Amazon Managed Prometheus workspace ID"
- value = module.eks_observability_accelerator.managed_prometheus_workspace_id
+ value = module.aws_observability_accelerator.managed_prometheus_workspace_id
}
output "managed_grafana_workspace_id" {
description = "Amazon Managed Grafana workspace ID"
- value = module.eks_observability_accelerator.managed_grafana_workspace_id
+ value = module.aws_observability_accelerator.managed_grafana_workspace_id
}
output "grafana_dashboard_urls" {
description = "URLs for dashboards created"
- value = module.workloads_infra.grafana_dashboard_urls
+ value = module.eks_monitoring.grafana_dashboard_urls
+}
+
+output "grafana_prometheus_datasource_test" {
+ description = "Grafana save & test URL for Amazon Managed Prometheus workspace"
+ value = module.aws_observability_accelerator.grafana_prometheus_datasource_test
+}
+output "eks_cluster_version" {
+ description = "EKS Cluster version"
+ value = module.eks_monitoring.eks_cluster_version
+}
+
+output "eks_cluster_id" {
+ description = "EKS Cluster Id"
+ value = module.eks_monitoring.eks_cluster_id
}
diff --git a/examples/existing-cluster-with-base-and-infra/terraform.tfvars b/examples/existing-cluster-with-base-and-infra/terraform.tfvars
index c592f28..0ef303f 100644
--- a/examples/existing-cluster-with-base-and-infra/terraform.tfvars
+++ b/examples/existing-cluster-with-base-and-infra/terraform.tfvars
@@ -1,8 +1,8 @@
# (mandatory) AWS Region where your resources will be located
-aws_region = ""
+aws_region = "eu-central-1"
# (mandatory) EKS Cluster name
-eks_cluster_id = ""
+eks_cluster_id = "eks-cluster-with-vpc"
# (optional) Leave it empty for a new workspace to be created
managed_prometheus_workspace_id = ""
diff --git a/examples/existing-cluster-with-base-and-infra/variables.tf b/examples/existing-cluster-with-base-and-infra/variables.tf
index 74d795f..73aa65d 100644
--- a/examples/existing-cluster-with-base-and-infra/variables.tf
+++ b/examples/existing-cluster-with-base-and-infra/variables.tf
@@ -14,11 +14,9 @@ variable "managed_prometheus_workspace_id" {
variable "managed_grafana_workspace_id" {
description = "Amazon Managed Grafana Workspace ID"
type = string
- default = ""
}
variable "grafana_api_key" {
description = "API key for authorizing the Grafana provider to make changes to Amazon Managed Grafana"
type = string
- default = ""
sensitive = true
}
diff --git a/examples/managed-prometheus-monitoring/main.tf b/examples/managed-prometheus-monitoring/main.tf
index ee246ef..de7598d 100644
--- a/examples/managed-prometheus-monitoring/main.tf
+++ b/examples/managed-prometheus-monitoring/main.tf
@@ -22,7 +22,7 @@ resource "grafana_folder" "this" {
}
module "managed_prometheus_monitoring" {
- source = "../../modules/workloads/managed-prometheus-monitoring"
+ source = "../../modules/managed-prometheus-monitoring"
dashboards_folder_id = resource.grafana_folder.this.id
aws_region = local.region
managed_prometheus_workspace_ids = var.managed_prometheus_workspace_ids
diff --git a/locals.tf b/locals.tf
index 02cbc2b..017301e 100644
--- a/locals.tf
+++ b/locals.tf
@@ -1,23 +1,11 @@
-data "aws_partition" "current" {}
-
-data "aws_caller_identity" "current" {}
-
data "aws_region" "current" {}
-data "aws_eks_cluster" "eks_cluster" {
- name = var.eks_cluster_id
-}
-
data "aws_grafana_workspace" "this" {
count = var.managed_grafana_workspace_id == "" ? 0 : 1
workspace_id = var.managed_grafana_workspace_id
}
locals {
- eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "")
- eks_cluster_endpoint = data.aws_eks_cluster.eks_cluster.endpoint
- eks_cluster_version = data.aws_eks_cluster.eks_cluster.version
-
# if region is not passed, we assume the current one
amp_ws_region = coalesce(var.managed_prometheus_workspace_region, data.aws_region.current.name)
amp_ws_id = var.enable_managed_prometheus ? aws_prometheus_workspace.this[0].id : var.managed_prometheus_workspace_id
@@ -28,19 +16,5 @@ locals {
amg_ws_endpoint = var.managed_grafana_workspace_id == "" ? "https://${module.managed_grafana[0].workspace_endpoint}" : "https://${data.aws_grafana_workspace.this[0].endpoint}"
amg_ws_id = var.managed_grafana_workspace_id == "" ? split(".", module.managed_grafana[0].workspace_endpoint)[0] : var.managed_grafana_workspace_id
- context = {
- aws_caller_identity_account_id = data.aws_caller_identity.current.account_id
- aws_caller_identity_arn = data.aws_caller_identity.current.arn
- aws_eks_cluster_endpoint = local.eks_cluster_endpoint
- aws_partition_id = data.aws_partition.current.partition
- aws_region_name = data.aws_region.current.name
- eks_cluster_id = var.eks_cluster_id
- eks_oidc_issuer_url = local.eks_oidc_issuer_url
- eks_oidc_provider_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.eks_oidc_issuer_url}"
- tags = var.tags
- irsa_iam_role_path = var.irsa_iam_role_path
- irsa_iam_permissions_boundary = var.irsa_iam_permissions_boundary
- }
-
name = "aws-observability-accelerator"
}
diff --git a/main.tf b/main.tf
index 33b5664..2042a4c 100644
--- a/main.tf
+++ b/main.tf
@@ -1,12 +1,3 @@
-module "operator" {
- source = "./modules/add-ons/adot-operator"
- count = var.enable_amazon_eks_adot ? 1 : 0
-
- enable_cert_manager = var.enable_cert_manager
- kubernetes_version = local.eks_cluster_version
- addon_context = local.context
-}
-
resource "aws_prometheus_workspace" "this" {
count = var.enable_managed_prometheus ? 1 : 0
diff --git a/mkdocs.yml b/mkdocs.yml
index 2132306..8efe42d 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -27,14 +27,14 @@ nav:
- Concepts: concepts.md
- Amazon EKS:
- Infrastructure monitoring: eks/index.md
+ - Java/JMX: eks/java.md
+ - Nginx: eks/nginx.md
- Teardown: eks/destroy.md
- - Workload Monitoring:
- - Java/JMX: workloads/java.md
- - Nginx: workloads/nginx.md
- - Amazon Managed Service for Prometheus Workspaces: workloads/managed-prometheus.md
+ - Monitoring Managed Service for Prometheus Workspaces: workloads/managed-prometheus.md
- Supporting Examples:
- EKS Cluster with VPC: helpers/new-eks-cluster.md
# - Amazon Managed Grafana setup: helpers/managed-grafana.md
+ - Support & feedback: support.md
- Contributors: contributors.md
markdown_extensions:
diff --git a/modules/workloads/infra/README.md b/modules/eks-monitoring/README.md
similarity index 83%
rename from modules/workloads/infra/README.md
rename to modules/eks-monitoring/README.md
index 09e5fa5..899e9b3 100644
--- a/modules/workloads/infra/README.md
+++ b/modules/eks-monitoring/README.md
@@ -33,6 +33,9 @@ This module is inspired from the open source [kube-prometheus-stack](https://git
| Name | Source | Version |
|------|--------|---------|
| [helm\_addon](#module\_helm\_addon) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon | v4.13.1 |
+| [java\_monitoring](#module\_java\_monitoring) | ./patterns/java | n/a |
+| [nginx\_monitoring](#module\_nginx\_monitoring) | ./patterns/nginx | n/a |
+| [operator](#module\_operator) | ./add-ons/adot-operator | n/a |
## Resources
@@ -61,20 +64,25 @@ This module is inspired from the open source [kube-prometheus-stack](https://git
| [dashboards\_folder\_id](#input\_dashboards\_folder\_id) | Grafana folder ID for automatic dashboards | `string` | n/a | yes |
| [eks\_cluster\_id](#input\_eks\_cluster\_id) | EKS Cluster Id | `string` | n/a | yes |
| [enable\_alerting\_rules](#input\_enable\_alerting\_rules) | Enables or disables Managed Prometheus alerting rules | `bool` | `true` | no |
+| [enable\_amazon\_eks\_adot](#input\_enable\_amazon\_eks\_adot) | Enables the ADOT Operator on the EKS Cluster | `bool` | `true` | no |
+| [enable\_cert\_manager](#input\_enable\_cert\_manager) | Allow reusing an existing installation of cert-manager | `bool` | `true` | no |
| [enable\_custom\_metrics](#input\_enable\_custom\_metrics) | Allows additional metrics collection for config elements in the `custom_metrics_config` config object. Automatic dashboards are not included | `bool` | `false` | no |
| [enable\_dashboards](#input\_enable\_dashboards) | Enables or disables curated dashboards | `bool` | `true` | no |
+| [enable\_java](#input\_enable\_java) | Enable Java workloads monitoring, alerting and default dashboards | `bool` | `false` | no |
| [enable\_kube\_state\_metrics](#input\_enable\_kube\_state\_metrics) | Enables or disables Kube State metrics exporter. Disabling this might affect some data in the dashboards | `bool` | `true` | no |
+| [enable\_nginx](#input\_enable\_nginx) | Enable NGINX workloads monitoring, alerting and default dashboards | `bool` | `false` | no |
| [enable\_node\_exporter](#input\_enable\_node\_exporter) | Enables or disables Node exporter. Disabling this might affect some data in the dashboards | `bool` | `true` | no |
-| [enable\_recording\_rules](#input\_enable\_recording\_rules) | Enables or disables Managed Prometheus recording rules. Disabling this might affect some data in the dashboards | `bool` | `true` | no |
| [enable\_tracing](#input\_enable\_tracing) | (Experimental) Enables tracing with AWS X-Ray. This changes the deploy mode of the collector to daemon set. Requirement: adot add-on <= 0.58-build.0 | `bool` | `false` | no |
| [helm\_config](#input\_helm\_config) | Helm Config for Prometheus | `any` | `{}` | no |
| [irsa\_iam\_permissions\_boundary](#input\_irsa\_iam\_permissions\_boundary) | IAM permissions boundary for IRSA roles | `string` | `null` | no |
| [irsa\_iam\_role\_path](#input\_irsa\_iam\_role\_path) | IAM role path for IRSA roles | `string` | `"/"` | no |
+| [java\_config](#input\_java\_config) | Configuration object for Java/JMX monitoring |
object({
enable_alerting_rules = bool
scrape_sample_limit = number
}) | {
"enable_alerting_rules": true,
"scrape_sample_limit": 1000
} | no |
| [ksm\_config](#input\_ksm\_config) | Kube State metrics configuration | object({
create_namespace = bool
k8s_namespace = string
helm_chart_name = string
helm_chart_version = string
helm_release_name = string
helm_repo_url = string
helm_settings = map(string)
helm_values = map(any)
scrape_interval = string
scrape_timeout = string
}) | {
"create_namespace": true,
"helm_chart_name": "kube-state-metrics",
"helm_chart_version": "4.24.0",
"helm_release_name": "kube-state-metrics",
"helm_repo_url": "https://prometheus-community.github.io/helm-charts",
"helm_settings": {},
"helm_values": {},
"k8s_namespace": "kube-system",
"scrape_interval": "60s",
"scrape_timeout": "15s"
} | no |
| [managed\_prometheus\_workspace\_endpoint](#input\_managed\_prometheus\_workspace\_endpoint) | Amazon Managed Prometheus Workspace Endpoint | `string` | `""` | no |
| [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus Workspace ID | `string` | `null` | no |
| [managed\_prometheus\_workspace\_region](#input\_managed\_prometheus\_workspace\_region) | Amazon Managed Prometheus Workspace's Region | `string` | `null` | no |
| [ne\_config](#input\_ne\_config) | Node exporter configuration | object({
create_namespace = bool
k8s_namespace = string
helm_chart_name = string
helm_chart_version = string
helm_release_name = string
helm_repo_url = string
helm_settings = map(string)
helm_values = map(any)
scrape_interval = string
scrape_timeout = string
}) | {
"create_namespace": true,
"helm_chart_name": "prometheus-node-exporter",
"helm_chart_version": "2.0.3",
"helm_release_name": "prometheus-node-exporter",
"helm_repo_url": "https://prometheus-community.github.io/helm-charts",
"helm_settings": {},
"helm_values": {},
"k8s_namespace": "prometheus-node-exporter",
"scrape_interval": "60s",
"scrape_timeout": "60s"
} | no |
+| [nginx\_config](#input\_nginx\_config) | Configuration object for NGINX monitoring | object({
enable_alerting_rules = bool
scrape_sample_limit = number
prometheus_metrics_endpoint = string
}) | {
"enable_alerting_rules": true,
"prometheus_metrics_endpoint": "metrics",
"scrape_sample_limit": 1000
} | no |
| [prometheus\_config](#input\_prometheus\_config) | Controls default values such as scrape interval, timeouts and ports globally | object({
global_scrape_interval = string
global_scrape_timeout = string
}) | {
"global_scrape_interval": "60s",
"global_scrape_timeout": "15s"
} | no |
| [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | `map(string)` | `{}` | no |
| [tracing\_config](#input\_tracing\_config) | Configuration object for traces collection to AWS X-Ray | object({
otlp_grpc_endpoint = string
otlp_http_endpoint = string
send_batch_size = number
timeout = string
}) | {
"otlp_grpc_endpoint": "0.0.0.0:4317",
"otlp_http_endpoint": "0.0.0.0:4318",
"send_batch_size": 50,
"timeout": "30s"
} | no |
@@ -83,5 +91,7 @@ This module is inspired from the open source [kube-prometheus-stack](https://git
| Name | Description |
|------|-------------|
+| [eks\_cluster\_id](#output\_eks\_cluster\_id) | EKS Cluster Id |
+| [eks\_cluster\_version](#output\_eks\_cluster\_version) | EKS Cluster version |
| [grafana\_dashboard\_urls](#output\_grafana\_dashboard\_urls) | URLs for dashboards created |
diff --git a/modules/add-ons/adot-operator/README.md b/modules/eks-monitoring/add-ons/adot-operator/README.md
similarity index 100%
rename from modules/add-ons/adot-operator/README.md
rename to modules/eks-monitoring/add-ons/adot-operator/README.md
diff --git a/modules/add-ons/adot-operator/locals.tf b/modules/eks-monitoring/add-ons/adot-operator/locals.tf
similarity index 100%
rename from modules/add-ons/adot-operator/locals.tf
rename to modules/eks-monitoring/add-ons/adot-operator/locals.tf
diff --git a/modules/add-ons/adot-operator/main.tf b/modules/eks-monitoring/add-ons/adot-operator/main.tf
similarity index 100%
rename from modules/add-ons/adot-operator/main.tf
rename to modules/eks-monitoring/add-ons/adot-operator/main.tf
diff --git a/modules/add-ons/adot-operator/outputs.tf b/modules/eks-monitoring/add-ons/adot-operator/outputs.tf
similarity index 100%
rename from modules/add-ons/adot-operator/outputs.tf
rename to modules/eks-monitoring/add-ons/adot-operator/outputs.tf
diff --git a/modules/add-ons/adot-operator/variables.tf b/modules/eks-monitoring/add-ons/adot-operator/variables.tf
similarity index 100%
rename from modules/add-ons/adot-operator/variables.tf
rename to modules/eks-monitoring/add-ons/adot-operator/variables.tf
diff --git a/modules/add-ons/adot-operator/versions.tf b/modules/eks-monitoring/add-ons/adot-operator/versions.tf
similarity index 100%
rename from modules/add-ons/adot-operator/versions.tf
rename to modules/eks-monitoring/add-ons/adot-operator/versions.tf
diff --git a/modules/workloads/infra/alerts.tf b/modules/eks-monitoring/alerts.tf
similarity index 100%
rename from modules/workloads/infra/alerts.tf
rename to modules/eks-monitoring/alerts.tf
diff --git a/modules/workloads/infra/dashboards.tf b/modules/eks-monitoring/dashboards.tf
similarity index 100%
rename from modules/workloads/infra/dashboards.tf
rename to modules/eks-monitoring/dashboards.tf
diff --git a/modules/workloads/infra/dashboards/cluster.json b/modules/eks-monitoring/dashboards/cluster.json
similarity index 100%
rename from modules/workloads/infra/dashboards/cluster.json
rename to modules/eks-monitoring/dashboards/cluster.json
diff --git a/modules/workloads/infra/dashboards/kubelet.json b/modules/eks-monitoring/dashboards/kubelet.json
similarity index 100%
rename from modules/workloads/infra/dashboards/kubelet.json
rename to modules/eks-monitoring/dashboards/kubelet.json
diff --git a/modules/workloads/infra/dashboards/namespace-workloads.json b/modules/eks-monitoring/dashboards/namespace-workloads.json
similarity index 100%
rename from modules/workloads/infra/dashboards/namespace-workloads.json
rename to modules/eks-monitoring/dashboards/namespace-workloads.json
diff --git a/modules/workloads/infra/dashboards/nodeexporter-nodes.json b/modules/eks-monitoring/dashboards/nodeexporter-nodes.json
similarity index 100%
rename from modules/workloads/infra/dashboards/nodeexporter-nodes.json
rename to modules/eks-monitoring/dashboards/nodeexporter-nodes.json
diff --git a/modules/workloads/infra/dashboards/nodes.json b/modules/eks-monitoring/dashboards/nodes.json
similarity index 100%
rename from modules/workloads/infra/dashboards/nodes.json
rename to modules/eks-monitoring/dashboards/nodes.json
diff --git a/modules/workloads/infra/dashboards/workloads.json b/modules/eks-monitoring/dashboards/workloads.json
similarity index 100%
rename from modules/workloads/infra/dashboards/workloads.json
rename to modules/eks-monitoring/dashboards/workloads.json
diff --git a/modules/workloads/infra/locals.tf b/modules/eks-monitoring/locals.tf
similarity index 95%
rename from modules/workloads/infra/locals.tf
rename to modules/eks-monitoring/locals.tf
index b0bfbb3..09d196b 100644
--- a/modules/workloads/infra/locals.tf
+++ b/modules/eks-monitoring/locals.tf
@@ -14,6 +14,7 @@ locals {
eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "")
eks_cluster_endpoint = data.aws_eks_cluster.eks_cluster.endpoint
+ eks_cluster_version = data.aws_eks_cluster.eks_cluster.version
context = {
aws_caller_identity_account_id = data.aws_caller_identity.current.account_id
diff --git a/modules/workloads/infra/main.tf b/modules/eks-monitoring/main.tf
similarity index 72%
rename from modules/workloads/infra/main.tf
rename to modules/eks-monitoring/main.tf
index ff7c3eb..80d51b7 100644
--- a/modules/workloads/infra/main.tf
+++ b/modules/eks-monitoring/main.tf
@@ -1,3 +1,12 @@
+module "operator" {
+ source = "./add-ons/adot-operator"
+ count = var.enable_amazon_eks_adot ? 1 : 0
+
+ enable_cert_manager = var.enable_cert_manager
+ kubernetes_version = local.eks_cluster_version
+ addon_context = local.context
+}
+
resource "helm_release" "kube_state_metrics" {
count = var.enable_kube_state_metrics ? 1 : 0
chart = var.ksm_config.helm_chart_name
@@ -104,6 +113,26 @@ module "helm_addon" {
{
name = "customMetricsDroppedSeriesPrefixes"
value = format("(%s.*)$", join(".*|", var.custom_metrics_config.dropped_series_prefixes))
+ },
+ {
+ name = "enable_java"
+ value = var.enable_java
+ },
+ {
+ name = "javaScrapeSampleLimit"
+ value = var.java_config.scrape_sample_limit
+ },
+ {
+ name = "enable_nginx"
+ value = var.enable_nginx
+ },
+ {
+ name = "nginxScrapeSampleLimit"
+ value = var.nginx_config.scrape_sample_limit
+ },
+ {
+ name = "nginxPrometheusMetricsEndpoint"
+ value = var.nginx_config.prometheus_metrics_endpoint
}
]
@@ -119,4 +148,24 @@ module "helm_addon" {
}
addon_context = local.context
+
+ depends_on = [module.operator]
+}
+
+module "java_monitoring" {
+ source = "./patterns/java"
+ count = var.enable_java ? 1 : 0
+
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
+ enable_alerting_rules = var.java_config.enable_alerting_rules
+ dashboards_folder_id = var.dashboards_folder_id
+}
+
+module "nginx_monitoring" {
+ source = "./patterns/nginx"
+ count = var.enable_nginx ? 1 : 0
+
+ managed_prometheus_workspace_id = var.managed_prometheus_workspace_id
+ enable_alerting_rules = var.nginx_config.enable_alerting_rules
+ dashboards_folder_id = var.dashboards_folder_id
}
diff --git a/modules/workloads/infra/otel-config/Chart.yaml b/modules/eks-monitoring/otel-config/Chart.yaml
similarity index 100%
rename from modules/workloads/infra/otel-config/Chart.yaml
rename to modules/eks-monitoring/otel-config/Chart.yaml
diff --git a/modules/workloads/infra/otel-config/templates/clusterrole.yaml b/modules/eks-monitoring/otel-config/templates/clusterrole.yaml
similarity index 100%
rename from modules/workloads/infra/otel-config/templates/clusterrole.yaml
rename to modules/eks-monitoring/otel-config/templates/clusterrole.yaml
diff --git a/modules/workloads/infra/otel-config/templates/clusterrolebinding.yaml b/modules/eks-monitoring/otel-config/templates/clusterrolebinding.yaml
similarity index 100%
rename from modules/workloads/infra/otel-config/templates/clusterrolebinding.yaml
rename to modules/eks-monitoring/otel-config/templates/clusterrolebinding.yaml
diff --git a/modules/workloads/infra/otel-config/templates/opentelemetrycollector.yaml b/modules/eks-monitoring/otel-config/templates/opentelemetrycollector.yaml
similarity index 96%
rename from modules/workloads/infra/otel-config/templates/opentelemetrycollector.yaml
rename to modules/eks-monitoring/otel-config/templates/opentelemetrycollector.yaml
index cd4b3bc..21f6ab4 100644
--- a/modules/workloads/infra/otel-config/templates/opentelemetrycollector.yaml
+++ b/modules/eks-monitoring/otel-config/templates/opentelemetrycollector.yaml
@@ -1703,6 +1703,72 @@ spec:
- source_labels: [ __name__ ]
regex: '{{ .Values.customMetricsDroppedSeriesPrefixes }}'
action: drop
+
+ {{ if .Values.enableJava }}
+ - job_name: 'kubernetes-java-jmx'
+ sample_limit: {{ .Values.javaScrapeSampleLimit }}
+ kubernetes_sd_configs:
+ - role: pod
+ relabel_configs:
+ - source_labels: [ __address__ ]
+ action: keep
+ regex: '.*:9404$'
+ - action: labelmap
+ regex: __meta_kubernetes_pod_label_(.+)
+ - action: replace
+ source_labels: [ __meta_kubernetes_namespace ]
+ target_label: Namespace
+ - source_labels: [ __meta_kubernetes_pod_name ]
+ action: replace
+ target_label: pod_name
+ - action: replace
+ source_labels: [ __meta_kubernetes_pod_container_name ]
+ target_label: container_name
+ - action: replace
+ source_labels: [ __meta_kubernetes_pod_controller_kind ]
+ target_label: pod_controller_kind
+ - action: replace
+ source_labels: [ __meta_kubernetes_pod_phase ]
+ target_label: pod_controller_phase
+ metric_relabel_configs:
+ - source_labels: [ __name__ ]
+ regex: 'jvm_gc_collection_seconds.*'
+ action: drop
+ {{ end }}
+
+ {{ if .Values.enableNginx }}
+ - job_name: 'kubernetes-nginx'
+ sample_limit: {{ .Values.nginxScrapeSampleLimit }}
+ metrics_path: /{{ .Values.nginxPrometheusMetricsEndpoint }}
+ kubernetes_sd_configs:
+ - role: pod
+ relabel_configs:
+ - source_labels: [ __address__ ]
+ action: keep
+ regex: '.*:10254$'
+ - source_labels: [__meta_kubernetes_pod_container_name]
+ target_label: container
+ action: replace
+ - source_labels: [__meta_kubernetes_pod_node_name]
+ target_label: host
+ action: replace
+ - source_labels: [__meta_kubernetes_namespace]
+ target_label: namespace
+ action: replace
+ metric_relabel_configs:
+ - source_labels: [__name__]
+ regex: 'go_memstats.*'
+ action: drop
+ - source_labels: [__name__]
+ regex: 'go_gc.*'
+ action: drop
+ - source_labels: [__name__]
+ regex: 'go_threads'
+ action: drop
+ - regex: exported_host
+ action: labeldrop
+ {{ end }}
+
exporters:
{{ if .Values.enableTracing }}
awsxray:
diff --git a/modules/workloads/infra/otel-config/values.yaml b/modules/eks-monitoring/otel-config/values.yaml
similarity index 69%
rename from modules/workloads/infra/otel-config/values.yaml
rename to modules/eks-monitoring/otel-config/values.yaml
index 29157c7..1bc7c5e 100644
--- a/modules/workloads/infra/otel-config/values.yaml
+++ b/modules/eks-monitoring/otel-config/values.yaml
@@ -14,3 +14,10 @@ tracingSendBatchSize: ${tracing_send_batch_size}
enableCustomMetrics: ${enable_custom_metrics}
customMetricsPorts: ${custom_metrics_ports}
customMetricsDroppedSeriesPrefixes: ${custom_metrics_dropped_series_prefixes}
+
+enableJava: ${enable_java}
+javaScrapeSampleLimit: ${java_scrape_sample_limit}
+
+enableNginx: ${enable_nginx}
+nginxScrapeSampleLimit: ${nginx_scrape_sample_limit}
+nginxPrometheusMetricsEndpoint: ${nginx_prometheus_metrics_endpoint}
diff --git a/modules/eks-monitoring/outputs.tf b/modules/eks-monitoring/outputs.tf
new file mode 100644
index 0000000..6e31d95
--- /dev/null
+++ b/modules/eks-monitoring/outputs.tf
@@ -0,0 +1,21 @@
+output "grafana_dashboard_urls" {
+ value = [concat(
+ grafana_dashboard.workloads[*].url,
+ grafana_dashboard.nodes[*].url,
+ grafana_dashboard.nsworkload[*].url,
+ grafana_dashboard.kubelet[*].url,
+ grafana_dashboard.cluster[*].url,
+ flatten(module.java_monitoring[*].grafana_dashboard_urls),
+ flatten(module.nginx_monitoring[*].grafana_dashboard_urls),
+ )]
+ description = "URLs for dashboards created"
+}
+output "eks_cluster_version" {
+ description = "EKS Cluster version"
+ value = data.aws_eks_cluster.eks_cluster.version
+}
+
+output "eks_cluster_id" {
+ description = "EKS Cluster Id"
+ value = var.eks_cluster_id
+}
diff --git a/modules/eks-monitoring/patterns/java/README.md b/modules/eks-monitoring/patterns/java/README.md
new file mode 100644
index 0000000..ce3de3a
--- /dev/null
+++ b/modules/eks-monitoring/patterns/java/README.md
@@ -0,0 +1,52 @@
+# Java patterns module
+
+Provides monitoring for Java based workloads with the following resources:
+
+- AWS Managed Grafana Dashboard and data source
+- Alerts and recording rules with AWS Managed Service for Prometheus
+
+
+## Requirements
+
+| Name | Version |
+|------|---------|
+| [terraform](#requirement\_terraform) | >= 1.1.0 |
+| [aws](#requirement\_aws) | >= 4.0.0 |
+| [grafana](#requirement\_grafana) | >= 1.25.0 |
+| [helm](#requirement\_helm) | >= 2.4.1 |
+| [kubectl](#requirement\_kubectl) | >= 1.14 |
+| [kubernetes](#requirement\_kubernetes) | >= 2.10 |
+
+## Providers
+
+| Name | Version |
+|------|---------|
+| [aws](#provider\_aws) | >= 4.0.0 |
+| [grafana](#provider\_grafana) | >= 1.25.0 |
+
+## Modules
+
+No modules.
+
+## Resources
+
+| Name | Type |
+|------|------|
+| [aws_prometheus_rule_group_namespace.alerting_rules](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_rule_group_namespace) | resource |
+| [aws_prometheus_rule_group_namespace.recording_rules](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/prometheus_rule_group_namespace) | resource |
+| [grafana_dashboard.this](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/dashboard) | resource |
+
+## Inputs
+
+| Name | Description | Type | Default | Required |
+|------|-------------|------|---------|:--------:|
+| [dashboards\_folder\_id](#input\_dashboards\_folder\_id) | Grafana folder ID for automatic dashboards | `string` | n/a | yes |
+| [enable\_alerting\_rules](#input\_enable\_alerting\_rules) | Enables or disables Managed Prometheus alerting rules | `bool` | `true` | no |
+| [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus Workspace ID | `string` | `null` | no |
+
+## Outputs
+
+| Name | Description |
+|------|-------------|
+| [grafana\_dashboard\_urls](#output\_grafana\_dashboard\_urls) | URLs for dashboards created |
+
diff --git a/modules/workloads/java/dashboards/default.json b/modules/eks-monitoring/patterns/java/dashboards/default.json
similarity index 99%
rename from modules/workloads/java/dashboards/default.json
rename to modules/eks-monitoring/patterns/java/dashboards/default.json
index b2a6131..a73897d 100644
--- a/modules/workloads/java/dashboards/default.json
+++ b/modules/eks-monitoring/patterns/java/dashboards/default.json
@@ -1837,4 +1837,4 @@
"uid": "m9mHfAy7ks",
"version": 4,
"weekStart": ""
-}
\ No newline at end of file
+}
diff --git a/modules/eks-monitoring/patterns/java/main.tf b/modules/eks-monitoring/patterns/java/main.tf
new file mode 100644
index 0000000..328ea7e
--- /dev/null
+++ b/modules/eks-monitoring/patterns/java/main.tf
@@ -0,0 +1,36 @@
+resource "aws_prometheus_rule_group_namespace" "recording_rules" {
+ name = "accelerator-java-rules"
+ workspace_id = var.managed_prometheus_workspace_id
+ data = <object({
global_scrape_interval = string
global_scrape_timeout = string
scrape_sample_limit = number
}) | {
"global_scrape_interval": "60s",
"global_scrape_timeout": "15s",
"scrape_sample_limit": 1000
} | no |
-| [tags](#input\_tags) | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | `map(string)` | `{}` | no |
-
-## Outputs
-
-| Name | Description |
-|------|-------------|
-| [grafana\_dashboard\_urls](#output\_grafana\_dashboard\_urls) | URLs for dashboards created |
-
diff --git a/modules/workloads/java/locals.tf b/modules/workloads/java/locals.tf
deleted file mode 100644
index 931a3a5..0000000
--- a/modules/workloads/java/locals.tf
+++ /dev/null
@@ -1,31 +0,0 @@
-data "aws_partition" "current" {}
-
-data "aws_caller_identity" "current" {}
-
-data "aws_region" "current" {}
-
-data "aws_eks_cluster" "eks_cluster" {
- name = var.eks_cluster_id
-}
-
-locals {
- name = "adot-collector-java"
- namespace = try(var.helm_config.namespace, local.name)
-
- eks_oidc_issuer_url = replace(data.aws_eks_cluster.eks_cluster.identity[0].oidc[0].issuer, "https://", "")
- eks_cluster_endpoint = data.aws_eks_cluster.eks_cluster.endpoint
-
- context = {
- aws_caller_identity_account_id = data.aws_caller_identity.current.account_id
- aws_caller_identity_arn = data.aws_caller_identity.current.arn
- aws_eks_cluster_endpoint = local.eks_cluster_endpoint
- aws_partition_id = data.aws_partition.current.partition
- aws_region_name = data.aws_region.current.name
- eks_cluster_id = var.eks_cluster_id
- eks_oidc_issuer_url = local.eks_oidc_issuer_url
- eks_oidc_provider_arn = "arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${local.eks_oidc_issuer_url}"
- tags = var.tags
- irsa_iam_role_path = var.irsa_iam_role_path
- irsa_iam_permissions_boundary = var.irsa_iam_permissions_boundary
- }
-}
diff --git a/modules/workloads/java/main.tf b/modules/workloads/java/main.tf
deleted file mode 100644
index 5f14027..0000000
--- a/modules/workloads/java/main.tf
+++ /dev/null
@@ -1,95 +0,0 @@
-# deploys collector
-module "helm_addon" {
- source = "github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon?ref=v4.13.1"
-
- helm_config = merge(
- {
- name = local.name
- chart = "${path.module}/otel-config"
- version = "0.2.0"
- namespace = local.namespace
- description = "ADOT helm Chart deployment configuration"
- },
- var.helm_config
- )
-
- set_values = [
- {
- name = "ampurl"
- value = "${var.managed_prometheus_workspace_endpoint}api/v1/remote_write"
- },
- {
- name = "region"
- value = var.managed_prometheus_workspace_region
- },
- {
- name = "ekscluster"
- value = local.context.eks_cluster_id
- },
- {
- name = "accountId"
- value = local.context.aws_caller_identity_account_id
- },
- {
- name = "globalScrapeInterval"
- value = var.prometheus_config.global_scrape_interval
- },
- {
- name = "globalScrapeTimeout"
- value = var.prometheus_config.global_scrape_timeout
- },
- {
- name = "scrapeSampleLimit"
- value = var.prometheus_config.scrape_sample_limit
- }
- ]
-
- irsa_config = {
- create_kubernetes_namespace = try(var.helm_config["create_namespace"], true)
- kubernetes_namespace = local.namespace
- create_kubernetes_service_account = true
- kubernetes_service_account = try(var.helm_config.service_account, local.name)
- irsa_iam_policies = ["arn:${data.aws_partition.current.partition}:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"]
- }
-
- addon_context = local.context
-}
-
-resource "aws_prometheus_rule_group_namespace" "recording_rules" {
- count = var.enable_recording_rules ? 1 : 0
-
- name = "accelerator-java-rules"
- workspace_id = var.managed_prometheus_workspace_id
- data = <