Search docs ⌘K
esc
Type to search across all documentation pages
Sketches

Sketches

Probabilistic analytics primitives for high-volume event streams. HyperLogLog estimates unique counts, and Count-Min Sketch estimates item frequencies without retaining the raw source data.

Approximate by design: Sketches trade exactness for throughput and tiny memory footprints. Use them for rolling analytics and ranking, not for reconstructing exact user lists or payload history.

Add HyperLogLog Elements

GET
typescript
await ss.infra.sketches.hll.add('visitors:2026-03-10', ['u_1', 'u_2', 'u_3'])
  1. Open Dashboard → Sketches and select your project
  2. Stay on the HyperLogLog tab and enter the sketch key
  3. Paste newline-separated or JSON-array elements, then click Add elements
Sketches are still key-driven structures, so the dashboard operates on the exact key you choose.

Estimate HyperLogLog Count

GET
typescript
const { count } = await ss.infra.sketches.hll.count('visitors:2026-03-10')
  1. Open Dashboard → Sketches and select your project
  2. Stay on the HyperLogLog tab and enter the sketch key
  3. Click Count to fetch the current approximate unique count
Counts are approximate and reflect the probabilistic nature of HyperLogLog.

Merge HyperLogLogs

GET
typescript
await ss.infra.sketches.hll.merge('visitors:week-11', [
  'visitors:2026-03-10',
  'visitors:2026-03-11',
])
  1. Open Dashboard → Sketches and select your project
  2. On the HyperLogLog tab, fill in the destination key and source keys
  3. Click Merge to roll multiple sketches into a new aggregate key
For repeatable rollups, move this same flow into Jobs or Workflows after validating it here.

Increment Count-Min Sketch

GET
typescript
await ss.infra.sketches.cms.increment('errors:daily', [
  { item: '429', count: 1 },
  { item: '500', count: 3 },
])
  1. Open Dashboard → Sketches and select your project
  2. Switch to the Count-Min Sketch tab and enter the sketch key
  3. Paste newline-separated item,count rows or a JSON array, then click Increment
Like Locks, sketches are key-driven, so there is no cross-project browser here.

Estimate Count-Min Sketch Frequency

GET
typescript
const estimate = await ss.infra.sketches.cms.estimate('errors:daily', '429')
// estimate.estimated_count
  1. Open Dashboard → Sketches and select your project
  2. Switch to the Count-Min Sketch tab and enter both the key and lookup item
  3. Click Estimate to fetch the current approximate frequency
The estimate is an upper bound, so use it for trends and ranking rather than exact source-of-truth counts.