Logs and Log Groups

Use Oracle Cloud Infrastructure Logging to manage logs and log groups.

Logs contain critical diagnostic information that tells you how your resources are performing and being accessed. You can enable logging on supported resources. To see a list of supported resources grouped by service, see Supported Services.

Log groups are logical containers for organizing logs. Logs must always be inside log groups. You must create a log group to enable a log.

Use log groups to limit access to sensitive logs with IAM policy. With log groups, you don't have to rely on complex compartment hierarchies to secure your logs. For example, say the default log group in a single compartment is where you store logs for the entire tenancy. You grant access to the compartment for log administrators with IAM policy as you normally would. However, let's say some projects contain personally identifiable information (PII) and those logs can only be viewed by a select group of log administrators. Log groups allow you to put logs that contain PII into a separate log group, and then use IAM policy to restrict access so that only a selected set of log administrators have the elevated access.

Log groups IAM policy

Required IAM Policy

To use Oracle Cloud Infrastructure, an administrator must be a member of a group granted security access in a policy  by a tenancy administrator. This access is required whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you get a message that you don't have permission or are unauthorized, verify with the tenancy administrator what type of access you have and which compartment  your access works in.

Administrators: for policy samples specific to logs and log groups, see Required Permissions for Working with Logs and Log Groups.

If you're new to policies, see Managing Identity Domains and Common Policies. If you want to know more about writing policies for Logging, see Details for Logging.

Required Permissions for Working with Logs and Log Groups

To enable service logs in a resource, a user must be granted manage access on the log group and access to the resource. In general, inspect access on the resource is enough, but check for specific resources. Inspect access provides permission to update the resource and permission for the log group that contains the log.

Logs and log groups use the log-group resource-type, but to search the contents of logs you must use a different resource-type.

IAM Policy Requirements for Resources

In addition to the permissions to work with the log group, to add service logs to a resource you must have the update permission for the resource. For many resources, the update permission is granted with the use verb. For example, users who can use buckets in CompartmentA, can also enable logging on a bucket in CompartmentA.

However, some resources don't include permission to update a resource with the use verb. For example, to update a rule for the Events service, you must have the full manage permission. To enable a log on an Events rule (or any other resource that doesn't include the update permission with the use verb), you must have the manage permission.

To allow a group to enable logging for these resources, without granting the full permissions of manage, you can add a policy statement to grant only the <RESOURCE>_UPDATE permission (or, in the case of the Events service, <RESOURCE>_MODIFY) from the manage verb. For example, to allow a group EventUsers to enable logs on Events rules in CompartmentA, you could write a policy like the following:

Allow group EventUsers to read cloudevents-rules in compartment CompartmentA
Allow group EventUsers to manage cloudevents-rules in compartment CompartmentA 
 where request.permission='EVENTRULE_MODIFY'

For information about resource permissions, see Policy Reference.

VCN Flow Logs IAM Policy

In addition to Required Permissions for Working with Logs and Log Groups, subnet read and update permissions are required for managing VCN Flow Logs.

To provide subnet permissions, use one of the following policies, listed in order from broader to narrowed privileges:

Allow group FlowLogsEnablers to manage virtual-network-family in tenancy 

Or:

Allow group FlowLogsEnablers to manage subnets in tenancy

Or:

Allow group FlowLogsEnablers to {SUBNET_READ, SUBNET_UPDATE} in tenancy

This group is similar to what is described for EventUsers in IAM Policy Requirements for Resources.

Example Scenario

Your company has an Operations department. Within the Operations department are several costs centers. You want to be able to tag resources that belong to the Operations department with the appropriate cost center.

  1. Create a log group called "confidential". Avoid entering confidential information.
  2. Add logs with sensitive data to the "confidential" log group.

An employee named Alice already belongs to the group BucketManagers. Alice can manage buckets in CompartmentA. You want Alice and other members of BucketManagers group to be able to enable logs on buckets in CompartmentA.

To grant the BucketManagers group access to the sensitive data log group (and only the sensitive data log group), add the following statements to the BucketManagers policy:

Allow group BucketManagers to manage log-groups in compartment CompartmentA where 
target.loggroups.id='ocid1.lumloggroup.oc1.phx.<uniqueID>'

Alice can now enable logs to bucket resources in CompartmentA.

Log and Log Group Names

For log group names, the first character must start with a letter. Otherwise, the following guidelines apply to both log and log group names:

  • Use from 1 to 256 characters.
  • Valid characters are letters (upper or lowercase), numbers, hyphens, underscores, and periods.
  • Log and log group names are case-sensitive. Logging handles write-log and WRITE-log as separate logs.
  • Avoid entering confidential information.