Skip to content
eliquious edited this page Jul 13, 2015 · 1 revision

Event Logs

Event logs are the core of KappaDB. They are replicated, immutable (although possibly expiring) logs of events inserted into the database. Logs can be distributed around the cluster based on the configured replication_factor and the clustering fields.

Each log has an associated type definition which can be updated over time as the data model changes.

CREATE LOG

CREATE LOG establishes a new event log in the cluster. The CREATE statement requires a type definition. Additional options can be provided to the data store upon creation. The clause CLUSTERED BY determines how the data is distributed across the cluster.

Specification

CREATE LOG <name> USING <typedef>
  [CLUSTERED BY <columns,>]
  [WITH OPTIONS <options>];

Examples


// This creates a new `voltage` event log using a previously defined type. This event log will be distributed around the cluster by the `deviceid`, `year` and `month` fields.
CREATE LOG voltages USING TYPE Voltage CLUSTERED BY deviceid, year, month;

// This example creates a new log for user login events clustered by a user id. We also provide additional log configuration options. Options are specified by using the `WITH OPTIONS` keywords. We specify a replication factor of 3 and an expiration of 1 day.
CREATE LOG user.logins USING TYPE LoginEvent CLUSTERED BY uuid WITH OPTIONS {
    replication_factor: 3,
    expiration: 24h
};