- Familiarity with ClickHouse config files
- A running instance of ClickHouse server
- (Optional) A running local Grafana instance
1
Check that opentelemetry_span_log system table is enabled
If you have not made any modifications to the Make sure that it is not commented out, or else you won’t be able to see
opentelemetry_span_log section of config.xml you can skip this step.Open your default ClickHouse config.xml file and find the following section:system.opentelemetry_span_log in the following steps.
This can also be the case if your ClickHouse server is not using the default configuration file.Check your server logs for something like:2
Enable OpenTelemetry tracing
With your ClickHouse server running, open ClickHouse client and enable trace collection using the following query:You should now see the Next run:This sets the probability that the ClickHouse can start a trace for executed queries, where
opentelemetry_span_log system table if you run:1 means that the trace is enabled for all executed queries.3
Obtain a query ID
Run the following dummy query, or the query you are interested in tracing:Copy the query id:
4
Generate a trace file
Run the following query, substituting in the query ID you obtained in the previous step:This will write the trace to a file named
trace.json.
By default, this file is created in the current working directory from which you are running the clickhouse-client or clickhouse-local tool.5
Visualize trace using built-in tooling
Use the hosted trace visualizer at https://trace-visualizer.clickhouse.com/.
Load the
trace.json file from the previous step to visualize the trace.6
Using Grafana to visualize traces
We recommend Grafana for visualizing and exploring trace data using the official ClickHouse plugin.
The plugin has been enhanced to allow visualization of traces using the Trace Panel.
This is supported as both a visualization and as a component in Explore.Follow the steps described in “Using Grafana and ClickHouse for Observability”
to set up Grafana with the ClickHouse plugin.From the Explore tab you can then run the following query, replacing the Make sure to set
trace_id with your own:Query type to Traces:Click “Run Query” and inspect the trace diagram: