Chapter 27Lesson 01~135 minutes

Server Logs, Monitoring, Health, Elasticsearch, and Operational Diagnostics: Core Concepts and Mental Model

Operate SonarQube from process-specific evidence: follow scanner reports through web, Compute Engine, database, search, and UI/API visibility instead of treating one green screen as whole-system health.

OperationsLogsCompute EngineMonitoringElasticsearch

Learning objectives

  • Trace scanner request/report → web/API → Compute Engine queue/task → database persistence → search indexing → UI/API visibility.
  • Map sonar.log, web.log, ce.log, es.log, access.log, and the deprecation log to the process or request layer they actually describe.
  • Distinguish server availability, global health, CE queue health, individual task status, project Quality Gate state, and search freshness.
  • Use api/system/health, api/system/status, CE APIs, and monitoring metrics with the correct authentication/permission boundary.
  • Explain why DEBUG/TRACE logging is a short diagnostic instrument rather than a permanent monitoring strategy.
  • Keep Elasticsearch and the SonarQube database inside their supported ownership boundaries—observe and recover them without direct state edits.

1. The practical problem: “the UI opens” is only one signal

Chapters 6 through 26 repeatedly separated scanner success, report upload, ceTaskId, Compute Engine completion, analysis result, Quality Gate, CI status, and provider decoration. Chapter 27 turns that evidence chain into an operating model for the server itself.

A browser can render the SonarQube home page while the Compute Engine queue is backed up. A scanner can print EXECUTION SUCCESS while its uploaded report later fails in Compute Engine. The database can accept web requests while the search engine is under disk pressure. A Quality Gate can remain green because it reflects the last completed analysis even though the newest task is pending or failed. Operational diagnosis therefore starts by naming the subsystem and timestamp, not by asking whether “SonarQube is up.”

revision + scanner context → report upload → ceTaskId / CE queue → DB persistence → Elasticsearch indexing → project measures/issues/gate → UI/API visibility

2. Mental model: one analysis crosses multiple owning processes

Analysis-to-visibility causality
              flowchart TD
                A["Scanner process"] -->|"analysis report"| B["Web server / API"]
                B --> C["CE queue"]
                C --> D["Compute Engine task"]
                D --> E[("SonarQube database")]
                D --> F["Embedded Elasticsearch"]
                E --> G["Project state"]
                F --> G
                G --> H["UI / Web API"]
                B -. "web.log" .-> L1["Process evidence"]
                D -. "ce.log" .-> L1
                F -. "es.log" .-> L1
                A -. "scanner log + report-task.txt" .-> L1
            

The scanner does local indexing/analyzer work and uploads a report. The web process receives HTTP/API traffic and interacts with the database/search layer for request handling. Compute Engine consumes queued background tasks and turns the uploaded report into persisted analysis state. Elasticsearch serves indexed/search-oriented views. If any transition fails, the later stage cannot be inferred from the earlier one.

3. Current server logs: identify the owner before reading noise

File Owning layer Typical evidence
sonar.log Main/bootstrap process Overall startup/shutdown and process-launch status; use child-process logs for detail.
web.log Web server Database connection/migration/reindexing, HTTP request processing, request-related database/search failures.
ce.log Compute Engine Background task execution, report processing, CE-side database/search failures, task IDs and timings.
es.log Embedded Elasticsearch Search startup, health-state changes, cluster/node/index operations, disk-watermark symptoms.
access.log HTTP access layer Inbound request path/status/timing metadata according to the configured pattern.
API deprecation log Web API compatibility Requests that still use deprecated endpoints or parameters—important before upgrades.

On ZIP installs the files live under <sonarqubeHome>/logs by default. Container deployments can preserve the same files on a mounted logs volume and may also expose stdout/stderr. Capture timestamps and the server’s time zone when correlating scanner, CI, container, database, and host logs.

4. Health, status, queue, and gate are different dimensions

api/system/status

Basic application lifecycle/status signal. Useful during startup, but not a substitute for CE/search/DB diagnostics.

api/system/health

Returns GREEN/YELLOW/RED global health. Current API requires Administer System or a configured system passcode.

CE activity/task

Shows whether a specific ceTaskId is PENDING, IN_PROGRESS, SUCCESS, FAILED, or canceled and whether queue latency is growing.

Quality Gate

Policy result for a completed analysis. It says nothing about a newer task that has not completed.

That distinction is essential during incidents: a GREEN system health response can coexist with one project’s failed CE task; a RED or YELLOW system signal can be unrelated to a project’s source code; and a green gate can simply be stale.

5. Metrics complement logs; they do not replace them

Current Community Build exposes OpenMetrics-formatted monitoring data at /api/monitoring/metrics. Monitoring authentication is intentionally separate from ordinary project API calls and can use the system passcode configured through sonar.web.systemPasscode/SONAR_WEB_SYSTEMPASSCODE. Kubernetes deployments can additionally expose CE/Web JMX metrics through the supported Prometheus integration.

