tinybird-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tinybird Deployment Skill

Tinybird 部署技能

Deploy observability pipes and datasources to Tinybird Cloud.
将可观测性管道和数据源部署到Tinybird Cloud。

Requirements

前提条件

  • tb CLI: Install with
    curl -sSL https://tinybird.co | bash
    or
    pip install tinybird-cli
  • Must run from
    enter.pollinations.ai/observability
    directory
  • Authenticated to Tinybird (run
    tb login
    if needed)
  • tb CLI:通过
    curl -sSL https://tinybird.co | bash
    pip install tinybird-cli
    安装
  • 必须在
    enter.pollinations.ai/observability
    目录下运行
  • 已通过Tinybird身份验证(如有需要请运行
    tb login

Workspace Info

工作区信息

PropertyValue
Workspace
pollinations_enter
Region
gcp-europe-west2
UIhttps://cloud.tinybird.co/gcp/europe-west2/pollinations_enter
属性
工作区
pollinations_enter
区域
gcp-europe-west2
界面https://cloud.tinybird.co/gcp/europe-west2/pollinations_enter

Directory Structure

目录结构

enter.pollinations.ai/observability/
├── datasources/       # Data source definitions (.datasource)
│   ├── generation_event.datasource
│   ├── polar_event.datasource
│   ├── stripe_event.datasource
│   └── ...
└── endpoints/         # Pipe definitions (.pipe)
    ├── weekly_usage_stats.pipe
    ├── weekly_active_users.pipe
    ├── daily_stripe_revenue.pipe
    └── ...

enter.pollinations.ai/observability/
├── datasources/       # 数据源定义文件(.datasource)
│   ├── generation_event.datasource
│   ├── polar_event.datasource
│   ├── stripe_event.datasource
│   └── ...
└── endpoints/         # 管道定义文件(.pipe)
    ├── weekly_usage_stats.pipe
    ├── weekly_active_users.pipe
    ├── daily_stripe_revenue.pipe
    └── ...

Commands

命令

Step 1: Validate (Dry Run)

步骤1:验证(试运行)

Always validate before deploying:
bash
cd enter.pollinations.ai/observability
tb --cloud deploy --check --wait
This shows exactly what will change without deploying. Safe to run anytime.
Example output:
| status   | name                  | type     | path                                 |
|----------|-----------------------|----------|--------------------------------------|
| modified | weekly_usage_stats    | endpoint | endpoints/weekly_usage_stats.pipe    |
部署前请务必先验证:
bash
cd enter.pollinations.ai/observability
tb --cloud deploy --check --wait
该命令会显示所有即将发生的变更,但不会实际部署,可随时安全运行。
示例输出:
| status   | name                  | type     | path                                 |
|----------|-----------------------|----------|--------------------------------------|
| modified | weekly_usage_stats    | endpoint | endpoints/weekly_usage_stats.pipe    |

Step 2: Deploy

步骤2:部署

If validation passes:
bash
tb --cloud deploy --wait
验证通过后执行部署:
bash
tb --cloud deploy --wait

Step 3: Verify

步骤3:验证部署结果

Test the deployed pipe:
bash
undefined
测试已部署的管道:
bash
undefined

Get Tinybird token from secrets

从密钥中获取Tinybird令牌

TINYBIRD_TOKEN=$(sops -d ../kpi/secrets/env.json | jq -r '.TINYBIRD_TOKEN')
TINYBIRD_TOKEN=$(sops -d ../kpi/secrets/env.json | jq -r '.TINYBIRD_TOKEN')

Test the pipe

测试管道

curl -s "https://api.europe-west2.gcp.tinybird.co/v0/pipes/weekly_usage_stats.json?weeks_back=12"
-H "Authorization: Bearer $TINYBIRD_TOKEN" | jq '.data | length'

---
curl -s "https://api.europe-west2.gcp.tinybird.co/v0/pipes/weekly_usage_stats.json?weeks_back=12"
-H "Authorization: Bearer $TINYBIRD_TOKEN" | jq '.data | length'

---

Safety Features

安全特性

FlagDescription
--check
Validates without making changes (dry run)
--wait
Waits for deployment to complete
--no-allow-destructive-operations
Prevents removing datasources (default)
--allow-destructive-operations
Required to delete datasources

标志描述
--check
仅验证变更,不实际执行(试运行)
--wait
等待部署完成
--no-allow-destructive-operations
防止删除数据源(默认开启)
--allow-destructive-operations
删除数据源时必须使用该标志

Common Tasks

常见任务

Add a New Pipe

添加新管道

  1. Create
    .pipe
    file in
    endpoints/
  2. Validate:
    tb --cloud deploy --check --wait
  3. Deploy:
    tb --cloud deploy --wait
  1. endpoints/
    目录下创建
    .pipe
    文件
  2. 验证:
    tb --cloud deploy --check --wait
  3. 部署:
    tb --cloud deploy --wait

Modify Existing Pipe

修改现有管道

  1. Edit the
    .pipe
    file
  2. Validate:
    tb --cloud deploy --check --wait
  3. Deploy:
    tb --cloud deploy --wait
  1. 编辑对应的
    .pipe
    文件
  2. 验证:
    tb --cloud deploy --check --wait
  3. 部署:
    tb --cloud deploy --wait

View Pipe in UI

在界面中查看管道

Troubleshooting

故障排除

"tb: command not found"

"tb: command not found"

bash
curl -sSL https://tinybird.co | bash
bash
curl -sSL https://tinybird.co | bash

Or

或者

pip install tinybird-cli
undefined
pip install tinybird-cli
undefined

"Not authenticated"

"未通过身份验证"

bash
tb login
bash
tb login

Follow prompts to authenticate

按照提示完成身份验证

undefined
undefined

Pipe Timeout Issues

管道超时问题

If a pipe times out with large
weeks_back
:
  • Use
    uniq()
    instead of
    uniqExact()
    for user counts (~10x faster)
  • Avoid CTE + JOIN patterns - use single-pass queries
  • Consider materialized views for expensive aggregations

如果设置较大的
weeks_back
时管道超时:
  • 统计用户数量时使用
    uniq()
    替代
    uniqExact()
    (速度提升约10倍)
  • 避免使用CTE + JOIN模式,采用单遍查询
  • 考虑为高开销的聚合操作使用物化视图

Important Notes

重要注意事项

  • Always use
    --cloud
    : Without it, CLI tries to use Tinybird Local (Docker)
  • Do NOT use
    tb push
    : It's deprecated, use
    tb --cloud deploy
  • Run from observability directory: Not from repo root
  • 务必使用
    --cloud
    标志
    :如果省略,CLI会尝试连接Tinybird Local(Docker环境)
  • 请勿使用
    tb push
    :该命令已被弃用,请使用
    tb --cloud deploy
  • 必须在observability目录下运行:不要从仓库根目录执行