Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Using Grafana and ClickHouse for Observability
Grafana represents the preferred visualization tool for Observability data in ClickHouse. This is achieved using the official ClickHouse plugin for Grafana. You can follow the installation instructions found here. V4 of the plugin makes logs and traces a first-class citizen in a new query builder experience. This minimizes the need for SREs to write SQL queries and simplifies SQL-based Observability, moving the needle forward for this emerging paradigm. Part of this has been placing OpenTelemetry (OTel) at the core of the plugin, as we believe this will be the foundation of SQL-based Observability over the coming years and how data will be collected.OpenTelemetry Integration
On configuring a ClickHouse datasource in Grafana, the plugin allows the user to specify a default database and table for logs and traces and whether these tables conform to the OTel schema. This allows the plugin to return the columns required for correct log and trace rendering in Grafana. If you’ve made changes to the default OTel schema and prefer to use your own column names, these can be specified. Usage of the default OTel column names for columns such as time (Timestamp), log level (SeverityText), or message body (Body) means no changes need to be made.
HTTP or NativeYou can connect Grafana to ClickHouse over either the HTTP or Native protocol. The latter offers marginal performance advantages which are unlikely to be appreciable in the aggregation queries issued by Grafana users. Conversely, the HTTP protocol is typically simpler for you to proxy and introspect.
Logs
If adhering to the Grafana requirements for logs, you can selectQuery Type: Log in the query builder and click Run Query. The query builder will formulate a query to list the logs and ensure they’re rendered e.g.
logs selected as the Query Type, the results will be rendered as logs. The required columns for log rendering are listed here.
Logs to traces
If logs contain trace Ids, you can benefit from being able to navigate through to a trace for a specific log line.Traces
Similar to the above logging experience, if the columns required by Grafana to render traces are satisfied (e.g., by using the OTel schema), the query builder is able to automatically formulate the necessary queries. By selectingQuery Type: Traces and clicking Run Query, a query similar to the following will be generated and executed (depending on your configured columns - the following assumes the use of OTel):
SQL Editor.
View trace details
As shown above, Trace ids are rendered as clickable links. On clicking on a trace Id, a user can choose to view the associated spans via the linkView Trace. This issues the following query (assuming OTel columns) to retrieve the spans in the required structure, rendering the results as a waterfall.
Note how the above query uses the materialized view
otel_traces_trace_id_ts to perform the trace id lookup. See Accelerating Queries - Using Materialized views for lookups for further details.Traces to logs
If logs contain trace ids, you can navigate from a trace to its associated logs. To view the logs click on a trace id and selectView Logs. This issues the following query assuming default OTel columns.
Dashboards
You can build dashboards in Grafana using the ClickHouse data source. We recommend the Grafana and ClickHouse data source documentation for further details, especially the concept of macros and variables. The plugin provides several out-of-the-box dashboards, including an example dashboard, “Simple ClickHouse OTel dashboarding,” for logging and tracing data conforming to the OTel specification. This requires users to conform to the default column names for OTel and can be installed from the data source configuration. We provide some simple tips for building visualizations below.Time series
Along with statistics, line charts are the most common form of visualization used in observability use cases. The Clickhouse plugin will automatically render a line chart if a query returns adatetime named time and a numeric column. For example:
Multi-line charts
Multi-line charts will be automatically rendered for a query provided the following conditions are met:- field 1: datetime field with an alias of time
- field 2: value to group by. This should be a String.
- field 3+: the metric values
Visualizing geo data
We have explored enriching observability data with geo coordinates using IP dictionaries in earlier sections. Assuming you havelatitude and longitude columns, observability can be visualized using the geohashEncode function. This produces geo hashes compatible with the Grafana Geo Map chart. An example query and visualization are shown below: