Skip to main content
The OCI Logging MCP server provides tools to interact with Oracle Cloud Infrastructure Logging resources, enabling management of log groups and logs for centralized logging and analysis.

Installation

uvx oracle.oci-logging-mcp-server

Running the Server

STDIO Transport Mode

uvx oracle.oci-logging-mcp-server

HTTP Streaming Transport Mode

ORACLE_MCP_HOST=<hostname/IP address> ORACLE_MCP_PORT=<port number> uvx oracle.oci-logging-mcp-server

Available Tools

The server provides the following tools for logging management:
Tool NameDescription
list_log_groupsList log groups in a given compartment
list_logsList logs in a given log group
get_logGet detailed information about a log using its OCID

Usage Examples

List Log Groups

List all log groups in my compartment
Retrieves all log groups with their names, descriptions, and states.

List Logs in a Group

Show me all logs in log group ocid1.loggroup.oc1.phx.example
Lists all logs within a specific log group including their configurations and states.

Get Log Details

Get details for log ocid1.log.oc1.phx.example
Retrieves comprehensive information about a specific log including:
  • Log type (service, custom, audit)
  • Retention period
  • Log configuration
  • Associated resources
  • Archiving settings

Understanding OCI Logging

What is OCI Logging?

OCI Logging is a centralized log management service that:
  • Collects Logs from OCI services and applications
  • Stores Logs with configurable retention
  • Analyzes Logs using search and filtering
  • Archives Logs to Object Storage
  • Integrates with Monitoring, Events, and Security services

Log Types

Service Logs
  • Automatically generated by OCI services
  • VCN Flow Logs - Network traffic
  • Load Balancer Access/Error Logs
  • API Gateway Access/Execution Logs
  • Object Storage Access Logs
  • Functions Invoke Logs
Audit Logs
  • Track API calls and administrative actions
  • Automatically enabled for all tenancies
  • Stored in special audit log groups
  • Critical for compliance and security
Custom Logs
  • Application logs from compute instances
  • Custom application logging
  • Aggregated using Logging Agent
  • Flexible schema and format

Log Groups

Log groups are logical containers for organizing logs:
  • Organize logs by environment, application, or service
  • Apply IAM policies at log group level
  • Simplify log management
  • Can contain multiple logs

Key Features

Retention
  • Configure retention from 1 to 6 months
  • Automatic deletion after retention period
  • Archive to Object Storage for long-term retention
Log Categories
  • Read - Service data plane operations
  • Write - Create, update, delete operations
Log Levels
  • Configure log detail levels
  • Filter noise from important events
  • Balance verbosity and cost

Architecture

Logging Components

Application/Service

Logging Agent (for custom logs)

OCI Logging Service

├── Log Storage (retention period)
├── Search & Analysis
├── Archive (Object Storage)
└── Connectors (Stream, Functions, Monitoring)

Log Flow

  1. Generation - Service or application emits logs
  2. Collection - Logging service or agent collects logs
  3. Ingestion - Logs written to OCI Logging
  4. Storage - Retained based on configuration
  5. Analysis - Search and query via console or API
  6. Archive - Optional long-term storage
  7. Action - Trigger events, alarms, or automation

Authentication

The server uses OCI CLI configuration from ~/.oci/config:
oci setup config

Required Permissions

Your OCI user or instance principal needs these IAM permissions: Read Logs:
Allow group LogReaders to read log-groups in compartment MyCompartment
Allow group LogReaders to read log-content in compartment MyCompartment
Manage Log Groups and Logs:
Allow group LogAdmins to manage log-groups in compartment MyCompartment
Allow group LogAdmins to manage logs in compartment MyCompartment
Enable Service Logs:
Allow group LogAdmins to use virtual-network-family in compartment MyCompartment
Allow group LogAdmins to use load-balancers in compartment MyCompartment
Security NoticeAll actions are performed with the permissions of the configured OCI CLI profile. We advise:
  • Least-privilege IAM setup
  • Secure credential management
  • Safe network practices
  • Secure logging (don’t log secrets)
  • Protect log data containing sensitive information

