Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f454b4c
Adding gdk-oci-email workshop
LesiaChaban Jul 25, 2024
52eaaa0
Add more changes
LesiaChaban Jul 25, 2024
d1644c3
Add build-and run sections
LesiaChaban Jul 26, 2024
1f1d1e7
Update git-clone.md
LesiaChaban Jul 26, 2024
d8e1c10
Update git-clone
LesiaChaban Jul 26, 2024
6e9844a
Follow Sachin P. comments
LesiaChaban Jul 26, 2024
9825ab5
Follow Sachin P. comments
LesiaChaban Jul 26, 2024
a2410ae
Update configure-app.md
LesiaChaban Jul 26, 2024
ff4b9ef
Add more changes
LesiaChaban Jul 26, 2024
4c0b200
Merge branch 'oracle-livelabs:main' into main
LesiaChaban Jul 27, 2024
767917b
Push more changes
LesiaChaban Jul 27, 2024
118f4bc
Update manifest.json
LesiaChaban Jul 27, 2024
c687a04
Add more changes
LesiaChaban Jul 29, 2024
eb6aa52
Update git-clone.md
LesiaChaban Jul 29, 2024
aaa8113
Additional changes
LesiaChaban Jul 29, 2024
4367cd0
Minor updates
sachin-pikle Jul 29, 2024
dd39b9e
Update prepare-setup.md
LesiaChaban Jul 29, 2024
878e9a8
Add minor changes
LesiaChaban Jul 30, 2024
2982158
Update git-clone.md
LesiaChaban Jul 30, 2024
73f973f
minor fix
LesiaChaban Jul 31, 2024
acb9c49
Add minor changes
LesiaChaban Jul 31, 2024
fe24b49
Change OCI menu images
LesiaChaban Jul 31, 2024
d57d129
Change manifest.json files
LesiaChaban Jul 31, 2024
fc656d2
Update configure-app.md
LesiaChaban Jul 31, 2024
28e0e7f
Update configure-app.md
LesiaChaban Jul 31, 2024
8ecf960
Minor updates
sachin-pikle Jul 31, 2024
970b2c0
Merge branch 'oracle-livelabs:main' into main
LesiaChaban Aug 3, 2024
ca902d8
Add gdk-oci-logging lab
LesiaChaban Aug 5, 2024
6867bc3
Add more changes
LesiaChaban Aug 5, 2024
e2b62e6
Add more changes
LesiaChaban Aug 6, 2024
0541a0d
Minor changes
LesiaChaban Aug 7, 2024
048de94
Minor fix
LesiaChaban Aug 7, 2024
59c3e3f
Fix manifest.json files
LesiaChaban Aug 7, 2024
f05ec62
Minor updates
sachin-pikle Aug 7, 2024
341da6b
update configure logging
LesiaChaban Aug 8, 2024
593c5af
Update configure-logging.md
LesiaChaban Aug 8, 2024
6c9f6ab
Merge branch 'oracle-livelabs:main' into main
LesiaChaban Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions gdk-oci-logging/00-introduction/introduction.md
Original file line number Diff line number Diff line change
@@ -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)
85 changes: 85 additions & 0 deletions gdk-oci-logging/01-prepare-setup/prepare-setup.md
Original file line number Diff line number Diff line change
@@ -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)
54 changes: 54 additions & 0 deletions gdk-oci-logging/02-git-clone/git-clone.md
Original file line number Diff line number Diff line change
@@ -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
<copy>
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
</copy>
```

3. Open the sample application source code from the _gdk-oci-logging-mvn_ directory in **Visual Studio Code**.

```bash
<copy>
code gdk-oci-logging-mvn
</copy>
```

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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions gdk-oci-logging/03-review-code/review-code.md
Original file line number Diff line number Diff line change
@@ -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_

<dependency>
<groupId>io.micronaut.oraclecloud</groupId>
<artifactId>micronaut-oraclecloud-logging</artifactId>
<scope>compile</scope>
</dependency>


## 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_

<configuration debug='false'>

<appender name='STDOUT' class='ch.qos.logback.core.ConsoleAppender'>
<encoder>
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
</encoder>
</appender>
<appender name='ORACLE' class='io.micronaut.oraclecloud.logging.OracleCloudAppender'>
<!-- <appender-ref ref='STDOUT'/> -->
<logId><!-- TODO set the value of the Oracle Cloud log OCID here --></logId>
<encoder class='ch.qos.logback.core.encoder.LayoutWrappingEncoder'>
<layout class='ch.qos.logback.contrib.json.classic.JsonLayout'>
<jsonFormatter class='ch.qos.logback.contrib.jackson.JacksonJsonFormatter'/>
</layout>
</encoder>
</appender>

<root level='INFO'>
<appender-ref ref='ORACLE'/>
<appender-ref ref='STDOUT'/>
</root>

</configuration>

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)
64 changes: 64 additions & 0 deletions gdk-oci-logging/04-configure-logging/configure-logging.md
Original file line number Diff line number Diff line change
@@ -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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading