首选选项

API 支持使用 Prefer 标头设置一些请求和响应选项。 本部分介绍如何设置每个首选项及其值。

可视化效果信息

在查询语言中,可以指定不同的呈现选项。 默认情况下,API 不返回有关可视化效果类型的信息。 若要包含特定的可视化效果,请包含以下标头:

    Prefer: include-render=true

该标头在响应中包含一个 render 属性,该属性指定查询选择的可视化效果类型以及该可视化效果的任何属性。

例如,以下请求指定标题为“Perf events in the last day”的条形图的可视化效果:

    POST https://api.loganalytics.azure.cn/v1/workspaces/{workspace-id}/query
    Authorization: Bearer <access token>
    Prefer: include-render=true
    Content-Type: application/json
    
    {
        "query": "Perf | summarize count() by bin(TimeGenerated, 4h) | render barchart title='24H Perf events'",
        "timespan": "P1D"
    }

响应包含一个 render 属性,该属性描述所选可视化效果的元数据。

    HTTP/1.1 200 OK
    Content-Type: application/json; charset=utf-8
    
    {
        "tables": [ ...query results... ],
        "render": {
            "visualization": "barchart",
            "title": "24H Perf events",
            "accumulate": false,
            "isQuerySorted": false,
            "kind": "default",
            "annotation": "",
            "by": null
        }
    }

查询统计信息

若要获取有关查询统计的信息,请包含以下标头:

    Prefer: include-statistics=true

该标头在响应中包含一个 statistics 属性,该属性描述各种性能统计信息,例如查询执行时间和资源使用量。

查询超时值

默认查询超时为 3 分钟。 要调整查询超时,请设置 wait 属性,如此处所述。

查询数据源

若要获取有关查询数据源(区域、工作区、群集和表)的信息,请包括以下标题:

    Prefer: include-dataSources=true