Common Use Cases

Security & Compliance

  • Enable VCN flow logs for network forensics
  • Monitor API audit logs for security events
  • Track administrative actions
  • Meet compliance logging requirements
  • Detect anomalous behavior

Troubleshooting

  • Debug application issues with custom logs
  • Analyze load balancer access patterns
  • Investigate network connectivity problems
  • Review API Gateway execution logs
  • Trace request flows across services

Performance Analysis

  • Analyze response times from access logs
  • Identify slow queries or operations
  • Monitor error rates
  • Track resource utilization

Operational Monitoring

  • Aggregate logs from multiple sources
  • Set up alerts on log patterns
  • Monitor service health
  • Track deployment impacts

Enabling Common Service Logs

VCN Flow Logs

Capture network traffic metadata:
  • Source and destination IPs
  • Ports and protocols
  • Packet counts and bytes
  • Accept/reject decisions
Use cases:
  • Network troubleshooting
  • Security analysis
  • Bandwidth monitoring
  • Compliance auditing

Load Balancer Logs

Access Logs:
  • Client IP and request details
  • Response codes and sizes
  • Backend server selection
  • Request timing
Error Logs:
  • Backend failures
  • SSL/TLS errors
  • Health check failures

Object Storage Logs

Track object operations:
  • Read/write/delete events
  • User and source IP
  • Timestamps
  • Success/failure status

Best Practices

Log Organization

  • Use descriptive log group names
  • Organize by environment (dev, test, prod)
  • Separate service logs from application logs
  • Group related logs together

Retention & Archiving

  • Set appropriate retention periods
  • Archive critical logs to Object Storage
  • Balance storage costs with compliance needs
  • Document retention policies

Security

  • Enable audit logging
  • Protect log data with IAM policies
  • Don’t log sensitive data (passwords, tokens)
  • Encrypt logs at rest and in transit
  • Monitor access to log data

Cost Optimization

  • Set retention to minimum required period
  • Archive to Object Storage for long-term retention
  • Use log categories to filter unnecessary logs
  • Monitor ingestion volume
  • Consider sampling for high-volume logs

Monitoring & Alerting

  • Create alarms on log patterns
  • Use Service Connector Hub to route logs
  • Integrate with SIEM systems
  • Set up automated responses

Integration Patterns

Log Analytics

  • Export logs to OCI Logging Analytics
  • Advanced querying and visualization
  • Machine learning anomaly detection
  • Long-term trend analysis

Service Connector Hub

  • Route logs to Object Storage
  • Stream to Functions for processing
  • Forward to Monitoring for metrics
  • Send to external SIEM

Events Service

  • Trigger actions on log events
  • Automate incident response
  • Execute Functions based on patterns
  • Send notifications

Troubleshooting

Log Group Not Found

Check:
  • Log group OCID is correct
  • Log group is in expected compartment
  • You have permission to view log group
  • Log group exists in correct region

No Logs Appearing

For Service Logs:
  • Verify log is enabled on the service
  • Check IAM policies allow log write
  • Ensure service is generating events
  • Wait a few minutes for propagation
For Custom Logs:
  • Verify Logging Agent is installed and running
  • Check agent configuration
  • Ensure network connectivity to Logging service
  • Review agent logs for errors

Permission Errors

Error: NotAuthorizedOrNotFound
  • Verify IAM policies grant required permissions
  • Check policy includes correct compartment
  • Ensure using principal with access
  • Verify log resource policy if applicable

High Ingestion Costs

Optimization strategies:
  • Review and reduce retention periods
  • Filter out unnecessary log categories
  • Sample high-volume logs
  • Archive to Object Storage
  • Remove or disable unused logs

Additional Resources

Build docs developers (and LLMs) love