创建映射 API
curl --request POST \
--url 'https://api.flashcat.cloud/enrichment/mapping/api/create?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"api_name": "CMDB API",
"description": "Query CMDB for host metadata",
"url": "https://cmdb.example.com/api/lookup",
"headers": {
"X-Token": "mytoken"
},
"timeout": 2,
"retry_count": 1,
"insecure_skip_verify": false
}
'import requests
url = "https://api.flashcat.cloud/enrichment/mapping/api/create?app_key="
payload = {
"api_name": "CMDB API",
"description": "Query CMDB for host metadata",
"url": "https://cmdb.example.com/api/lookup",
"headers": { "X-Token": "mytoken" },
"timeout": 2,
"retry_count": 1,
"insecure_skip_verify": False
}
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({
api_name: 'CMDB API',
description: 'Query CMDB for host metadata',
url: 'https://cmdb.example.com/api/lookup',
headers: {'X-Token': 'mytoken'},
timeout: 2,
retry_count: 1,
insecure_skip_verify: false
})
};
fetch('https://api.flashcat.cloud/enrichment/mapping/api/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/enrichment/mapping/api/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([
'api_name' => 'CMDB API',
'description' => 'Query CMDB for host metadata',
'url' => 'https://cmdb.example.com/api/lookup',
'headers' => [
'X-Token' => 'mytoken'
],
'timeout' => 2,
'retry_count' => 1,
'insecure_skip_verify' => false
]),
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/enrichment/mapping/api/create?app_key="
payload := strings.NewReader("{\n \"api_name\": \"CMDB API\",\n \"description\": \"Query CMDB for host metadata\",\n \"url\": \"https://cmdb.example.com/api/lookup\",\n \"headers\": {\n \"X-Token\": \"mytoken\"\n },\n \"timeout\": 2,\n \"retry_count\": 1,\n \"insecure_skip_verify\": false\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/enrichment/mapping/api/create?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"api_name\": \"CMDB API\",\n \"description\": \"Query CMDB for host metadata\",\n \"url\": \"https://cmdb.example.com/api/lookup\",\n \"headers\": {\n \"X-Token\": \"mytoken\"\n },\n \"timeout\": 2,\n \"retry_count\": 1,\n \"insecure_skip_verify\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/enrichment/mapping/api/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 \"api_name\": \"CMDB API\",\n \"description\": \"Query CMDB for host metadata\",\n \"url\": \"https://cmdb.example.com/api/lookup\",\n \"headers\": {\n \"X-Token\": \"mytoken\"\n },\n \"timeout\": 2,\n \"retry_count\": 1,\n \"insecure_skip_verify\": false\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"api_id": "665f1a2b3c4d5e6f7a8b9c02",
"api_name": "CMDB API"
}
}{
"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."
}
}API 数据源
创建映射 API
登记一个外部 HTTP API,供富化规则调用以查询告警标签。
POST
/
enrichment
/
mapping
/
api
/
create
创建映射 API
curl --request POST \
--url 'https://api.flashcat.cloud/enrichment/mapping/api/create?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"api_name": "CMDB API",
"description": "Query CMDB for host metadata",
"url": "https://cmdb.example.com/api/lookup",
"headers": {
"X-Token": "mytoken"
},
"timeout": 2,
"retry_count": 1,
"insecure_skip_verify": false
}
'import requests
url = "https://api.flashcat.cloud/enrichment/mapping/api/create?app_key="
payload = {
"api_name": "CMDB API",
"description": "Query CMDB for host metadata",
"url": "https://cmdb.example.com/api/lookup",
"headers": { "X-Token": "mytoken" },
"timeout": 2,
"retry_count": 1,
"insecure_skip_verify": False
}
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({
api_name: 'CMDB API',
description: 'Query CMDB for host metadata',
url: 'https://cmdb.example.com/api/lookup',
headers: {'X-Token': 'mytoken'},
timeout: 2,
retry_count: 1,
insecure_skip_verify: false
})
};
fetch('https://api.flashcat.cloud/enrichment/mapping/api/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/enrichment/mapping/api/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([
'api_name' => 'CMDB API',
'description' => 'Query CMDB for host metadata',
'url' => 'https://cmdb.example.com/api/lookup',
'headers' => [
'X-Token' => 'mytoken'
],
'timeout' => 2,
'retry_count' => 1,
'insecure_skip_verify' => false
]),
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/enrichment/mapping/api/create?app_key="
payload := strings.NewReader("{\n \"api_name\": \"CMDB API\",\n \"description\": \"Query CMDB for host metadata\",\n \"url\": \"https://cmdb.example.com/api/lookup\",\n \"headers\": {\n \"X-Token\": \"mytoken\"\n },\n \"timeout\": 2,\n \"retry_count\": 1,\n \"insecure_skip_verify\": false\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/enrichment/mapping/api/create?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"api_name\": \"CMDB API\",\n \"description\": \"Query CMDB for host metadata\",\n \"url\": \"https://cmdb.example.com/api/lookup\",\n \"headers\": {\n \"X-Token\": \"mytoken\"\n },\n \"timeout\": 2,\n \"retry_count\": 1,\n \"insecure_skip_verify\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/enrichment/mapping/api/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 \"api_name\": \"CMDB API\",\n \"description\": \"Query CMDB for host metadata\",\n \"url\": \"https://cmdb.example.com/api/lookup\",\n \"headers\": {\n \"X-Token\": \"mytoken\"\n },\n \"timeout\": 2,\n \"retry_count\": 1,\n \"insecure_skip_verify\": false\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"api_id": "665f1a2b3c4d5e6f7a8b9c02",
"api_name": "CMDB API"
}
}{
"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."
}
}限制说明
| 项目 | 说明 |
|---|---|
| 速率限制 | 每个账户 300 次/分钟;20 次/秒 |
| 权限要求 | 映射数据管理(on-call) |
使用说明
mapping_type为api的富化规则会携带配置的headers发送POST <url>,请求体为 JSON{"result_label_keys": [...], "event": {...}}(告警事件)。API 须返回 HTTP 200 和{"result_labels": {"<label>": "<value>"}}。url必须使用http或https;SaaS 环境下主机名不得解析到内网 IP。timeout是整个请求的超时秒数(1–3,默认 2);retry_count是失败后的重试次数(0–1,默认 0)。- SaaS 环境下会拒绝以下敏感请求头(不区分大小写):
Authorization、Proxy-Authorization、Cookie、X-Api-Key、X-Access-Token、X-Forwarded-For、X-Real-Ip、True-Client-Ip、X-Client-Ip、Host、X-Forwarded-Host、X-Forwarded-Proto、X-Internal-Id、X-User-Id、Transfer-Encoding、Upgrade、Connection。 api_name在未删除的映射 API 中必须唯一;每个账户最多 50 个未删除的映射 API。team_id非 0 时必须是已存在的团队。- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。
授权
请求体
application/json
此页面对您有帮助吗?