POST /api/v1/streams
streams.create。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 可包含字母、数字、_、- 与 .。名称 _molesignal 为保留名称。 |
stream_type | string | 是 | logs、metrics、traces、profiles 或 extend。 |
fields | array | 否 | 字段定义,见下文。 |
retention_days | integer | 否 | 1 到 3650。省略则使用 设置 → 数据保留 中的平台默认值。 |
settings | object | 否 | description、queryable 等数据流设置,参见编辑保留期与设置。 |
| 属性 | 类型 | 说明 |
|---|---|---|
name | string | 字段名称。 |
data_type | string | bool、int64、float64、utf8、timestamp 或 json。 |
nullable | boolean | 默认 true。 |
indexed | boolean | 启用索引。 |
index_type | string | none、exact、full_text、bloom 或 skip。indexed 为 true 且省略 index_type 时,文本字段使用 full_text,其他字段使用 skip。 |
encrypted | boolean | 对字段做静态加密,之后无法修改,参见数据流。 |
curl -X POST http://localhost:5080/api/v1/streams \
-H "authorization: Bearer $MS_JWT" \
-H 'content-type: application/json' \
-d '{
"name": "app",
"stream_type": "logs",
"fields": [
{ "name": "trace_id", "data_type": "utf8", "nullable": true,
"indexed": true, "index_type": "exact", "encrypted": false }
],
"retention_days": 30
}'
{
"id": "3KE0ot1NtfCTJ3V3XxBNbqx9Y62",
"org_id": "<organization-id>",
"name": "app",
"stream_type": "logs",
"schema": {
"fields": [
{ "name": "trace_id", "data_type": "utf8", "nullable": true, "index_type": "exact",
"indexed": true, "encrypted": false, "exact": true }
]
},
"retention": { "days": 30 },
"effective_retention": { "days": 30 },
"settings": {
"description": null,
"index_rules": [],
"queryable": true,
"field_masking": []
},
"created_at_micros": 1790000000000000,
"updated_at_micros": 1790000000000000
}
| 状态码 | 原因 |
|---|---|
403 | 名称为 _molesignal,或 Token 缺少 streams.create。 |
409 | 同名同类型的数据流已经存在。 |
422 | 请求体字段缺失或无效,例如未知的 data_type,响应为纯文本。 |