aws iam create-group --group-name Administrators
aws iam create-user --user-name Administrator
aws iam add-user-to-group --user-name Administrator --group-name Administrators
aws iam attach-group-policy --group-name Administrators --policy-arn $(aws iam list-policies --query 'Policies[?PolicyName==`AdministratorAccess`].{ARN:Arn}' --output text)
aws iam create-access-key --user-name Administrator
Collect metrics with the Micronaut framework and monitor them on Amazon Cloudwatch
Learn how to collect standard and custom metrics with the Micronaut framework and monitor them on Amazon Cloudwatch.
Authors: Burt Beckwith, Nemanja Mikic
Micronaut Version: 4.6.3
1. Getting Started
In this guide, we will create a Micronaut application written in Java.
We’ll use Micronaut Micrometer to expose application metric data with Micrometer.
2. What you will need
To complete this guide, you will need the following:
-
Some time on your hands
-
A decent text editor or IDE (e.g. IntelliJ IDEA)
-
JDK 17 or greater installed with
JAVA_HOME
configured appropriately
3. Amazon Web Services (AWS)
If you don’t have one already, create an AWS Account.
3.1. AWS CLI
Follow the AWS documentation for installing or updating the latest version of the AWS CLI.
3.2. Administrator IAM user
Instead of using your AWS root account, it is recommended that you use an IAM administrative user. If you don’t have one already, follow the steps below to create one:
Then, run aws configure
to configure your AWS CLI to use the Administrator IAM user just created.
4. The Application
Download the complete solution of the Collect Metrics with Micronaut guide. You will use the sample application as a starting point.
5. Monitor metrics on Amazon CloudWatch
To publish metrics to Amazon CloudWatch, you have to adjust your application configuration slightly, and then you will be able to create queries and monitor your metrics on Cloudwatch.
(1)
micronaut.metrics.enabled=true
(2)
micronaut.metrics.binders.files.enabled=true
micronaut.metrics.binders.jdbc.enabled=true
micronaut.metrics.binders.jvm.enabled=true
micronaut.metrics.binders.logback.enabled=true
micronaut.metrics.binders.processor.enabled=true
micronaut.metrics.binders.uptime.enabled=true
micronaut.metrics.binders.web.enabled=true
(3)
micronaut.metrics.export.cloudwatch.namespace=micronautguide
micronaut.metrics.export.cloudwatch.enabled=true
1 | Change to false to disable all metrics, e.g., per-environment |
2 | These default to true and are only here for convenience, to be able to disable a subset of metrics |
3 | Change the namespace to something meaningful, for example, the app’s name. In this guide, we are using micronautguide |
5.1. Visit the Amazon CloudWatch Metrics.
In the Metrics panel, select the namespace that you chose earlier. We select micronautguide
.
Here you can browse different metrics and explore their values. In this example, we want to check the price of Bitcoin. Select Metrics with no dimensions
.
In this panel, you can see our custom metrics about Bitcoin. Select (#2) bitcoin.price.latest.value
to see on (#1) the graph how the price of Bitcoin changed over time.
6. Next steps
Explore more features with Micronaut Guides.
Read about Amazon Cloudwatch
7. Help with the Micronaut Framework
The Micronaut Foundation sponsored the creation of this Guide. A variety of consulting and support services are available.
8. License
All guides are released with an Apache license 2.0 license for the code and a Creative Commons Attribution 4.0 license for the writing and media (images…). |