All Products
Search
Document Center

Cloud Monitor:Correlate business logs with trace IDs in Go

Last Updated:Sep 04, 2026

Enrich your Go application's business logs with trace IDs so that you can quickly locate related logs when issues occur and speed up troubleshooting.

Prerequisites

  • You have compiled and deployed your application with the ARMS agent for Go.

  • You have configured log collection using Simple Log Service. For more information, see Data collection overview.

Background

Application Real-Time Monitoring Service (ARMS) correlates trace IDs with business logs in Go microservices by instrumenting logging frameworks. The following table lists the supported frameworks.

Component

Repository address

Minimum version

Maximum version

Zerolog

https://github.com/rs/zerolog

v1.10.0

v1.33.0

Zap

https://github.com/uber-go/zap

v1.20.0

v1.27.0

Logrus

https://github.com/sirupsen/logrus

v1.5.0

v1.9.3

Log

https://pkg.go.dev/log

v1.21

No limit

Slog

https://pkg.go.dev/log/slog

v1.21

No limit

Enable log and trace correlation

  1. Log on to the ARMS console. In the left-side navigation pane, choose Application Monitoring > Application List.

  2. On the Application List page, select the region in the top navigation bar and then click the name of the application.

    Note

    Icons in the Language column have the following meanings:

    • Java icon: a Java application connected to Application Monitoring.

    • image: a Golang application connected to Application Monitoring.

    • image: a Python application connected to Application Monitoring.

    • -: an application connected to Managed Service for OpenTelemetry.

  3. In the top navigation bar, choose Application Configuration > Custom Configuration.

  4. On the Custom Configurations tab, in the Application Log Association section, select Simple Log Service as the log source, turn on the Associate Business Logs with Trace ID switch, select the service region, and then bind the Project and Logstore.

    Set Correlation Type to Logstore or StoreView, configure the Correlation Index (both full-text index and field-specific indexes are supported), and then click Save.

  5. If the trace ID is successfully printed in your application's business logs as shown in the following example, the correlation is successful.

    2024/12/09 11:14:39  trace_id=0c74ce6d96528xxx  2 span_id=ae73xxx cedbrequest to mongon server
    $$$$$$$$$$$$$$
    map[Content-Length:[20] Content-Type:[text/plain; charset=utf-8] Date:[Mon, 09 Dec 2024 03:14:39 GMT] Eagleeye-Traceid:[0c74ce6d96528cxxx 2]]
    $$$$$$$$$$$$$$
  6. (Optional) Configure log collection in Simple Log Service to upload application logs to the project and Logstore you bound in a previous step.

    By default, ARMS does not collect application logs.

    12-09 10:43:38  10.36.45.83  cn-hangzhou.xxx.83  1733712219  k8s-group-c7ab2784bd...d17fa  c7ab2784bd8a84020b05...d17fa  xxx.101  ad-recommend-server
    registry.cn-hangzhou...erver  insights  xxx.83  cn-hangzhou.xxx.83  ad-recommend-server-...bc6xn  65c79c55-9e04-469f-9...9d636
    _source_: stderr
    _time_: 2024-12-09T10:43:38.366744191+08:00
    content: 2024/12/09 10:43:38  trace_id=cf6281bdde61f7xxx7dd span_id=7fc65xxx72e[grpc] SayHello message:"Hello Hello"