可观测性
错误捕获、事件追踪、指标与特性开关。
概览
https://api.infrai.cc/v1/observabilityAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/observability capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/observability/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"方法
observability.error.capture
捕获应用错误,可选标签。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
message | string | 必填 | 可读的错误消息。 |
code | string | 可选 | 可选的应用错误码。 |
stack | string | 可选 | 可选的堆栈跟踪。 |
tags | Record<string, string> | 可选 | 用于分组的键/值标签。 |
返回
{ ok, error_id }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/capture \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"exception": {"type": "ValueError", "message": "bad input", "stacktrace": "..."}, "level": "error"}'observability.metric.report
上报一个或多个指标点。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 必填 | 指标名称。 |
value | number | 必填 | 指标数值。 |
tags | Record<string, string> | 可选 | 用于分组的键/值标签。 |
返回
{ ok: boolean }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/metric/report \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "...", "value": 0, "type": "counter"}'observability.flag.is_enabled
为当前上下文评估特性开关。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 特性开关 key。 |
返回
{ enabled: boolean }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/flag/is_enabled/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.message
上报一条结构化错误或日志消息
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
text | string | 必填 | 消息正文 |
level | 'debug' | 'info' | 'warning' | 'error' | 'fatal' | 可选 | 级别:debug/info/warning/error/fatal |
tags | Record<string, string> | 可选 | 键值标签,便于过滤与分组 |
user_id | string | 可选 | 关联的用户 ID |
release | string | 可选 | 发布版本标识 |
environment | 'production' | 'staging' | 'development' | 可选 | 环境:production/staging/development |
idempotency_key | string | 可选 | 幂等键,用于避免重复写入 |
返回
CaptureResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/message \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "..."}'observability.error.list
分页列出捕获到的错误事件
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
filter | Record<string, unknown> | 可选 | 过滤条件(观测过滤 DSL) |
cursor | string | 可选 | 分页游标 |
limit | number | 可选 | 每页返回数量 |
返回
ErrorEventList示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/list \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.search
按关键词搜索错误事件
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
q | string | 必填 | 搜索关键词 |
filter | Record<string, unknown> | 可选 | 过滤条件(观测过滤 DSL) |
cursor | string | 可选 | 分页游标 |
limit | number | 可选 | 每页返回数量 |
返回
ErrorEventList示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/search \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.get
按事件 ID 获取错误事件详情
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
event_id | string | 必填 | 错误事件 ID |
返回
ErrorEvent示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/get/EVENT_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.groups
分页列出错误分组
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
status | 'unresolved' | 'resolved' | 'ignored' | 可选 | 按状态过滤:unresolved/resolved/ignored |
sort | 'count_desc' | 'last_seen_desc' | 'first_seen_desc' | 可选 | 排序方式:count_desc/last_seen_desc/first_seen_desc |
cursor | string | 可选 | 分页游标 |
limit | number | 可选 | 每页返回数量 |
返回
ErrorGroupList示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/groups \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.group_detail
获取错误分组的聚合详情
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_id | string | 必填 | 错误分组 ID |
返回
ErrorGroupDetail示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/group_detail/ERROR_GROUP_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.events
列出某错误分组下的事件
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_id | string | 必填 | 错误分组 ID |
cursor | string | 可选 | 分页游标 |
limit | number | 可选 | 每页返回数量 |
返回
ErrorEventList示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/events/ERROR_GROUP_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.resolve
将错误分组标记为已解决
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_id | string | 必填 | 错误分组 ID |
返回
ErrorGroup示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/resolve/ERROR_GROUP_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"error_group_id": "..."}'observability.error.unresolve
撤销错误分组的已解决状态
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_id | string | 必填 | 错误分组 ID |
返回
ErrorGroup示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/unresolve/ERROR_GROUP_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"error_group_id": "..."}'observability.error.ignore
将错误分组标记为忽略
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_id | string | 必填 | 错误分组 ID |
返回
ErrorGroup示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/ignore/ERROR_GROUP_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"error_group_id": "..."}'observability.error.delete
删除错误分组
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_id | string | 必填 | 错误分组 ID |
返回
DeleteResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/observability/error/delete/ERROR_GROUP_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.bulk
对多个错误分组批量执行操作
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
error_group_ids | string[] | 必填 | 目标错误分组 ID 列表 |
action | 'resolve' | 'unresolve' | 'ignore' | 'delete' | 必填 | 批量动作:resolve/unresolve/ignore/delete |
返回
ErrorBulkResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/bulk \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"error_group_ids": [], "action": "resolve"}'observability.error.export
导出错误数据
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
filter | Record<string, unknown> | 可选 | 过滤条件(观测过滤 DSL) |
format | 'json' | 'csv' | 可选 | 导出格式:json 或 csv |
返回
ErrorExportResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/error/export \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'observability.error.retention.get
查询错误数据保留期配置
返回
{ days, auto_export_before_cleanup, export_destination }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/error/retention/get \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.error.retention.set
设置错误数据保留期
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
days | number | 必填 | 保留天数 |
auto_export_before_cleanup | boolean | 可选 | 清理前是否自动导出 |
export_destination | string | 可选 | 导出目标地址 |
返回
{ days, auto_export_before_cleanup, export_destination }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X PUT https://api.infrai.cc/v1/observability/error/retention/set \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"days": 0}'observability.metric.batch
批量上报指标数据点
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
points | MetricPoint[] | 必填 | 指标数据点数组 |
idempotency_key | string | 可选 | 幂等键,用于避免重复写入 |
返回
MetricBatchResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/metric/batch \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"points": []}'observability.metric.query
查询指标时间序列
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 必填 | 指标名称 |
agg | 'p50' | 'p99' | 'sum' | 'avg' | 'count' | 必填 | 聚合方式:p50/p99/sum/avg/count |
tags | Record<string, string> | 可选 | 按标签过滤 |
window | string | 可选 | 聚合时间窗,如 5m、1h |
since | string | 可选 | 起始时间 |
until | string | 可选 | 结束时间 |
返回
MetricSeries示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/metric/query \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.log.ingest
批量摄取日志条目
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
entries | LogEntry[] | 必填 | 日志条目数组 |
idempotency_key | string | 可选 | 幂等键,用于避免重复写入 |
返回
AcceptedResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/log/ingest \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"entries": []}'observability.log.search
搜索日志
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
q | string | 可选 | 搜索关键词 |
filter | Record<string, unknown> | 可选 | 过滤条件(观测过滤 DSL) |
since | string | 可选 | 起始时间 |
until | string | 可选 | 结束时间 |
cursor | string | 可选 | 分页游标 |
limit | number | 可选 | 每页返回数量 |
返回
LogQueryResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/log/search \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.flag.set
创建或更新功能开关定义
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 功能开关键 |
description | string | 可选 | 功能开关描述 |
type | 'bool' | 'string' | 'number' | 'json' | 可选 | 取值类型:bool/string/number/json |
default_value | unknown | 可选 | 默认取值 |
rules | FlagRule[] | 可选 | 定向规则列表 |
rollout | RolloutConfig | 可选 | 灰度发布配置 |
tags | Record<string, string> | 可选 | 键值标签 |
enabled | boolean | 可选 | 是否启用 |
version | number | 可选 | 版本号,用于乐观并发控制 |
返回
Flag示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/flag/set \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "new_checkout", "type": "bool", "default_value": false, "description": "new checkout UX"}'observability.flag.list
分页列出功能开关
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
cursor | string | 可选 | 分页游标 |
limit | number | 可选 | 每页返回数量 |
include_archived | boolean | 可选 | 是否包含已归档开关 |
返回
FlagList示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/flag/list \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.flag.get
获取功能开关定义
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 功能开关键 |
返回
Flag示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/flag/get/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.flag.get_value
在上下文下求值单个功能开关
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 功能开关键 |
user_id | string | 可选 | 求值上下文中的用户 ID |
context | Record<string, unknown> | 可选 | 求值上下文属性 |
default | unknown | 可选 | 求值失败时的兜底默认值 |
返回
FlagValue示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/flag/get_value/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.flag.get_all
在上下文下批量求值所有开关
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 可选 | 求值上下文中的用户 ID |
context | Record<string, unknown> | 可选 | 求值上下文属性 |
返回
FlagEvaluationMap示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/observability/flag/get_all \
-H "Authorization: Bearer $INFRAI_API_KEY"observability.flag.toggle
启用或禁用功能开关
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 功能开关键 |
enabled | boolean | 必填 | 目标启用状态 |
version | number | 必填 | 版本号,用于乐观并发控制 |
返回
Flag示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/flag/toggle/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "...", "enabled": true, "version": 0}'observability.flag.rollout
配置功能开关的灰度发布
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 功能开关键 |
percentage | number | 必填 | 灰度百分比(0-100) |
salt | string | 必填 | 哈希分桶用的盐值 |
sticky_unit | 'user_id' | 'session_id' | 'device_id' | 必填 | 黏滞维度:user_id/session_id/device_id |
version | number | 必填 | 版本号,用于乐观并发控制 |
variants | Variant[] | 可选 | 多变体配置列表 |
返回
Flag示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/observability/flag/rollout/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"key": "new_checkout", "rollout": {"percentage": 25, "salt": "v1", "sticky_unit": "user_id"}}'observability.flag.delete
删除功能开关
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
key | string | 必填 | 功能开关键 |
返回
DeleteResult示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/observability/flag/delete/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"全部能力
本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。
| 能力 | 端点 | 说明 |
|---|---|---|
observability.error.bulk | POST /v1/observability/error/bulk | Bulk-apply resolve/ignore/delete and other actions across multiple error groups. |
observability.error.capture | POST /v1/observability/error/capture | Capture an error event, aggregated into a group by fingerprint. |
observability.error.delete | DELETE /v1/observability/error/delete/{error_group_id} | Delete a specified error group. |
observability.error.events | GET /v1/observability/error/events/{error_group_id} | Page through all events within an error group. |
observability.error.export | POST /v1/observability/error/export | Export error data matching the filters (JSON or CSV). |
observability.error.get | GET /v1/observability/error/get/{event_id} | Get the details of one error event by event ID. |
observability.error.group_detail | GET /v1/observability/error/group_detail/{error_group_id} | Get the aggregated details of a specified error group. |
observability.error.groups | GET /v1/observability/error/groups | Page through error groups, with status filtering and sorting. |
observability.error.ignore | POST /v1/observability/error/ignore/{error_group_id} | Mark an error group as ignored. |
observability.error.list | GET /v1/observability/error/list | Page through captured error events, with filtering. |
observability.error.message | POST /v1/observability/error/message | Capture a structured error/log message (level, tags, user, release, environment). |
observability.error.resolve | POST /v1/observability/error/resolve/{error_group_id} | Mark an error group as resolved. |
observability.error.retention.get | GET /v1/observability/error/retention/get | Get the retention-period configuration for error data. |
observability.error.retention.set | PUT /v1/observability/error/retention/set | Set the retention period for error data, with auto-export before purge. |
observability.error.search | GET /v1/observability/error/search | Full-text search error events by keyword. |
observability.error.unresolve | POST /v1/observability/error/unresolve/{error_group_id} | Revert an error group's resolved status. |
observability.flag.delete | DELETE /v1/observability/flag/delete/{key} | Delete a feature flag permanently. |
observability.flag.get | GET /v1/observability/flag/get/{key} | Retrieve the full definition of a feature flag. |
observability.flag.get_all | GET /v1/observability/flag/get_all | Evaluate all feature flags at once for a given evaluation context. |
observability.flag.get_value | GET /v1/observability/flag/get_value/{key} | Evaluate a single feature flag's value for a given evaluation context. |
observability.flag.is_enabled | GET /v1/observability/flag/is_enabled/{key} | Check whether a feature flag is enabled for the current evaluation context. |
observability.flag.list | GET /v1/observability/flag/list | List feature flags with pagination, optionally including archived ones. |
observability.flag.rollout | POST /v1/observability/flag/rollout/{key} | Configure a percentage-based gradual rollout for a feature flag. |
observability.flag.set | POST /v1/observability/flag/set | Create or update a feature-flag definition. |
observability.flag.toggle | POST /v1/observability/flag/toggle/{key} | Enable or disable a feature flag with optimistic version checking. |
observability.log.ingest | POST /v1/observability/log/ingest | Ingest a batch of log entries. |
observability.log.search | GET /v1/observability/log/search | Search logs by keyword and time range. |
observability.metric.batch | POST /v1/observability/metric/batch | Report a batch of metric data points. |
observability.metric.query | GET /v1/observability/metric/query | Query a metric time series with aggregation. |
observability.metric.report | POST /v1/observability/metric/report | Report a single metric point (counter, gauge, timing, or distribution) with tags and idempotency. |
完整示例
本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at the console for a project key
# + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..." # from the console
# 2) observability.error.capture
curl -X POST https://api.infrai.cc/v1/observability/error/capture \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"exception": {"type": "ValueError", "message": "bad input", "stacktrace": "..."}, "level": "error"}'
# 3) observability.metric.report
curl -X POST https://api.infrai.cc/v1/observability/metric/report \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "...", "value": 0, "type": "counter"}'
# 4) observability.flag.is_enabled
curl -X GET https://api.infrai.cc/v1/observability/flag/is_enabled/KEY \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 5) observability.error.message
curl -X POST https://api.infrai.cc/v1/observability/error/message \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "..."}'
# 6) observability.error.list
curl -X GET https://api.infrai.cc/v1/observability/error/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 7) observability.error.search
curl -X GET https://api.infrai.cc/v1/observability/error/search \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) observability.error.get
curl -X GET https://api.infrai.cc/v1/observability/error/get/EVENT_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 9) observability.error.groups
curl -X GET https://api.infrai.cc/v1/observability/error/groups \
-H "Authorization: Bearer $INFRAI_API_KEY"