diff --git a/gdk-oci-logging/00-introduction/introduction.md b/gdk-oci-logging/00-introduction/introduction.md new file mode 100644 index 000000000..d432f7061 --- /dev/null +++ b/gdk-oci-logging/00-introduction/introduction.md @@ -0,0 +1,61 @@ +# Introduction + +## About this Workshop + +This workshop takes you step by step through the process of configuring a Java application to send application logs to Oracle Cloud Infrastructure (OCI) Logging using the Graal Development Kit for Micronaut (GDK). You'll use GraalVM Native Image to package and run the application as a native executable. + +It is aimed at application developers and DevOps engineers with a basic knowledge of Java. + +Estimated Workshop Time: 75 minutes + +### What is Graal Development Kit for Micronaut? + +The [Graal Development Kit for Micronaut (GDK)](https://graal.cloud/gdk) is an Oracle build of the open source Micronaut® framework. The GDK provides a curated set of Micronaut framework modules that simplify cloud application development, are designed for ahead-of-time compilation with GraalVM Native Image, and are fully supported by Oracle. The GDK also provides project creation utilities, VS Code and IntelliJ extensions to simplify application development and deployment. + +### What is Micronaut? + +The [Micronaut® framework](https://micronaut.io/) is a modern, JVM-based framework to build modular, easily testable microservice and serverless applications. By avoiding runtime reflection in favor of annotation processing, Micronaut improves the Java-based development experience by detecting errors at compile time instead of runtime, and improves Java-based application startup time and memory footprint. Micronaut includes a persistence framework called Micronaut Data that precomputes your SQL queries at compilation time making it a great fit for working with databases like MySQL, Oracle Autonomous Database, etc. + +> Micronaut® is a registered trademark of Object Computing, Inc. Use is for referential purposes and does not imply any endorsement or affiliation with any third-party product. + +### What is GraalVM Native Image? + +[GraalVM Native Image](https://www.graalvm.org/) technology compiles Java applications ahead-of-time into self-contained native executables that are small in size, start almost instantaneously, provide peak performance with no warmup, and require less memory and CPU. Only the code that is required at run time by the application gets added into the executable file. Native Image is perfect for containerized workloads and microservices — which is why it has been embraced by Micronaut, Spring Boot, Helidon, and Quarkus. + +The GDK modules are designed for ahead-of-time compilation with GraalVM Native Image to produce native executables that are ideal for microservices: they have a small memory footprint, start instantly, and provide peak performance with no warmup. + +> Graal Development Kit for Micronaut, and Oracle GraalVM are available at no additional cost on Oracle Cloud Infrastructure (OCI). + +### Objectives + +In this workshop, you will: + +* Use Visual Studio Code (VS Code) from a remote desktop running in an OCI Compute Instance +* Review the application source code developed with the Graal Development Kit for Micronaut +* Configure OCI Logging: + * Create a Log Group + * Create a Custom Log +* Build a native executable for the application using GraalVM Native Image +* Run the application and send application logs to OCI Logging +* Browse the application logs using the Oracle Cloud Console + +### Prerequisites + +This workshop assumes you have: + +* Some familiarity with Oracle Cloud Infrastructure (OCI) +* Understanding of the Java programming language +* Oracle GraalVM for JDK 17 +* Visual Studio Code (VS Code) +* A browser with access to the internet +* An Oracle Cloud Infrastructure (OCI) account with adequate permissions + +## Learn More + +* [Graal Development Kit for Micronaut](https://graal.cloud/gdk/) + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/01-prepare-setup/prepare-setup.md b/gdk-oci-logging/01-prepare-setup/prepare-setup.md new file mode 100644 index 000000000..1038c0fd2 --- /dev/null +++ b/gdk-oci-logging/01-prepare-setup/prepare-setup.md @@ -0,0 +1,85 @@ +# Prepare Setup + +## Introduction + +This lab will show you how to download the Oracle Resource Manager (ORM) stack zip file needed to set up the resources needed to run this workshop. + +*Estimated Lab Time:* 5 minutes + +### Objectives + +* Download ORM stack +* (*Optional*) Configure an existing Virtual Cloud Network (VCN) +* Select a Compartment for the workshop + +### Prerequisites + +This lab assumes you have: + +* An Oracle Cloud account + +## Task 1: Download Oracle Resource Manager (ORM) stack zip file + +1. Click on the link below to download the Resource Manager zip file you need to build your environment: + + * [gdk-oci-logging-ll-orm.zip](https://c4u04.objectstorage.us-ashburn-1.oci.customer-oci.com/p/EcTjWk2IuZPZeNnD_fYMcgUhdNDIDA6rt9gaFj_WZMiL7VvxPBNMY60837hu5hga/n/c4u04/b/livelabsfiles/o/oci-library/gdk-oci-logging-ll-orm.zip) + +2. Save it in your downloads folder. + +3. (*Recommended*) We strongly recommend using this stack to create a new self-contained/dedicated VCN along with your instance. Skip to **Task 3** to follow the recommendation. + +4. Alternatively, if you would rather use an existing VCN then proceed to the next task to update your existing VCN with the required network security rules. + +## Task 2: Add Network Security Rules to an Existing VCN + +This workshop requires a certain number of ports to be available, a requirement that is automatically met by using the default ORM stack execution that creates a new dedicated VCN. + +However, if you would rather use an existing VCN/subnet, follow these steps to add the following rules to the network security list. + +1. From the Oracle Cloud Console navigation menu, go to **Networking >> Virtual Cloud Networks**. +2. Choose your network. +3. Under **Resources**, select **Security Lists**. +4. Click on **Default Security Lists** under the **Create Security List** button. +5. Click **Add Ingress Rules** button. +6. Create a rule for each row in the *Ingress* table below: + + | Stateless | Source Type | Source CIDR | IP Protocol | Source Port Range | Destination Port Range | Description | + | :------------- | :---------: | :---------: | :---------: | :---------------: | :--------------------: | :------------------------- | + | No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 80 | Remote Desktop using noVNC | + | No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 6080 | Remote Desktop using noVNC | + {: title="Network Ingress Security Rules"} + +7. Select **Egress Rule** from the left panel. +8. Click **Add Egress Rule** button +9. Create a rule for each row in the *Egress* table below: + + | Stateless | Source Type | Destination CIDR | IP Protocol | Source Port Range | Destination Port Range | Description | + | :------------- | :---------: | :--------------: | :---------: | :---------------: | :--------------------: | :-------------------- | + | No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 80 | Outbound HTTP access | + | No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 443 | Outbound HTTPS access | + {: title="Network Egress Security Rules"} + +## Task 3: Select a Compartment for the Workshop + +We recommend you use a single compartment for the workshop. We will refer to this as your workshop compartment. This is the compartment where you will provision all the resources - Oracle Resource Manager (ORM) Stack, Compute Instance, VCN/Subnet, Instance Principals, Policies - needed for the workshop. + +1. From the Oracle Cloud Console navigation menu, go to **Identity & Security >> Identity >> Compartments**. +2. Go to your workshop compartment. +3. Make a note of the compartment name and OCID. You will need this information in subsequent labs. + +## Task 4: Setup Compute + +Using the details from the above Tasks, proceed to the **Environment Setup** lab to set up your workshop environment using Oracle Resource Manager (ORM) with one of the following options: + +* (*Recommended*) Create Stack: **Compute + Networking** +* Create Stack: **Compute only** with an existing VCN where security lists have been updated as per **Task 2** above + +The ORM stack will provision a compute instance with 4 OCPUs, 64 GB RAM and a Remote Desktop environment. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/02-git-clone/git-clone.md b/gdk-oci-logging/02-git-clone/git-clone.md new file mode 100644 index 000000000..a55661866 --- /dev/null +++ b/gdk-oci-logging/02-git-clone/git-clone.md @@ -0,0 +1,54 @@ +# Clone the Sample Application Source Code + +## Introduction + +This lab describes the steps to download the sample application source code used in the workshop. + +Estimated Lab Time: 5 minutes + +### Objectives + +In this lab, you will: + +* Clone the sample application source code + +## Task 1: Clone the Sample Application Source Code + +1. From the **Activities** menu, start a new **Terminal** window. + +2. Clone the sample application source code. + + ```bash + + git init lab + cd lab + git remote add origin https://github.com/sachin-pikle/gdk-oci-samples.git + git config core.sparsecheckout true + echo "gdk-oci-logging-mvn/*">>.git/info/sparse-checkout + git pull --depth=1 origin main + + ``` + +3. Open the sample application source code from the _gdk-oci-logging-mvn_ directory in **Visual Studio Code**. + + ```bash + + code gdk-oci-logging-mvn + + ``` + +4. VS Code may show a dialog box with the message "Do you trust the authors of the files in this folder?". Select **Trust the authors of all files in the parent folder 'oracle'** and click **Yes, I trust the authors**. + +5. VS Code may ask you to choose a password for new keyring. Press **Cancel** twice to close the prompt. + +6. VS Code may show a dialog box with the message "A git repository was found in the parent folders of the workspace or the open file(s). Would you like to open the repository?". Click **Never**. + + ![VS Code Question Icon](images/vs-code-question-icon.jpg#input) + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/02-git-clone/images/vs-code-question-icon.jpg b/gdk-oci-logging/02-git-clone/images/vs-code-question-icon.jpg new file mode 100644 index 000000000..0e7299ab5 Binary files /dev/null and b/gdk-oci-logging/02-git-clone/images/vs-code-question-icon.jpg differ diff --git a/gdk-oci-logging/03-review-code/review-code.md b/gdk-oci-logging/03-review-code/review-code.md new file mode 100644 index 000000000..9287cc0cf --- /dev/null +++ b/gdk-oci-logging/03-review-code/review-code.md @@ -0,0 +1,96 @@ +# Review the Sample Application Source Code + +## Introduction + +This lab reviews the sample Micronaut application code used in the workshop. The application source code and build scripts are available for review in VS Code. + +You'll see how easy it is to configure a Micronaut application to send logs to OCI Logging with the GDK. + +Estimated Time: 10 minutes + +### Objectives + +In this lab, you will: + +* Review the sample application source code + +## Task 1: Review the Application Dependencies + +The build file contains the following dependency to support the [Logback](https://logback.qos.ch/) appender that pushes logs to Oracle Cloud. + +_oci/pom.xml_ + + + io.micronaut.oraclecloud + micronaut-oraclecloud-logging + compile + + + +## Task 2: Review the Controller + +Our application contains a simple controller class, named `GreetingController`, containing a single method `greet` which is invoked by an HTTP POST request. The method has an informational log statement to log the greeting message. + +_lib/src/main/java/com/example/GreetingController.java_ + +``` java +import org.slf4j.Logger; // <1> +import org.slf4j.LoggerFactory; // <1> + +@Controller +class GreetingController { + + private static final Logger LOG = LoggerFactory.getLogger(GreetingController.class); // <2> + + @Post("/greet") + void greet(@Body String message) { + LOG.info(message); // <3> + } +} +``` + +1. Import the Simple Logging Facade for Java (SLF4J) Logger and LoggerFactory classes. SLF4J serves as a simple facade or abstraction for various logging frameworks, such as `java.util.logging`, `logback` and `reload4j`. SLF4J enables the user to plug in the desired logging framework at deployment time. + +2. Get a logger with the class name. + +3. This logger is in turn used to log the message received in each POST request. + +## Task 3: Review the Logback configuration + +The Logback configuration has been modified by adding the `OracleCloudAppender` to send log statements to OCI Logging in addition to `STDOUT`. + +_oci/src/main/resources/logback.xml_ + + + + + + %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + + + + + + + + + + + + + + + + + + +In the next section, you will configure OCI Logging and include the OCI Log OCID in the _logback.xml_ file. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/04-configure-logging/configure-logging.md b/gdk-oci-logging/04-configure-logging/configure-logging.md new file mode 100644 index 000000000..4d7160cc6 --- /dev/null +++ b/gdk-oci-logging/04-configure-logging/configure-logging.md @@ -0,0 +1,64 @@ +# Configure OCI Logging + +## Introduction + +This lab provides instructions to configure the OCI Logging service. + +Estimated Lab Time: 05 minutes + +### Objectives + +In this lab, you will: + +* Create a Log Group +* Create a Custom Log + +## Task 1: Create a Log Group + +1. From the Oracle Cloud Console navigation menu, go to **Observability & Management**. Under **Logging**, click **Log Groups**. + + ![Logging Menu](https://oracle-livelabs.github.io/common/images/console/logging.png) + +2. Under **List scope**, select your workshop compartment. + + ![Select Compartment Button](images/select-compartment-button.jpg) + +3. Click **Create Log Group**. + + ![Create Log Group Button](images/log-group-create-button.jpg#input) + +4. You will see the **Create Log Group** screen. Enter the Name as "MicronautLogGroup". Click **Create** to create the Log Group. + + ![Create Log Group Screen](images/log-group-create-screen.jpg#input) + +## Task 2: Create a Custom Log + +1. From the **MicronautLogGroup** details screen, click **Logs** under **Resources**. Click **Create custom log**. + + ![Create Custom Log Button](images/custom-log-create-button.jpg#input) + +2. You will see the **Create custom log** wizard. Enter the Custom log name as "MicronautCustomLog". Select Log group as "MicronautLogGroup" from the drop down list (if it's not already selected). Click **Create custom log** to proceed to **Create agent config**. + + ![Create Custom Log Screen 1](images/custom-log-create-screen-1.jpg#input) + +3. On the **Create agent configuration** screen, select the **Add configuration later** option. Click **Create agent config**. + + ![Create Custom Log Screen 2](images/custom-log-create-screen-2.jpg#input) + +4. From the Logs list, click **MicronautCustomLog** to go to the Log details screen. + + ![Open MicronautCustomLog](images/micronaut-custom-log-open.jpg#input) + +15. From the **Log Information** tab of the **MicronautCustomLog** details screen, click **Copy** to copy the Log OCID. You’ll need it to configure the application in the next step. + + ![Copy MicronautCustomLog OCID](images/micronaut-custom-log-copy-ocid.jpg#input) + +Congratulations! In this lab, you configured OCI Logging by creating a Log Group and a Custom Log object. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/04-configure-logging/images/custom-log-create-button.jpg b/gdk-oci-logging/04-configure-logging/images/custom-log-create-button.jpg new file mode 100644 index 000000000..354c8bdeb Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/custom-log-create-button.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/custom-log-create-screen-1.jpg b/gdk-oci-logging/04-configure-logging/images/custom-log-create-screen-1.jpg new file mode 100644 index 000000000..e7405a5d4 Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/custom-log-create-screen-1.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/custom-log-create-screen-2.jpg b/gdk-oci-logging/04-configure-logging/images/custom-log-create-screen-2.jpg new file mode 100644 index 000000000..43332d218 Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/custom-log-create-screen-2.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/log-group-create-button.jpg b/gdk-oci-logging/04-configure-logging/images/log-group-create-button.jpg new file mode 100644 index 000000000..876e670d1 Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/log-group-create-button.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/log-group-create-screen.jpg b/gdk-oci-logging/04-configure-logging/images/log-group-create-screen.jpg new file mode 100644 index 000000000..5fc745fc1 Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/log-group-create-screen.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/micronaut-custom-log-copy-ocid.jpg b/gdk-oci-logging/04-configure-logging/images/micronaut-custom-log-copy-ocid.jpg new file mode 100644 index 000000000..6d54ed2db Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/micronaut-custom-log-copy-ocid.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/micronaut-custom-log-open.jpg b/gdk-oci-logging/04-configure-logging/images/micronaut-custom-log-open.jpg new file mode 100644 index 000000000..34cb58591 Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/micronaut-custom-log-open.jpg differ diff --git a/gdk-oci-logging/04-configure-logging/images/select-compartment-button.jpg b/gdk-oci-logging/04-configure-logging/images/select-compartment-button.jpg new file mode 100644 index 000000000..a17e0a72e Binary files /dev/null and b/gdk-oci-logging/04-configure-logging/images/select-compartment-button.jpg differ diff --git a/gdk-oci-logging/05-configure-app/configure-app.md b/gdk-oci-logging/05-configure-app/configure-app.md new file mode 100644 index 000000000..927791040 --- /dev/null +++ b/gdk-oci-logging/05-configure-app/configure-app.md @@ -0,0 +1,88 @@ +# Configure the Application to Use the OCI Logging + +## Introduction + +This lab provides instructions to configure the application to point to OCI Logging. + +Estimated Lab Time: 05 minutes + +### Objectives + +In this lab, you will: + +* Configure the Application to Use the OCI Logging +* Configure OCI Instance Principal Authentication + +## Task 1: Configure the Application to Use the OCI Logging + +1. In VS Code, open _oci/src/main/resources/logback.xml_. + +2. Go to the `` element and paste the Log OCID that you copied earlier. + + ```xml + + ``` + + Replace `ocid1.log.oc1.iad.ama...` with the actual value. + + ``` + ocid1.log.oc1.iad.ama... + ``` + +3. Save the file. + + +## Task 2: UseConfigure OCI Instance Principal Authentication + +1. In VS Code, open `application-oraclecloud.properties`. The application is configured to use `OCI Instance Principal Authentication` when it is running on an OCI Compute Instance. + + _oci/src/main/resources/application-oraclecloud.properties_ + + ``` properties + oci.config.instance-principal.enabled=true + ``` + + +2. The workshop environment includes a preconfigured `Instance Principal` using a `Dynamic Group` and a `Policy` in OCI to allow the application to send logs to OCI Logging. + + + +2. The following steps show you how to set up an `Instance Principal` using a `Dynamic Group`-less `Policy` in OCI to allow the application to send logs to OCI Logging. + +3. From the Oracle Cloud Console navigation menu, go to **Identity & Security >> Identity >> Policies**. + + ![Policies Menu](https://oracle-livelabs.github.io//common/images/console/id-policies.png) + +4. Go to your workshop compartment. + +5. Click **Create Policy**. + +6. Enter a name and description. + +7. Select your workshop compartment. + +8. In the **Policy Builder** section, click **Show manual editor**. + +9. Enter the following policy statement in the text area. Replace the placeholders `WORKSHOP_COMPARTMENT_NAME` with your workshop compartment name, and `WORKSHOP_COMPARTMENT_OCID` with your workshop compartment OCID. + + ``` text + + Allow any-user to use log-content in compartment WORKSHOP_COMPARTMENT_NAME where ALL {request.principal.type='instance', request.principal.compartment.id='WORKSHOP_COMPARTMENT_OCID'} + + ``` + + To learn more about policies to control access to OCI Logging, see [Policy Reference - Details for Logging](https://docs.oracle.com/en-us/iaas/Content/Identity/Reference/loggingpolicyreference.htm). + + + + To learn more about the supported authentication options, see [Micronaut Oracle Cloud Authentication](https://micronaut-projects.github.io/micronaut-oracle-cloud/snapshot/guide/#authentication). + +Congratulations! In this lab, you configured the application to use OCI Logging. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/06-build-run-app/build-run-app.md b/gdk-oci-logging/06-build-run-app/build-run-app.md new file mode 100644 index 000000000..2289536e2 --- /dev/null +++ b/gdk-oci-logging/06-build-run-app/build-run-app.md @@ -0,0 +1,85 @@ +# Build and run the application and view the logs in OCI Logging + +## Introduction + +This section of the lab takes you through the steps to build and run the sample application and send application logs to OCI Logging. + +Estimated Lab Time: 10 minutes + +### Objectives + +In this lab, you will: + +* Build and run the application +* Send an HTTP POST request +* View the application logs in OCI Logging + +## Task 1: Build and run the application + +1. Open a new terminal in VS Code using the **Terminal > New Terminal** menu. + +2. Run the following command to build application: + + + + Use `mn:run` to build and start the application on port 8080. + + ``` bash + + ./mvnw install -pl lib -am && MICRONAUT_ENVIRONMENTS=oraclecloud ./mvnw mn:run -pl oci + + ``` + + + + + Build an executable JAR file and then use `java -jar` to run it. + + ``` bash + + ./mvnw install -pl lib -am && ./mvnw package -pl oci + + MICRONAUT_ENVIRONMENTS=oraclecloud java -jar oci/target/oci-logging-demo-oci-1.0-SNAPSHOT.jar + + ``` + + +## Task 2: Send an HTTP POST request + +1. Open a second terminal in VS Code using the **Terminal>New Terminal** menu. + +2. From the second terminal, send an HTTP POST request to the `/greet` endpoint: + + ``` bash + + curl -X POST -H "Content-Type: application/json" -id '{"message":"Hello GCN Logging!"}' http://localhost:8080/greet + + ``` + + VS Code may prompt you to open the URL in a browser as shown below. Just click the **Configure Notifications** gear icon and then click **Don't Show Again**. + + ![VS Code ](images/vscode-paste-urls.png) + + ![VS Code ](images/vscode-dont-show-again.png) + +## Task 3: Stop the application + +1. In the first terminal in VS Code, use `CTRL+C` to stop the application. + +## Task 4: View the application logs in OCI Logging + +1. Go to the **OCI Console >> Logging >> Log Groups >> MicronautLogGroup >> MicronautCustomLog >> Custom Log (MicronautCustomLog) Details** screen opened in the browser. The application logs should appear in the **Explore Log** section. (If necessary, refresh the browser.) + + You can select a different value such as "Past 15 minutes" or "Past hour" in the **Filter by time** drop down list to refresh the logs table view. + + ![Application Logs](./images/application-logs-jvm.jpg) + +Congratulations! You've successfully completed this lab. Your Java application can successfully send logs to OCI Logging. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/06-build-run-app/images/application-logs-jvm.jpg b/gdk-oci-logging/06-build-run-app/images/application-logs-jvm.jpg new file mode 100644 index 000000000..e7ea8b64c Binary files /dev/null and b/gdk-oci-logging/06-build-run-app/images/application-logs-jvm.jpg differ diff --git a/gdk-oci-logging/06-build-run-app/images/vscode-dont-show-again.png b/gdk-oci-logging/06-build-run-app/images/vscode-dont-show-again.png new file mode 100644 index 000000000..7dfb2cb6c Binary files /dev/null and b/gdk-oci-logging/06-build-run-app/images/vscode-dont-show-again.png differ diff --git a/gdk-oci-logging/06-build-run-app/images/vscode-paste-urls.png b/gdk-oci-logging/06-build-run-app/images/vscode-paste-urls.png new file mode 100644 index 000000000..fbca1fac7 Binary files /dev/null and b/gdk-oci-logging/06-build-run-app/images/vscode-paste-urls.png differ diff --git a/gdk-oci-logging/07-build-run-native/build-run-native.md b/gdk-oci-logging/07-build-run-native/build-run-native.md new file mode 100644 index 000000000..2f6168096 --- /dev/null +++ b/gdk-oci-logging/07-build-run-native/build-run-native.md @@ -0,0 +1,83 @@ +# Build and run a native executable and view the logs in OCI Logging + +## Introduction + +This lab describes how to build and run a native executable for the application, and send logs to OCI Logging. + +You will use [GraalVM Native Image](https://docs.oracle.com/en/graalvm/jdk/17/docs/overview/)’s ahead-of-time compilation to build a native executable for the application. + +At build time, GraalVM analyzes a Java application and its dependencies to identify just what classes, methods, and fields are absolutely necessary, and then generates a native executable with optimized machine code for just these elements. + +Native executables built with GraalVM require less memory, are smaller in size, and start upto 100x faster than just-in-time compiled applications running on a Java Virtual Machine. + +Estimated Lab Time: 15 minutes + +### Objectives + +In this lab, you will: + +* Build and run a native executable for the application +* Send an HTTP POST request +* View the application logs in OCI Logging + +## Task 1: Build and run a native executable for the application + +1. In the first terminal in VS Code, check the version of the GraalVM native-image utility: + + ``` bash + + native-image --version + + ``` + +2. To generate a native executable using Maven, run the following command: + + ``` bash + + ./mvnw install -pl lib -am && ./mvnw clean package -pl oci -Dpackaging=native-image + + ``` + + It can take approximately 3-4 minutes to generate the native executable. + +3. The native executable is created in the _oci/target_ directory and can be run with the following command: + + ``` bash + + MICRONAUT_ENVIRONMENTS=oraclecloud oci/target/oci-logging-demo-oci + + ``` + + The native executable starts instantaneously. + +## Task 2: Send an HTTP POST request + +1. From the second terminal, send an HTTP POST request to the `/greet` endpoint: + + ``` bash + + curl -X POST -H "Content-Type: application/json" -id '{"message":"Hello GCN Logging native executable!"}' http://localhost:8080/greet + + ``` + +## Task 3: Stop the application + +1. In the first terminal in VS Code, use `CTRL+C` to stop the application. + +## Task 4: View the application logs in OCI Logging + +1. Go to the **OCI Console >> Logging >> Log Groups >> MicronautLogGroup >> MicronautCustomLog >> Custom Log (MicronautCustomLog) Details** screen opened in the browser. The application logs should appear in the **Explore Log** section. (If necessary, refresh the browser.) + + You can select a different value such as "Past 15 minutes" or "Past hour" in the **Filter by time** drop down list to refresh the logs table view. + + ![Application Logs](./images/application-logs-native.jpg) + +Congratulations! You've successfully completed this lab. Your Java application native executable can successfully send logs to OCI Logging. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/07-build-run-native/images/application-logs-native.jpg b/gdk-oci-logging/07-build-run-native/images/application-logs-native.jpg new file mode 100644 index 000000000..7d6d2c5fa Binary files /dev/null and b/gdk-oci-logging/07-build-run-native/images/application-logs-native.jpg differ diff --git a/gdk-oci-logging/08-cleanup/cleanup.md b/gdk-oci-logging/08-cleanup/cleanup.md new file mode 100644 index 000000000..ae441e128 --- /dev/null +++ b/gdk-oci-logging/08-cleanup/cleanup.md @@ -0,0 +1,41 @@ +# Cleanup + +## Introduction + +From the Oracle Cloud Console, clean up the resources provisioned for this workshop. + +Estimated Workshop Time: 05 minutes + +### Objectives + +In this lab, you will: + +* Delete the Custom Log +* Delete the Log Group +* Destroy Stack +* Delete Stack +* Delete the Instance Principals Policy + +## Task 1: Cleanup + +From the Oracle Cloud Console, clean up the resources provisioned for this workshop: + +1. From **Observability & Management >> Logging >> Log Groups >> MicronautLogGroup**, delete the **Custom Log (MicronautCustomLog)**. + +2. From **Observability & Management >> Logging >> Log Groups**, delete the **MicronautLogGroup**. + +3. From **Resource Manager >> Stacks >> Stack Details** screen, run **Destroy** to delete the VCN and the Compute instance. + +4. From **Resource Manager >> Stacks >> Stack Details** screen, **Delete** the **Stack**. + +5. From **Identity & Security >> Identity >> Policies**, delete the Instance Principals **Policy**. + +Congratulations! You've successfully completed this lab. + +You may now **proceed to the next lab**. + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) \ No newline at end of file diff --git a/gdk-oci-logging/09-conclusion/conclusion.md b/gdk-oci-logging/09-conclusion/conclusion.md new file mode 100644 index 000000000..d6d0d63cb --- /dev/null +++ b/gdk-oci-logging/09-conclusion/conclusion.md @@ -0,0 +1,20 @@ +# Conclusion + +In this workshop, you've learnt how to configure a Micronaut application to send application logs to OCI Logging using the GDK. + +You've seen how to use GraalVM Native Image to package and run the application as a native executable. + +Application developers can use the Graal Development Kit for Micronaut (GDK) to build cloud-portable Java applications on Oracle Cloud Infrastructure with Micronaut and GraalVM Native Image. + +## Learn More + +- [Publish Application Logs to OCI Logging](https://graal.cloud/gdk/gdk-modules/logging/micronaut-oci-logging/?buildTool=maven&lang=java) +- [GDK Logging](https://graal.cloud/gdk/modules/#logging) +- [Micronaut Oracle Cloud Logging](https://micronaut-projects.github.io/micronaut-oracle-cloud/snapshot/guide/#logging) +- [Micronaut Oracle Cloud Authentication](https://micronaut-projects.github.io/micronaut-oracle-cloud/snapshot/guide/#authentication) + +## Acknowledgements + +* **Author** - [](var:author) +* **Contributors** - [](var:contributors) +* **Last Updated By/Date** - [](var:last_updated) diff --git a/gdk-oci-logging/variables/variables.json b/gdk-oci-logging/variables/variables.json new file mode 100644 index 000000000..4736d95bb --- /dev/null +++ b/gdk-oci-logging/variables/variables.json @@ -0,0 +1,5 @@ +{ + "author": "Graal Product Management", + "contributors": "Lesia Chaban, Sachin Pikle, Ewan Slater, Kris Foster, Shaun Smith", + "last_updated": "Lesia Chaban, August 2024" + } \ No newline at end of file diff --git a/gdk-oci-logging/workshops/desktop/index.html b/gdk-oci-logging/workshops/desktop/index.html new file mode 100644 index 000000000..7ec6410f1 --- /dev/null +++ b/gdk-oci-logging/workshops/desktop/index.html @@ -0,0 +1,62 @@ + + + + + + + + + Oracle LiveLabs + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ + + + + diff --git a/gdk-oci-logging/workshops/desktop/manifest.json b/gdk-oci-logging/workshops/desktop/manifest.json new file mode 100644 index 000000000..758dc2d95 --- /dev/null +++ b/gdk-oci-logging/workshops/desktop/manifest.json @@ -0,0 +1,67 @@ +{ + "workshoptitle": "Build a Java application with the Graal Development Kit for Micronaut (GDK), and Oracle Cloud Infrastructure Logging", + "variables": ["../../variables/variables.json"], + "help": "livelabs-help-oci_us@oracle.com", + "tutorials": [ + { + "title": "Introduction", + "description": "The Introduction is always second for LiveLabs. The title and contents menu title match for the Introduction.", + "filename": "../../00-introduction/introduction.md" + }, + { + "title": "Get Started", + "description": "Prerequisites for LiveLabs (Oracle-owned tenancies). The title of the lab and the Contents Menu title (the title above) match for Prerequisite lab. This lab is always first.", + "filename": "https://oracle-livelabs.github.io/common/labs/cloud-login/cloud-login-livelabs2.md" + }, + { + "title": "Get Started with noVNC Remote Desktop", + "description": "Using noVNC Remote Desktop", + "filename": "https://oracle-livelabs.github.io/common/labs/remote-desktop/using-novnc-remote-desktop.md" + }, + { + "title": "Lab 1: Clone the Sample Application Source Code", + "filename": "../../02-git-clone/git-clone.md" + }, + { + "title": "Lab 2: Review the Application Source Code", + "filename": "../../03-review-code/review-code.md" + }, + { + "title": "Lab 3: Configure OCI Logging", + "filename": "../../04-configure-logging/configure-logging.md", + "type": "desktop" + }, + { + "title": "Lab 4: Configure the application to use OCI Logging", + "filename": "../../05-configure-app/configure-app.md", + "type": "desktop" + }, + { + "title": "Lab 5: Build and Run the Application", + "filename": "../../06-build-run-app/build-run-app.md", + "type" : { + "mn_run" : "mn:run", + "jar" : "JAR" + } + }, + { + "title": "Lab 6: Build and Run a Native Executable", + "filename": "../../07-build-run-native/build-run-native.md", + "type": "desktop" + }, + { + "title": "Lab 7: Cleanup", + "filename": "../../08-cleanup/cleanup.md", + "type": "desktop" + }, + { + "title": "Conclusion", + "filename": "../../09-conclusion/conclusion.md" + }, + { + "title": "Need Help?", + "description": "Solutions to Common Problems and Directions for Receiving Live Help", + "filename": "https://oracle-livelabs.github.io/common/labs/need-help/need-help-livelabs.md" + } + ] +} diff --git a/gdk-oci-logging/workshops/sandbox/index.html b/gdk-oci-logging/workshops/sandbox/index.html new file mode 100644 index 000000000..7ec6410f1 --- /dev/null +++ b/gdk-oci-logging/workshops/sandbox/index.html @@ -0,0 +1,62 @@ + + + + + + + + + Oracle LiveLabs + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ + + + + diff --git a/gdk-oci-logging/workshops/sandbox/manifest.json b/gdk-oci-logging/workshops/sandbox/manifest.json new file mode 100644 index 000000000..be6978fe4 --- /dev/null +++ b/gdk-oci-logging/workshops/sandbox/manifest.json @@ -0,0 +1,62 @@ +{ + "workshoptitle": "Build a Java application with the Graal Development Kit for Micronaut (GDK), and Oracle Cloud Infrastructure Logging", + "variables": ["../../variables/variables.json"], + "help": "livelabs-help-oci_us@oracle.com", + "tutorials": [ + { + "title": "Introduction", + "description": "The Introduction is always second for LiveLabs. The title and contents menu title match for the Introduction.", + "filename": "../../00-introduction/introduction.md" + }, + { + "title": "Get Started", + "description": "Prerequisites for LiveLabs (Oracle-owned tenancies). The title of the lab and the Contents Menu title (the title above) match for Prerequisite lab. This lab is always first.", + "filename": "https://oracle-livelabs.github.io/common/labs/cloud-login/cloud-login-livelabs2.md" + }, + { + "title": "Lab 1: Clone the Sample Application Source Code", + "filename": "../../02-git-clone/git-clone.md" + }, + { + "title": "Lab 2: Review the Application Source Code", + "filename": "../../03-review-code/review-code.md" + }, + { + "title": "Lab 3: Configure OCI Logging", + "filename": "../../04-configure-logging/configure-logging.md", + "type": "desktop" + }, + { + "title": "Lab 4: Configure the application to use OCI Logging", + "filename": "../../05-configure-app/configure-app.md", + "type": "desktop" + }, + { + "title": "Lab 5: Build and Run the Application", + "filename": "../../06-build-run-app/build-run-app.md", + "type" : { + "mn_run" : "mn:run", + "jar" : "JAR" + } + }, + { + "title": "Lab 6: Build and Run a Native Executable", + "filename": "../../07-build-run-native/build-run-native.md", + "type": "desktop" + }, + { + "title": "Lab 7: Cleanup", + "filename": "../../08-cleanup/cleanup.md", + "type": "desktop" + }, + { + "title": "Conclusion", + "filename": "../../09-conclusion/conclusion.md" + }, + { + "title": "Need Help?", + "description": "Solutions to Common Problems and Directions for Receiving Live Help", + "filename": "https://oracle-livelabs.github.io/common/labs/need-help/need-help-livelabs.md" + } + ] +} diff --git a/gdk-oci-logging/workshops/tenancy/index.html b/gdk-oci-logging/workshops/tenancy/index.html new file mode 100644 index 000000000..7ec6410f1 --- /dev/null +++ b/gdk-oci-logging/workshops/tenancy/index.html @@ -0,0 +1,62 @@ + + + + + + + + + Oracle LiveLabs + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ + + + + diff --git a/gdk-oci-logging/workshops/tenancy/manifest.json b/gdk-oci-logging/workshops/tenancy/manifest.json new file mode 100644 index 000000000..9b196c8c0 --- /dev/null +++ b/gdk-oci-logging/workshops/tenancy/manifest.json @@ -0,0 +1,77 @@ +{ + "workshoptitle": "Build a Java application with the Graal Development Kit for Micronaut (GDK), and Oracle Cloud Infrastructure Logging", + "variables": ["../../variables/variables.json"], + "help": "livelabs-help-oci_us@oracle.com", + "tutorials": [ + { + "title": "Introduction", + "description": "The Introduction is always first. The title and contents menu title match for the Introduction.", + "filename": "../../00-introduction/introduction.md" + }, + { + "title": "Get Started", + "description": "This is the prerequisites for customers using Free Trial and Paid tenancies, and Always Free accounts (if applicable). The title of the lab and the Contents Menu title (the title above) match for Prerequisite lab. This lab is always first.", + "filename": "https://oracle-livelabs.github.io/common/labs/cloud-login/pre-register-free-tier-account.md" + }, + { + "title": "Prepare Setup", + "description": "How to download your ORM stack and update security rules for an existing VCN", + "filename": "../../01-prepare-setup/prepare-setup.md" + }, + { + "title": "Environment Setup", + "description": "How to provision the workshop environment and connect to it", + "filename": "https://oracle-livelabs.github.io/common/labs/setup-compute-generic/setup-compute-novnc-ssh.md" + }, + { + "title": "Get Started with noVNC Remote Desktop", + "description": "Using noVNC Remote Desktop", + "filename": "https://oracle-livelabs.github.io/common/labs/remote-desktop/using-novnc-remote-desktop.md" + }, + { + "title": "Lab 1: Clone the Sample Application Source Code", + "filename": "../../02-git-clone/git-clone.md" + }, + { + "title": "Lab 2: Review the Application Source Code", + "filename": "../../03-review-code/review-code.md" + }, + { + "title": "Lab 3: Configure OCI Logging", + "filename": "../../04-configure-logging/configure-logging.md", + "type": "tenancy" + }, + { + "title": "Lab 4: Configure the application to use OCI Logging", + "filename": "../../05-configure-app/configure-app.md", + "type": "tenancy" + }, + { + "title": "Lab 5: Build and Run the Application", + "filename": "../../06-build-run-app/build-run-app.md", + "type" : { + "mn_run" : "mn:run", + "jar" : "JAR" + } + }, + { + "title": "Lab 6: Build and Run a Native Executable", + "filename": "../../07-build-run-native/build-run-native.md", + "type": "tenancy" + }, + { + "title": "Lab 7: Cleanup", + "filename": "../../08-cleanup/cleanup.md", + "type": "tenancy" + }, + { + "title": "Conclusion", + "filename": "../../09-conclusion/conclusion.md" + }, + { + "title": "Need Help?", + "description": "Solutions to Common Problems and Directions for Receiving Live Help", + "filename": "https://oracle-livelabs.github.io/common/labs/need-help/need-help-freetier.md" + } + ] +} \ No newline at end of file