Kaiten
Guides

Feature Flag Targeting

Advanced CEL targeting rules, rollout strategies, and evaluation patterns.

Feature Flag Targeting Guide

This guide covers advanced feature flag patterns with CEL targeting, rollout strategies, and per-instance evaluation.

CEL Expression Language

Kaiten uses CEL (Common Expression Language) for targeting rules. CEL is a safe, fast expression language designed for policy evaluation.

Basic Comparisons

tenantSlug == "sakura-tokyo"
orderCount > 100
region != "eu-west"

Logical Operators

tenantSlug == "sakura-tokyo" && orderCount > 10
region == "us-east" || region == "us-west"
!(tenantSlug == "demo-tenant")

List Membership

region in ["us-east", "us-west", "eu-west"]

String Functions

tenantSlug.startsWith("test-")
tenantSlug.endsWith("-production")
tenantSlug.contains("demo")

Rollout Strategies

Gradual Rollout

Use percentage-based rollout for the default variant to gradually enable a feature:

{
  "defaultVariant": {
    "type": "rolloutPercentage",
    "value": {
      "rolloutPercentage": {
        "distribution": {"on": 10, "off": 90}
      }
    }
  }
}

Increase the percentage over time: 10% → 25% → 50% → 100%.

Canary Deployment

Combine targeting + rollout:

  1. Targeting rule: tenantSlug == "internal-test"on (always on for your test tenant)
  2. Default variant: 5% rollout to on (canary for everyone else)

Feature Kill Switch

Set default to off with no targeting rules. Enable for specific tenants as needed.

Per-Instance Evaluation

When evaluating flags, pass the instance tenantSlug as a context variable:

{
  "context": {
    "tenantSlug": "sakura-tokyo",
    "orderCount": 42
  }
}

This scopes the evaluation to that specific tenant, allowing per-customer feature control.

Rule Ordering

Targeting rules are evaluated in order — the first matching rule determines the variant. Order your rules from most specific to least specific:

  1. tenantSlug == "vip-customer"premium
  2. region == "us-east"beta
  3. Default → off

On this page