创建错误采集规则
curl --request POST \
--url 'https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"application_id": "WoyQQ3BohkdtPivubEvE8o",
"description": "Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.",
"filters": [
[
{
"key": "error.error_message",
"oper": "IN",
"vals": [
"Script error.",
"ResizeObserver loop*"
]
}
],
[
{
"key": "error.view_url",
"oper": "IN",
"vals": [
"https://example.com/debug/*"
]
}
]
],
"rule_name": "Ignore browser noise"
}
'import requests
url = "https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key="
payload = {
"application_id": "WoyQQ3BohkdtPivubEvE8o",
"description": "Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.",
"filters": [[
{
"key": "error.error_message",
"oper": "IN",
"vals": ["Script error.", "ResizeObserver loop*"]
}
], [
{
"key": "error.view_url",
"oper": "IN",
"vals": ["https://example.com/debug/*"]
}
]],
"rule_name": "Ignore browser noise"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
application_id: 'WoyQQ3BohkdtPivubEvE8o',
description: 'Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.',
filters: [
[
{
key: 'error.error_message',
oper: 'IN',
vals: ['Script error.', 'ResizeObserver loop*']
}
],
[{key: 'error.view_url', oper: 'IN', vals: ['https://example.com/debug/*']}]
],
rule_name: 'Ignore browser noise'
})
};
fetch('https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'application_id' => 'WoyQQ3BohkdtPivubEvE8o',
'description' => 'Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.',
'filters' => [
[
[
'key' => 'error.error_message',
'oper' => 'IN',
'vals' => [
'Script error.',
'ResizeObserver loop*'
]
]
],
[
[
'key' => 'error.view_url',
'oper' => 'IN',
'vals' => [
'https://example.com/debug/*'
]
]
]
],
'rule_name' => 'Ignore browser noise'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key="
payload := strings.NewReader("{\n \"application_id\": \"WoyQQ3BohkdtPivubEvE8o\",\n \"description\": \"Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.\",\n \"filters\": [\n [\n {\n \"key\": \"error.error_message\",\n \"oper\": \"IN\",\n \"vals\": [\n \"Script error.\",\n \"ResizeObserver loop*\"\n ]\n }\n ],\n [\n {\n \"key\": \"error.view_url\",\n \"oper\": \"IN\",\n \"vals\": [\n \"https://example.com/debug/*\"\n ]\n }\n ]\n ],\n \"rule_name\": \"Ignore browser noise\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"application_id\": \"WoyQQ3BohkdtPivubEvE8o\",\n \"description\": \"Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.\",\n \"filters\": [\n [\n {\n \"key\": \"error.error_message\",\n \"oper\": \"IN\",\n \"vals\": [\n \"Script error.\",\n \"ResizeObserver loop*\"\n ]\n }\n ],\n [\n {\n \"key\": \"error.view_url\",\n \"oper\": \"IN\",\n \"vals\": [\n \"https://example.com/debug/*\"\n ]\n }\n ]\n ],\n \"rule_name\": \"Ignore browser noise\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"application_id\": \"WoyQQ3BohkdtPivubEvE8o\",\n \"description\": \"Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.\",\n \"filters\": [\n [\n {\n \"key\": \"error.error_message\",\n \"oper\": \"IN\",\n \"vals\": [\n \"Script error.\",\n \"ResizeObserver loop*\"\n ]\n }\n ],\n [\n {\n \"key\": \"error.view_url\",\n \"oper\": \"IN\",\n \"vals\": [\n \"https://example.com/debug/*\"\n ]\n }\n ]\n ],\n \"rule_name\": \"Ignore browser noise\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"rule_id": "9spXEVoMeZWujjz25yrgTe",
"rule_name": "Ignore browser noise"
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "InvalidParameter",
"message": "The specified parameter is not valid."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "AccessDenied",
"message": "Access Denied."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}错误采集规则
创建错误采集规则
创建一条错误采集规则:命中的错误不再归入任何问题(Issue),但仍会照常入库。
POST
/
rum
/
error-ingestion
/
rules
/
create
创建错误采集规则
curl --request POST \
--url 'https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"application_id": "WoyQQ3BohkdtPivubEvE8o",
"description": "Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.",
"filters": [
[
{
"key": "error.error_message",
"oper": "IN",
"vals": [
"Script error.",
"ResizeObserver loop*"
]
}
],
[
{
"key": "error.view_url",
"oper": "IN",
"vals": [
"https://example.com/debug/*"
]
}
]
],
"rule_name": "Ignore browser noise"
}
'import requests
url = "https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key="
payload = {
"application_id": "WoyQQ3BohkdtPivubEvE8o",
"description": "Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.",
"filters": [[
{
"key": "error.error_message",
"oper": "IN",
"vals": ["Script error.", "ResizeObserver loop*"]
}
], [
{
"key": "error.view_url",
"oper": "IN",
"vals": ["https://example.com/debug/*"]
}
]],
"rule_name": "Ignore browser noise"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
application_id: 'WoyQQ3BohkdtPivubEvE8o',
description: 'Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.',
filters: [
[
{
key: 'error.error_message',
oper: 'IN',
vals: ['Script error.', 'ResizeObserver loop*']
}
],
[{key: 'error.view_url', oper: 'IN', vals: ['https://example.com/debug/*']}]
],
rule_name: 'Ignore browser noise'
})
};
fetch('https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'application_id' => 'WoyQQ3BohkdtPivubEvE8o',
'description' => 'Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.',
'filters' => [
[
[
'key' => 'error.error_message',
'oper' => 'IN',
'vals' => [
'Script error.',
'ResizeObserver loop*'
]
]
],
[
[
'key' => 'error.view_url',
'oper' => 'IN',
'vals' => [
'https://example.com/debug/*'
]
]
]
],
'rule_name' => 'Ignore browser noise'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key="
payload := strings.NewReader("{\n \"application_id\": \"WoyQQ3BohkdtPivubEvE8o\",\n \"description\": \"Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.\",\n \"filters\": [\n [\n {\n \"key\": \"error.error_message\",\n \"oper\": \"IN\",\n \"vals\": [\n \"Script error.\",\n \"ResizeObserver loop*\"\n ]\n }\n ],\n [\n {\n \"key\": \"error.view_url\",\n \"oper\": \"IN\",\n \"vals\": [\n \"https://example.com/debug/*\"\n ]\n }\n ]\n ],\n \"rule_name\": \"Ignore browser noise\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"application_id\": \"WoyQQ3BohkdtPivubEvE8o\",\n \"description\": \"Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.\",\n \"filters\": [\n [\n {\n \"key\": \"error.error_message\",\n \"oper\": \"IN\",\n \"vals\": [\n \"Script error.\",\n \"ResizeObserver loop*\"\n ]\n }\n ],\n [\n {\n \"key\": \"error.view_url\",\n \"oper\": \"IN\",\n \"vals\": [\n \"https://example.com/debug/*\"\n ]\n }\n ]\n ],\n \"rule_name\": \"Ignore browser noise\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/rum/error-ingestion/rules/create?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"application_id\": \"WoyQQ3BohkdtPivubEvE8o\",\n \"description\": \"Keep cross-origin script errors, ResizeObserver warnings, and debug pages out of issues.\",\n \"filters\": [\n [\n {\n \"key\": \"error.error_message\",\n \"oper\": \"IN\",\n \"vals\": [\n \"Script error.\",\n \"ResizeObserver loop*\"\n ]\n }\n ],\n [\n {\n \"key\": \"error.view_url\",\n \"oper\": \"IN\",\n \"vals\": [\n \"https://example.com/debug/*\"\n ]\n }\n ]\n ],\n \"rule_name\": \"Ignore browser noise\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"rule_id": "9spXEVoMeZWujjz25yrgTe",
"rule_name": "Ignore browser noise"
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "InvalidParameter",
"message": "The specified parameter is not valid."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "AccessDenied",
"message": "Access Denied."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}{
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
},
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
}限制说明
| 项目 | 说明 |
|---|---|
| 速率限制 | 每个账户 300 次/分钟;20 次/秒 |
| 权限要求 | 无 —— 持有有效的 app_key 即可调用 |
使用说明
- 命中的错误仍会入库、可正常查询,只是不会被归入任何问题,且其
issue_grouping_excluded字段为true。 - 规则匹配的是 SDK 上报的原始错误类型和错误信息,发生在服务端解析堆栈之前。
filters中每个条件的 key 必须是受支持的error.*字段或context.*路径;key 不受支持、操作符无效、vals为空,或正则/CIDR/数值模式无效时,返回InvalidParameter。- 新建规则的初始状态为
enabled;如需创建后即处于停用状态,需再调用一次disable。 - 每次写操作都会先把应用变更前的完整规则集合保存为一个新的历史版本。
- 采集端按应用缓存已启用的规则,缓存有效期 5 秒,因此变更最多约 5 秒后对新上报的错误生效。
- 需要对该应用有编辑权限(账户所有者或管理员、应用创建者、应用所属团队的成员),否则返回
AccessDenied;application_id不存在时返回ResourceNotFound。 - 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。
授权
请求体
application/json
创建错误采集规则的入参。
此页面对您有帮助吗?