获取ES字段聚合结果

最近更新时间:2024-10-31 02:10:11

我的收藏

1. 接口描述

接口请求域名: tcss.tencentcloudapi.com 。

获取ES字段聚合结果

默认接口请求频率限制:20次/秒。

推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:DescribeESAggregations。
Version String 公共参数,本接口取值:2020-11-01。
Region String 公共参数,此参数为可选参数。
Query String ES聚合条件JSON
示例值:{"index":[],"body":"{"query":{"bool":{"filter":{"bool":{"filter":{"range":{"insert_time":{"gte":1729699200000,"lte":1729708160014}}},"must":[],"must_not":[],"should":[]}}}},"highlight":{"fields":{"*":{}}},"aggs":{"count_stats":{"date_histogram":{"field":"insert_time","interval":"30m","time_zone":"Asia/Shanghai","min_doc_count":1}}},"track_total_hits":true,"sort":[{"insert_time":"desc"}]}"}
LogTypes.N Array of String 日志类型列表
示例值:["asset_container"]

3. 输出参数

参数名称 类型 描述
Data String ES聚合结果JSON
示例值:{ "took": 53, "hits": { "total": { "value": 360540, "relation": "eq" } }, "aggregations": { "count_stats": { "buckets": [ { "key_as_string": "2024-10-24T00:00:00.000+08:00", "key": 1729699200000, "doc_count": 72104 } ] } }, "_shards": { "total": 9, "successful": 9, "failed": 0 } }
RequestId String 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 获取ES字段聚合结果

输入示例

POST / HTTP/1.1
Host: tcss.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeESAggregations
<公共请求参数>

{
    "Query": "{\"index\":[],\"body\":\"{\\\"query\\\":{\\\"bool\\\":{\\\"filter\\\":{\\\"bool\\\":{\\\"filter\\\":{\\\"range\\\":{\\\"insert_time\\\":{\\\"gt\\\":1729737627694,\\\"lte\\\":1729766427694}}},\\\"must\\\":[],\\\"must_not\\\":[],\\\"should\\\":[]}}}},\\\"highlight\\\":{\\\"fields\\\":{\\\"*\\\":{}}},\\\"aggs\\\":{\\\"count_stats\\\":{\\\"date_histogram\\\":{\\\"field\\\":\\\"insert_time\\\",\\\"interval\\\":\\\"30m\\\",\\\"time_zone\\\":\\\"Asia/Shanghai\\\",\\\"min_doc_count\\\":1}}},\\\"track_total_hits\\\":true,\\\"sort\\\":[{\\\"insert_time\\\":\\\"desc\\\"}]}\"}",
    "LogTypes": [
        "asset_container",
        "asset_local_image",
        "asset_registry_image",
        "asset_host",
        "asset_cluster",
        "asset_pod",
        "asset_service",
        "asset_ingress",
        "asset_process",
        "asset_port",
        "asset_web_service",
        "asset_app",
        "asset_db",
        "container_bash",
        "container_launch",
        "k8s_api",
        "local_image_virus",
        "local_image_risk",
        "local_image_vul",
        "registry_image_virus",
        "registry_image_risk",
        "registry_image_vul",
        "image_deny",
        "cluster_risk_vul",
        "cluster_risk_cfg",
        "baseline_docker_container",
        "baseline_docker_image",
        "baseline_docker_host",
        "baseline_containerd_container",
        "baseline_k8s",
        "baseline_containerd_host",
        "container_escape",
        "reverse_shell",
        "container_virus",
        "malicious_connection",
        "abnormal_process",
        "access_control",
        "risk_syscall",
        "abnormal_k8s_api"
    ]
}

输出示例

{
    "Response": {
        "Data": "{\"took\":973,\"hits\":{\"total\":{\"value\":5108036,\"relation\":\"eq\"}},\"aggregations\":{\"count_stats\":{\"buckets\":[{\"key_as_string\":\"2024-10-24T10:30:00.000+08:00\",\"key\":1729737000000,\"doc_count\":47623},{\"key_as_string\":\"2024-10-24T11:00:00.000+08:00\",\"key\":1729738800000,\"doc_count\":64848},{\"key_as_string\":\"2024-10-24T11:30:00.000+08:00\",\"key\":1729740600000,\"doc_count\":65760},{\"key_as_string\":\"2024-10-24T12:00:00.000+08:00\",\"key\":1729742400000,\"doc_count\":71743},{\"key_as_string\":\"2024-10-24T12:30:00.000+08:00\",\"key\":1729744200000,\"doc_count\":72563},{\"key_as_string\":\"2024-10-24T13:00:00.000+08:00\",\"key\":1729746000000,\"doc_count\":65545},{\"key_as_string\":\"2024-10-24T13:30:00.000+08:00\",\"key\":1729747800000,\"doc_count\":63693},{\"key_as_string\":\"2024-10-24T14:00:00.000+08:00\",\"key\":1729749600000,\"doc_count\":71868},{\"key_as_string\":\"2024-10-24T14:30:00.000+08:00\",\"key\":1729751400000,\"doc_count\":73547},{\"key_as_string\":\"2024-10-24T15:00:00.000+08:00\",\"key\":1729753200000,\"doc_count\":65341},{\"key_as_string\":\"2024-10-24T15:30:00.000+08:00\",\"key\":1729755000000,\"doc_count\":64074},{\"key_as_string\":\"2024-10-24T16:00:00.000+08:00\",\"key\":1729756800000,\"doc_count\":877499},{\"key_as_string\":\"2024-10-24T16:30:00.000+08:00\",\"key\":1729758600000,\"doc_count\":914717},{\"key_as_string\":\"2024-10-24T17:00:00.000+08:00\",\"key\":1729760400000,\"doc_count\":823727},{\"key_as_string\":\"2024-10-24T17:30:00.000+08:00\",\"key\":1729762200000,\"doc_count\":743536},{\"key_as_string\":\"2024-10-24T18:00:00.000+08:00\",\"key\":1729764000000,\"doc_count\":756934},{\"key_as_string\":\"2024-10-24T18:30:00.000+08:00\",\"key\":1729765800000,\"doc_count\":265018}]}},\"_shards\":{\"total\":9,\"successful\":9,\"failed\":0}}",
        "RequestId": "16fd0b2f-6bae-426e-bf63-64607a7e2705"
    }
}

5. 开发者资源

腾讯云 API 平台

腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。

API Inspector

用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码

错误码 描述
InternalError 内部错误。
InternalError.MainDBFail 操作数据库失败。
InvalidParameter 参数错误。