Files
terraform-aws-observability…/docs/eks/java.md
T
Rodrigue Koffi fa38a90efc Move all dashboards to GitOps (#175)
* Typo

* Remove Grafana provider

* Temp: move dashbaords to gitOps

* Move external labels to resource attributes

* Avoid DDoS with using 0.0.0.0

* Pre-commit

* Transition in two steps

Will need to remove provider in a separate version to provide a transition path as removing this will break terraform and leave orphans in the state

* Move patterns' dashboards creation to gitOps

Standardize config objects for patterns as well

* Pre-commit

* Create AMP dashboard from external source with Grafana provider

* Fix deprecated option

* Fix Flux requirements

* Run pre-commit

* Update example with operator

* Cleanup examples

* Update multicluster example

* Update multicluster example

* Drop dead variable

* Update docs

* Change GitOps branch name

* Update docs

* Replacing Secrets Manager to SSM to store Grafana API Key (#178)

* Fixing SSM

* Fixing SSM

* Replacing Secrets Manager with SSM

* Replacing Secrets Manager with SSM

* Update architecture diagram

* Update architecture diagram

* Update README.md

* Update index.md

* Fixing Grafana Operator Version

* Fix multicluster example

* Update docs

---------

Co-authored-by: Ela AWS <51791117+elamaran11@users.noreply.github.com>
Co-authored-by: Elamaran Shanmugam <elamaran.shan@gmail.com>
2023-06-12 18:00:42 +02:00

4.9 KiB

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 to allow visibility both on the cluster and the workloads, #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 configuration, simply enable the Java pattern's flag.


module "eks_monitoring" {
   ...
   enable_java = true
}

You can further customize the Java pattern by providing java_config options.

2. Grafana API key

Make sure to refresh your temporary Grafana API key

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 7200 --workspace-id $TF_VAR_managed_grafana_workspace_id --query key --output text`

Deploy

Simply run this command to deploy.

terraform apply

!!! note To see the complete Java example, open the example on the repository

Visualization

1. Grafana dashboards

Go to the Dashboards panel of your Grafana workspace. There will be a folder called Observability Accelerator Dashboards

image

Open the "Java/JMX" dashboard to view its visualization

Grafana Java dashboard

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.

image

!!! note To setup your alert receiver, with Amazon SNS, follow this documentation

Deploy an example Java application

In this section we will reuse an example from the AWS OpenTelemetry collector repository. For convenience, the steps can be found below.

1. Clone repository

git clone https://github.com/aws-observability/aws-otel-test-framework
cd aws-otel-test-framework/sample-apps/jmx/

2. Authenticate to Amazon ECR

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

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.

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

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:

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