Use metrics to answer how much and how often: queue depth/latency, JVM memory, CPU, disk, request rates, database pool pressure. Use logs and task records to answer which operation failed and why. A graph tells you when CE latency rose; ce.log and the failed task’s error detail tell you which report or dependency caused the incident.

6. Resource domains: three Java processes plus shared dependencies

Community Build has three main Java processes: Web, Compute Engine, and Elasticsearch. Each has independent memory behavior. The database is an external dependency in production, and the host/container adds CPU, RAM, file-descriptor, process/thread, and disk constraints.

Symptom First owning evidence Do not jump to
Slow UI/API web.log, access timings, web JVM/CPU, DB pool, search request errors Restarting CE or changing a Quality Gate
Growing analysis queue CE activity, ce.log, CE JVM/CPU, task duration distribution Increasing worker count before proving capacity/cause
Search errors/read-only indices es.log, disk usage, system health Direct Elasticsearch API/index edits
DB connection exhaustion web.log/ce.log, database metrics, HikariCP errors Deleting search data or changing project configuration
One failed project task ceTaskId, scanner context, task error details, ce.log Server-wide restart without evidence

7. Elasticsearch is embedded, owned state—not an operator playground

SonarQube uses embedded Elasticsearch as part of its application architecture. Treat it as SonarQube-owned state. Diagnose through es.log, supported health/monitoring surfaces, disk/IO evidence, and SonarSource recovery procedures. Do not “repair” a SonarQube incident by issuing arbitrary Elasticsearch cluster/index mutations or deleting search directories.

Current Sonar guidance documents disk watermarks: warnings begin before the critical threshold, and at roughly 95% used disk non-Data-Center installations can put indices into read-only mode. After freeing space, the supported non-DCE recovery includes restarting SonarQube so indices return to read/write. The safe causal sequence is preserve logs → prove disk pressure → free space safely → follow documented recovery → verify health.

8. DEBUG and TRACE are temporary diagnostic states

INFO is the default server log level. DEBUG adds advanced information and can include personal user information. TRACE includes very detailed SQL/Elasticsearch request information, can slow the server, and can grow logs rapidly. Current SonarQube lets an administrator change log level temporarily from Administration → System; that temporary choice resets at restart.

Evidence and privacy warning. Preserve the incident window before increasing verbosity. Set the narrowest process-specific level you need (app, web, ce, or es), bound the capture duration, restrict log access, and return to INFO immediately after reproduction. Never leave TRACE enabled as a substitute for monitoring.

9. Read-only inspection first

# Scanner-side identity
sonar-scanner --version
git rev-parse HEAD
cat .scannerwork/report-task.txt

# Public/basic lifecycle endpoint (availability depends on auth policy)
curl -fsS "$SONAR_HOST_URL/api/system/status"

# Admin/system-passcode health request; do not put the passcode in source.
curl -fsS -H "X-Sonar-Passcode: $SONAR_SYSTEM_PASSCODE" \
  "$SONAR_HOST_URL/api/system/health"

# Correlate one uploaded task with its server state.
curl -fsS -H "Authorization: Bearer $SONAR_API_TOKEN" \
  "$SONAR_HOST_URL/api/ce/task?id=$CE_TASK_ID"

# Container lab: preserve process-specific logs before changing anything.
docker cp sq-ch27:/opt/sonarqube/logs/. evidence/logs-before/

The goal is not to collect everything forever. The goal is to preserve the smallest evidence set that can prove ownership, timing, and causal order.

Knowledge check

A scanner reports EXECUTION SUCCESS but the project page does not update. Which state is missing?

Why can a green Quality Gate be stale during a CE incident?

Which log is the primary place for a failed background analysis task?

Is api/system/health an anonymous production health endpoint?

Why not fix an Elasticsearch symptom by editing indices directly?

Next lesson

Trace a successful and failed task end to end

Lesson 2 turns the process model into a disposable baseline, successful analysis, controlled failed-task experiment, and least-destructive recovery.

Official references and version notes

Version and compatibility note

Rechecked 2026-09-08. Mandatory examples target SonarQube Community Build 26.9.0.129388 and SonarScanner CLI 8.1.0.6389; the Maven failed-task fixture uses SonarScanner for Maven 5.7.0.6970. Current commercial reference is SonarQube Server 2026 Release 4.1 with 2026.1.5 LTA. Current Community Build logs are sonar.log, web.log, ce.log, es.log, access and API-deprecation logs. api/system/health requires Administer System or system passcode; /api/monitoring/metrics exposes OpenMetrics under its monitoring-auth boundary. Community Build has Web, CE and embedded Elasticsearch JVMs; production databases must use supported PostgreSQL/SQL Server/Oracle rather than the evaluation H2 database. The project/component key-clash failure is documented as a CE failure class, but exact scanner versions may prevalidate the conflict before upload; the lessons explicitly preserve that layer distinction rather than forcing unsafe database/search failures.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.