Categorygithub.com/nextrevision/jaeger-otel-clickhouse-backend
modulepackage
0.0.0-20240531210525-8d22dd162381
Repository: https://github.com/nextrevision/jaeger-otel-clickhouse-backend.git
Documentation: pkg.go.dev

# README

Jaeger OpenTelemetry Clickhouse Backend

Jaeger gRPC backend (v1) compatible with the OpenTelemetry Clickhouse exporter. It provides a way of visualizing trace data stored in Clickhouse via the Jaeger Query frontend.

Example trace from backend

Quickstart

Clone this repository and open a shell in the examples folder, then run:

docker-compose up

Access the Jaeger UI at http://localhost:16686.

On first load, there will be no traces, but that will cause the backend to create and send traces to the collector. On refresh, you should see the backend service in the UI.

Docker

Images are hosted on Docker Hub and can be run with:

docker run --rm -it -e JOCB_DB_HOST=127.0.0.1 -e JOCB_DB_PORT=9000 -p 14482:14482 nextrevision/jaeger-otel-clickhouse-backend:latest

Config

Can be set by YAML file and the -config flag or by environment variable with the JOCB prefix.

Env VarYAMLTypeRequiredDefaultExample
JOCB_DB_HOSTdb_hoststringtrue127.0.0.1
JOCB_DB_PORTdb_portinttrue9000
JOCB_DB_USERdb_userstringtruedefaulttest_user
JOCB_DB_PASSdb_passstringfalsetest_pass
JOCB_DB_NAMEdb_namestringtrueotelcustom_database
JOCB_DB_TABLEdb_tablestringtrueotel_tracestrace_data
JOCB_DB_CA_FILEdb_ca_filestringfalse/ca.crt
JOCB_DB_TLS_ENABLEDdb_tls_enabledboolfalsefalsetrue
JOCB_DB_TLS_INSECUREdb_tls_insecureboolfalsefalsetrue
JOCB_DB_MAX_OPEN_CONNSdb_max_open_connsintfalse10
JOCB_DB_MAX_IDLE_CONNSdb_max_idle_connsintfalse5
JOCB_DB_CONN_MAX_LIFETIME_MILLISdb_conn_max_lifetime_millisintfalse3000
JOCB_DB_CONN_MAX_IDLE_TIME_MILLISdb_conn_max_idle_time_millisintfalse1000
JOCB_ENABLE_TRACINGenable_tracingboolfalsefalsetrue
JOCB_PAD_TRACE_IDpad_trace_idboolfalsefalsetrue

Pad Trace ID

If your trace provider exports using the old 16 character trace ID, you can set this field to pad the trace ID with 16 additional "0"s. If you are unsure, check your Clickhouse database and see how traces are being stored. If there are trace IDs padded with 16 characters, this should be enabled.

Tracing

The backend has been instrumented with OpenTelemetry and can be configured to export traces via gRPC to an OTLP compatible endpoint. This can be enabled using the JOCB_ENABLE_TRACING=true environment variable and setting OTEL_EXPORTER_OTLP_ENDPOINT to the desired OTLP compatible address.

Tag Search Syntax

I took the liberty to enhance the tag search expressivity with wildcards and regex patterns.

Wildcards

In the "Tags" field, using a % character will result in a wildcard match using SQL LIKE grammar. The following is an example of a tag query and the resulting SQL:

# http.url=http%://duckduckgo.com
  
SELECT ... WHERE SpanAttributes['http.url'] LIKE 'http%://duckduckgo.com'

If you wish to use a literal %, then escape it as \\%.

Regex

In the "Tags" field, using the operator =~ character will result in a regex match using the Clickhouse match function. The following is an example of a tag query and the resulting SQL:

# http.url=~http://[duck]+go.com
  
SELECT ... WHERE match(SpanAttributes['http.url'], 'http://[duck]+go.com')

Development

Start the clickhouse, otelcol and jaeger-query services in the docker-compose example:

cd examples
docker-compose up -f docker-compose.dev.yml

Start a development server with the following environment variables:

JOCB_DB_HOST=127.0.0.1
JOCB_DB_PORT=19000
JOCB_ENABLE_TRACING=true
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317

# Packages

No description provided by the author