Documentation
¶
Overview ¶
Package clickhouse implements observe.LogStore against a ClickHouse backend (the analytical optional sink). It lowers the Query AST to SQL (see sql.go) and writes via batched INSERT. It supports both the Core and Advanced capability tiers: raw SQL mode, percentiles on arbitrary fields, and high-cardinality field filters.
Hot fields (namespace, service, instance, node, level, stream) are promoted to typed columns; the remaining labels live in a Map(String, String) column and the raw line carries a token bloom-filter skip index. Unlike Loki, ClickHouse is local-disk-first, so long retention uses S3 *tiering* — a TTL move-to-volume against a server-configured storage policy (see schema.go).
Index ¶
- type Config
- type Store
- func (s *Store) Capabilities() observe.Capabilities
- func (s *Store) Close() error
- func (s *Store) EnsureSchema(ctx context.Context) error
- func (s *Store) Execute(ctx context.Context, q *observe.Query) (observe.ResultStream, error)
- func (s *Store) Health(ctx context.Context) error
- func (s *Store) Labels(ctx context.Context, sel observe.Selector) ([]observe.LabelValue, error)
- func (s *Store) Write(ctx context.Context, batch []observe.LogRecord) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DSN is the ClickHouse connection string
// (e.g. clickhouse://user:pass@host:9000/runesight).
DSN string
// Table is the target MergeTree table for log rows (default "logs").
Table string
// Database is the target database (default "runesight").
Database string
// DialTimeout bounds connection establishment. Zero uses the driver default.
DialTimeout time.Duration
// AutoMigrate runs EnsureSchema (CREATE DATABASE/TABLE) on first connect so
// the backend works zero-config. Operators who manage their own schema can
// leave it false.
AutoMigrate bool
// StoragePolicy is the server-configured ClickHouse storage policy that
// defines the hot (local) and cold (s3) volumes. Empty disables tiering and
// the move-to-volume TTL.
StoragePolicy string
// S3Volume is the volume name within StoragePolicy that aged parts move to
// (default "s3"). Only used when HotDays > 0.
S3Volume string
// HotDays moves parts older than this to the S3 volume. Zero keeps all parts
// on the hot disk.
HotDays int
// RetentionDays deletes parts older than this. Zero keeps data indefinitely.
RetentionDays int
}
Config configures the ClickHouse store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the ClickHouse-backed observe.LogStore.
func New ¶
New constructs a ClickHouse store. It does not dial; call Health (or any I/O method) to establish the connection lazily.
func (*Store) Capabilities ¶
func (s *Store) Capabilities() observe.Capabilities
Capabilities reports the ClickHouse capability handshake: Advanced tier (which implies Core). Enables the dashboard's SQL mode and advanced widgets.
func (*Store) EnsureSchema ¶
EnsureSchema creates the database and log table (idempotent). Safe to call at startup; AutoMigrate calls it lazily on first use.
func (*Store) Execute ¶
Execute lowers the AST to SQL and streams rows or samples. RawSQL is run verbatim (Advanced tier) with a generic column scan.