Skip to main content

Jaeger

Enable Jaeger support in CnosDB

Uncomment the [trace] configuration to enable Jaeger tracing.

Tip: You need to restart the server for the configuration to take effect.

[trace]
auto_generate_span = false
[trace.log]
path = '/tmp/cnosdb'
[trace.jaeger]
jaeger_agent_endpoint = 'http://127.0.0.1:14268/api/traces'
max_concurrent_exports = 2
max_queue_size = 4096

Deploy and Start Jaeger

Other methods of deployment, please refer to Jaeger Deployment.

docker run -d --name jaeger \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 16686:16686 \
-p 14268:14268 \
jaegertracing/all-in-one:latest

When you start Jaeger successfully, visit http://127.0.0.1:16686.

jaeger

Trace CnosDB with Jaeger

  1. Add span context to the request header.

It can be automatically generated by setting auto_generate_span = true in the config file, and if you need to analyze a specific statement, you can customize the uber-trace-id value in the request, in the following format (refer to the format for more details: Propagation Format).

uber-trace-id: 3a3a43:432e345:0:1

Example:

The data source in the example: https://docs.cnosdb.com/zh/latest/start/quick_start.html

Query the air table in the database oceanic_station and sort the data in reverse order, returning the first 5 data.

curl -i -u "root:" -H "Accept: application/json" -H "uber-trace-id: 3a3a43:432e345:0:1" -XPOST "http://127.0.0.1:8902/api/v1/sql?db=oceanic_station&pretty=true" -d "select * from air order by time desc limit 5;"

Use the Dashboard for Analysis

jaeger_dashboard

  1. Record Span:

When a client application sends a query or write request to the CnosDB database, CnosDB sends the resulting Span record to Jaeger. Each span represents a phase of the request and includes the processing time, operation name, and other relevant information.

  1. Select Service:

In the Service drop-down box of the Jaeger user interface, select the service related to CnosDB (for example: cnosdb_singleton_1001).

  1. Find Traces:

On the interface, click the "Find Traces" button and the system will retrieve all traces associated with the selected service. This will display a list of requests and corresponding spans.

  1. Analyze Trace details:

Click the trace of interest to enter the detailed view. In this view, you'll see the flow of the request and the time each span takes to execute. This timing information will help you understand how long each step of the query takes to process.

  1. Optimize queries and systems:

With detailed timing logs, you can accurately analyze the performance of your query. In a production environment, this can be a valuable tool for optimizing queries and improving system performance. By analyzing the execution time of each span, you can find the steps that may be causing delays, so you can take targeted optimization actions.

In addition to this, Jaeger can track other events for CnosDB, check out: ISSUE 1272