This post is part of the OCI Logging – Complete Hands-on Series. Make sure to check out the other posts as well.
- Service logs: Emitted by OCI native services, such as API Gateway, Events, Functions, Load Balancing, Object Storage, and VCN Flow Logs. Each of these supported services has pre-defined logging categories that you can enable or disable on your respective resources.
So basically, you can see the logs from some of the OCI Native Services (list below) and you can use them in many different ways (like creating alerts on specific errors or archiving them for audit purposes) so you have better control over your workloads and a better understanding of what’s going on.
As of March 2022, you can enable service logs for the following Oracle Cloud Infrastructure services:
- API Gateway
- Email Delivery
- Load Balancers
- Object Storage
- VCN Flow Logs
- Site-to-Site VPN
- Web Application Firewall
This is very easy and everyone should do it if they use some of the services above, and there’s a good chance you are using at least a VCN or an Object Storage bucket.
You can enable Service Logs in two places: directly on the resource itself, or from the Logs page. Depending on the service, you’ll have different log categories and you can choose which ones you want to enable or you can just enable them all.
We will do this for the Load Balancer Service Logs, but feel free to check the documentation to see more details on enabling the logs using either option.
Example: Enabling Load Balancer Logs
We’ll take the Load Balancer logs as an example, but this applies to any other OCI Native Service mentioned above.
Enable Logs directly on the resource
So let’s see how to enable the Service Logs directly from the Load Balancer.
Navigate to Networking -> Load Balancers and then select your Load Balancer.
You will find then under the Resources on the left, the Logs menu where you will find the two service logs available for the Load Balancer: Access Logs and Error Logs:
Choose to enable one or both logs by toggling the Enable Log switch and you will be prompted with the following screen:
You can now select the compartment where you want to create the log, choose an existing Log Group or Create a New Group, give the log a name, choose the Log retention period and click Enable Log.
It is not recommended to choose the legacy archival of logs – check this post to see how to archive your logs
Enable Logs from the main Logging menu
This is a different way of achieving the same result as above. It is a matter of preference on how you choose to activate your service logs.
Navigate to Observability & Management -> Logs under the Logging category
In here, you will find all logs from OCI and you have the possibility to Create a Custom Log or Enable a Service Log.
Click on Enable Service Log
In here we’ll first select our Resource by choosing the compartment of our resource (in our case, the compartment of the Load Balancer), choose the Load Balancers service and select your Load Balancer.
Now configure the log by choosing the Log Category you want to enable and give the log a name.
Under Advancend Options you can configure the Log Group and the Log Retention Period
You can repeat this process for all Service Logs you want to enable.
This is a very simple way of gaining insight into some of the OCI Native Services by leveraging the Service Logs.
You can now find these logs either in the resource menu itself, like under Networking -> Load Balancer -> Your Load Balancer -> Logs
Or directly from the Observability & Management -> Logs.
You can click on any Log Name and you’ll be redirected to the Log Explorer where you’ll be able to view the logs
Activating these logs can give you a lot of insight into what’s happening with your OCI Native Resources – to the traffic that you’re getting through your Load Balancer and through your VCN, etc. You can easily explore these logs from the Logging menu, but you can also use Machine Learning Algorithms to do analysis and build your own dashboards using OCI Logging Analytics.
You can check this article on how to Analyze Logs in OCI with Logging Analytics to make your life easier (soon).