> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.crewai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cube Analytics

> Configuration for the Cube analytics engine.

Cube is the analytics engine used by CrewAI. It provides cost tracking, execution analytics, and provider usage metrics.

## Prerequisites

Before enabling Cube, ensure the following:

1. **Wharf must be enabled:** Wharf is enabled by default. If you disabled it with `wharf.enabled: false`, re-enable it for Cube to work. See [Wharf OTLP Trace Collector](/reference/chart-values/wharf).
2. **Object storage (recommended for production):** Cubestore needs persistent storage. See [Storage](#storage) below.

## Database

**With internal PostgreSQL (`postgres.enabled: true`):**

The Helm chart automatically creates and configures the Cube database during installation. No manual steps required.

**With external PostgreSQL (`postgres.enabled: false`):**

You must manually create the Cube database before enabling. The database name should match `cube.database` (default: `cube`).

```sql theme={null}
CREATE DATABASE cube;
GRANT ALL PRIVILEGES ON DATABASE cube TO your_db_user;
```

Cube requires the `postgres_fdw` extension. On most managed PostgreSQL services (AWS RDS, Google Cloud SQL, Azure) this extension is available by default. If your database administrator has restricted extension creation, they may need to run the following on the Cube database:

```sql theme={null}
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
```

## Storage

Cube automatically detects and reuses the storage backend already configured for your installation (`STORAGE_SERVICE`). No additional storage configuration is needed -- Cube stores its data under a `cubestore/` prefix in the same bucket or container.

| `STORAGE_SERVICE` | Detected backend     |
| ----------------- | -------------------- |
| `amazon`          | AWS S3               |
| `google`          | Google Cloud Storage |
| `microsoft`       | Azure Blob Storage   |

If you need to override the auto-detected backend, set `cube.cubestore.storage.type` explicitly to `"s3"`, `"gcs"`, or `"azure"`.

### Local PVC (Evaluation Only)

<Warning>
  **PVC-based storage is for evaluation and development only.**

  In Kubernetes, PersistentVolumeClaims with `ReadWriteOnce` access mode are bound to a single node. If the node is rescheduled or fails, cached data is lost and must be rebuilt. For production deployments, always use object storage.
</Warning>

To force local PVC storage instead of auto-detection:

```yaml theme={null}
cube:
  enabled: true
  cubestore:
    storage:
      type: "local"
    persistence:
      enabled: true
      size: "20Gi"
```

## Configuration

<ParamField path="cube.enabled" type="boolean" default="false">
  Enable or disable Cube.

  **Values:**

  * `true` - Deploy Cube (enables analytics)
  * `false` - Disable Cube (default)
</ParamField>

<ParamField path="cube.database" type="string" default="cube">
  Database name used by the Cube service.

  **Default:** `"cube"`

  **Must match:** When using external PostgreSQL, the database with this name must exist and be accessible by the application user.
</ParamField>

### Image

<ParamField path="cube.image.host" type="string" default="">
  Container registry hosting the Cube image.

  **Default:** `""` (empty) - Automatically uses `global.imageRegistry` value
</ParamField>

<ParamField path="cube.image.name" type="string" default="proxy/crewai/crewai/cube">
  Cube container image name.
</ParamField>

<ParamField path="cube.image.tag" type="string" default="0.1.0">
  Cube version to deploy.
</ParamField>

<ParamField path="cube.image.pullPolicy" type="string" default="IfNotPresent">
  Image pull policy.
</ParamField>

### Scaling

<ParamField path="cube.replicaCount" type="integer" default="1">
  Number of Cube API replicas.
</ParamField>

### Resources

<ParamField path="cube.resources" type="object">
  Resource limits and requests for the Cube API pod.

  **Defaults:**

  ```yaml theme={null}
  resources:
    limits:
      cpu: "2"
      memory: "3Gi"
    requests:
      cpu: "500m"
      memory: "1Gi"
  ```
</ParamField>

<ParamField path="cube.refreshWorker.resources" type="object">
  Resource limits and requests for the background worker pod.

  **Defaults:**

  ```yaml theme={null}
  refreshWorker:
    resources:
      limits:
        cpu: "2"
        memory: "6Gi"
      requests:
        cpu: "500m"
        memory: "2Gi"
  ```
</ParamField>

### Cubestore

<ParamField path="cube.cubestore.image.tag" type="string" default="v1.6.29">
  Cubestore version.
</ParamField>

<ParamField path="cube.cubestore.storage.type" type="string" default="">
  Storage backend override. When empty (default), auto-detected from `STORAGE_SERVICE`.

  **Values:**

  * `""` - Auto-detect from `STORAGE_SERVICE` (recommended)
  * `"s3"` - Force AWS S3
  * `"gcs"` - Force Google Cloud Storage
  * `"azure"` - Force Azure Blob Storage
  * `"local"` - Force local PVC storage
</ParamField>

<ParamField path="cube.cubestore.storage.remoteDir" type="string" default="cubestore">
  Path prefix within the storage bucket. Must NOT start with `/` — a leading slash causes S3 list-after-write failures.

  **Default:** `"cubestore"`
</ParamField>

<ParamField path="cube.cubestore.persistence.enabled" type="boolean" default="false">
  Enable PVC-based local storage. Only used when `storage.type` is empty. See the [storage warning](#local-pvc-evaluation-only) above.
</ParamField>

<ParamField path="cube.cubestore.persistence.size" type="string" default="10Gi">
  PVC storage size.
</ParamField>

<ParamField path="cube.cubestore.workers.replicas" type="integer" default="2">
  Number of Cubestore worker replicas.

  **Default:** `2` — Matches SaaS baseline. Increase for high query volume.
</ParamField>

<ParamField path="cube.cubestore.router.resources" type="object">
  Resource limits and requests for the Cubestore router.

  **Defaults:**

  ```yaml theme={null}
  router:
    resources:
      limits:
        cpu: "1"
        memory: "2Gi"
      requests:
        cpu: "250m"
        memory: "512Mi"
  ```
</ParamField>

<ParamField path="cube.cubestore.workers.resources" type="object">
  Resource limits and requests for each Cubestore worker.

  **Defaults:**

  ```yaml theme={null}
  workers:
    resources:
      limits:
        cpu: "1"
        memory: "2Gi"
      requests:
        cpu: "250m"
        memory: "512Mi"
  ```
</ParamField>

### Node Placement

<ParamField path="cube.nodeSelector" type="object" default="{}">
  Node selector labels for Cube pod placement.

  **Default:** `{}` (no node restrictions)
</ParamField>

## Examples

### Minimal

```yaml theme={null}
wharf:
  enabled: true

cube:
  enabled: true
```

### With Multiple Cubestore Workers

```yaml theme={null}
wharf:
  enabled: true

cube:
  enabled: true
  cubestore:
    workers:
      replicas: 2
```

### Disabled (Default)

```yaml theme={null}
cube:
  enabled: false
```
