# Oracle Cloud integration

Forward metrics and logs from your Oracle Cloud Infrastructure tenancy to Better Stack.

**Deploy our Resource Manager stack to your tenancy.** It runs inside your tenancy, so Better Stack never connects to it.

This integration provides:

- Forwarding of metrics from OCI Monitoring, from every compartment or the ones you choose.
- Forwarding of audit logs from every compartment in your tenancy.
- Forwarding of logs from the log groups you choose.

### 1. Create a source

Create a [new Oracle Cloud source in Better Stack](https://telemetry.betterstack.com/team/0/sources/new?platform=oracle_cloud ";_blank")

### 2. Deploy the stack

1. Sign in to the Oracle Cloud Console in your tenancy's home region, as a user who can create compartments and policies. The stack forwards metrics and logs from this region.
2. On your source's **Ingest** tab, click **Deploy to Oracle Cloud**. Resource Manager opens the stack form.
3. Accept the Oracle Terms of Use and click **Next**.
4. The **Ingesting host** and **Source token** are already filled in. Click **Next**. To forward less, see [Choose what to forward](#choose-what-to-forward).
5. Make sure **Run apply** is selected, then click **Create**.
6. Once the apply job succeeds, go back to the **Ingest** tab. **Verify data collection** shows when the first logs and metrics arrive.

[info]
#### Apply fails on a Free Tier tenancy?
A Free Tier tenancy allows only 2 Connector Hubs, and the stack needs one for logs plus one or more for metrics. Set **Compartments** to the one compartment you need metrics from, as in [Choose what to forward](#choose-what-to-forward).
[/info]

## Choose what to forward

By default, the stack forwards metrics of common OCI services from every compartment, and audit logs from your whole tenancy. To change that, set these fields in the stack form when you deploy it:

- **Compartments**: comma-separated compartment OCIDs to forward metrics from. Leave it empty for every compartment.
- **Metric namespaces**: the OCI services to forward metrics for.
- **Forward audit logs**: turn it off to skip audit logs.
- **Log groups**: comma-separated OCIDs of more log groups to forward.

The stack finds the compartments with metrics when it runs, so apply it again in Resource Manager after you add compartments or start using new OCI services. To change these fields later, edit the stack's variables in Resource Manager, then apply it.

## Metrics and logs in Better Stack

When we ingest your metrics, we convert them to Better Stack naming, `oci.<namespace>.<metric>`. For example, `BytesFromNATgw` in `oci_nat_gateway` becomes `oci.nat_gateway.bytes_from_natgw`. Each metric is tagged with `compartment_id` and `unit`, plus its OCI dimensions in snake case, such as `resource_id` and `resource_name`, and `region` when the resource has one.

Logs from OCI Logging, including `_Audit` audit logs, arrive with the event under `data`. Better Stack removes session tokens and request and response headers before storing them.

## What the stack creates

The stack creates a `betterstack` compartment, so remove or rename any compartment of that name first. It holds:

- A VCN with a private subnet and a NAT gateway, so the function can reach Better Stack.
- A Functions application with the forwarder function.
- Connector Hubs: one for logs, and one or more for metrics. Each takes up to 5 compartments and 50 metric namespaces.

It also adds a policy that lets these connectors read metrics and logs and invoke the forwarder function.

These resources run in your tenancy, so Oracle bills them at your usual rates, including function invocations and the NAT gateway.

You can see exactly what gets deployed, including the forwarder code, at [https://github.com/BetterStackHQ/oci](https://github.com/BetterStackHQ/oci ";_blank")

## Removing the integration

1. In the Oracle Cloud Console, go to **Developer Services → Resource Manager → [Stacks](https://cloud.oracle.com/resourcemanager/stacks ";_blank")**
2. Open the Better Stack stack.
3. Click **Destroy**.

Destroying takes about 15 minutes, most of it removing the `betterstack` compartment.

## Need help?

Please let us know at hello@betterstack.com.  
We're happy to help! 🙏
