Skip to main content

Log Monitoring

Operate Tab - Log Viewer

When something goes wrong with your service, the first thing to check is the logs. KIOPS's log monitoring feature makes it easy to view and analyze logs from your Pods and Containers.

The target selector differs by runtime

The log viewer tab is available for all runtimes, but the target dropdown differs.

  • Kubernetes: Select the target Pod from the Select Pod dropdown.
  • Docker · Podman: Select the target container from the Select Container dropdown.
Why is Log Monitoring Important?

Logs are like a "diary" that tells you what your application is doing. Through error messages, warnings, and debug information, you can quickly identify the root cause of problems.

Log Viewing Overview

KIOPS supports log viewing in both Kubernetes and Docker/Podman environments. The UI branches on the infrastructure type (isDockerInfra); Docker and Podman use the same interface.

  • Kubernetes: Fetches Pod stdout/stderr.
  • Docker/Podman: Fetches container stdout/stderr.

Options such as line count, Follow (real-time streaming), Timestamps, and Previous are not provided. For real-time streaming, use the streaming mode in the Command Execution tab.


Step 1: Open the Log Viewer Tab

First, select the service whose logs you want to view.

  1. Go to the [Service Management] page and select the desired service.
  2. Click the Operate stage.
  3. Select the Log Viewer tab in the Operations Modal.
note

You need operational permissions for the service to access the Log Viewer tab.


Step 2: Select the Target

Kubernetes

  1. Select the target Pod from the Select Pod dropdown.
  2. The Pod status icon is rendered via an external callback. Status colors are shown as blue for running, orange for pending, red for failed/error, and gray for all other states.

Docker/Podman

  1. Select the target container from the Select Container dropdown.
  2. Confirm the container name and image.

Step 3: View Logs

  1. After selecting the target, click the View Logs button.
  2. Results appear in the log viewer.
  3. Use the Clear button to empty the output area.

Log Viewer UI

  • Target selection: Pod/container dropdown
  • View Logs button: View/refresh logs
  • Clear button: Clear the log screen
  • Log area: Monospace font, dark theme

Log Viewer Features

  • Dark theme: Dark background for improved readability.
  • Monospace font: Optimized for code/log readability.
  • Scrolling: Supports scrolling through large volumes of logs.
  • Select and copy: Text can be selected and copied.
  • Browser search: Use Ctrl+F to search for keywords. Dedicated log-level filtering and regular-expression search are not provided.

Log Analysis Techniques

Effective log analysis helps you resolve issues quickly.

Finding Error Logs

Look for these patterns in your logs. Most problems start with keywords like these.

ERROR: Connection refused to database
[ERROR] Failed to bind to port 8080
Exception in thread "main"
panic: runtime error
Search Tip

Press Ctrl+F in the log viewer to search for keywords like ERROR, Exception, or panic to quickly find issues.

Understanding Log Levels

Log levels indicate the importance of the message.

  • ERROR: Serious errors that require immediate attention.
  • WARN: Warnings that don't cause immediate problems but need attention.
  • INFO: Normal operational information.
  • DEBUG: Detailed debug information for developers.

Key Checkpoints

What to look for depends on the type of problem.

  • Application startup failure: Initialization errors, port binding failures, dependency connection issues.
  • Request processing errors: HTTP 5xx errors, stack traces.
  • Performance issues: Response time delays, timeouts, connection pool exhaustion.
  • Memory issues: OOM (Out of Memory), GC-related logs.

Real-World Usage Scenarios

Scenario 1: Verifying Service Startup After Deployment

Purpose: Confirm normal startup after deploying a new version.

  1. Open OperateLog Viewer tab.
  2. Select the newly created Pod.
  3. Click View Logs.
  4. Messages to look for:
    Starting application...
    Server started on port 8080
    Database connection established
    Application ready

Scenario 2: Analyzing Request Failure Causes

Purpose: Identify the cause of API call failures.

  1. Select the Pod where failures occurred.
  2. Click View Logs.
  3. Search for error patterns (Ctrl+F):
    • Exception, Error, Failed
    • HTTP status codes (500, 502, 503)
  4. Analyze stack traces.

Scenario 3: Debugging Restarted Pods

Purpose: Identify the cause of Pod restarts.

When a Pod has been restarted in Kubernetes:

  1. Select the Pod and click View Logs.
  2. Check startup logs for initialization failures.
  3. If in CrashLoopBackOff state, search recent logs for panic or exception.
  4. For additional events, expand the Pod row in the Pod List tab (there is no separate "Events tab").

Log-Based Troubleshooting

Common Error Patterns

  • Connection refused: Usually indicates DB or service connection failure. Check dependent service status and verify network connectivity.

  • Port already in use: Indicates a port conflict. Check port settings and ensure no other process is using the same port.

  • OutOfMemoryError: Indicates insufficient memory. Increase resource limits in your deployment configuration.

  • Permission denied: Indicates insufficient permissions. Check file and directory permissions for the running user.

  • No such file or directory: Indicates a missing file. Check ConfigMap and Volume mounts are correctly configured.

Java Applications

// Check stack trace
java.lang.NullPointerException
at com.example.MyClass.method(MyClass.java:42)

// Resolution: Add null check at the affected line

Node.js Applications

// Unhandled exception
UnhandledPromiseRejectionWarning
Error: connect ECONNREFUSED 127.0.0.1:5432

// Resolution: Check DB connection settings

Python Applications

// Import error
ModuleNotFoundError: No module named 'requests'

// Resolution: Add dependency to requirements.txt

Downloading Logs

Saving Logs

  1. Select all text in the log area (Ctrl+A)
  2. Copy (Ctrl+C)
  3. Paste into a text editor
  4. Save as a .log or .txt file.

Sharing Logs

  • When sharing a problem with team members, extract only the relevant logs.
  • Remove sensitive information (passwords, tokens) before sharing.

Troubleshooting

Logs not displayed

  • Pod in Pending state: Wait until the Pod is in Running state.
  • Container not outputting to stdout: Check application log settings.
  • Insufficient permissions: Check service operations permissions.

Connection dropped

  • Unstable network: Try refreshing or reopening the modal.
  • Session timeout: Log in again and retry.

Too many log entries

  • Use browser search: Use Ctrl+F to search for error keywords and narrow your scope.
  • Narrow time range: Focus on the time the issue occurred.

Best Practices

Here are some log analysis tips learned from experience.

Efficient Log Analysis

4 Steps of Log Analysis

Follow these steps in order to quickly identify most problems.

  1. Check the most recent logs first: The most recent error is most likely the root cause.
  2. Trace error chains: Start from the first error and follow the chain of cascading errors.
  3. Use timestamps: Cross-reference issue timing with log timestamps to narrow down the scope.
  4. Understand the context: Read surrounding logs to understand the full situation.

Improving Log Quality (For Developers)

Good logs significantly reduce debugging time.

  1. Use appropriate log levels: Use ERROR, WARN, INFO, DEBUG appropriately for each situation.
  2. Structured logs: Output in JSON format for easier parsing and searching.
  3. Include context: Include tracking information like request ID and user ID.
  4. Exclude sensitive information: Mask passwords and tokens to maintain security.
Sensitive Information Warning

Make sure logs don't contain passwords, API keys, or personal information. Logs can be viewed by many people.