azure - 如何从 Kusto (ADX) 查询结果生成 Markdown

标签 azure azure-data-explorer kql

我正在尝试基于 KQL 查询构建仪表板。 我使用的仪表板工具知道如何呈现 Markdown,但我不知道如何根据 Kusto 中的查询结果生成 Markdown(不使用外部工具)。

最佳答案

我创建了一个实用函数来根据查询结果创建 Markdown 。

.create-or-alter function with (folder = "formatting", docstring = "Table to Markdown", skipvalidation = "true") TableToMarkdown(t:(*)) {
let schema = t | getschema;
let headers = schema | project ColumnName | summarize make_list(ColumnName) | extend String = strcat('| ', strcat_array(list_ColumnName, ' | '), ' |') | project String, Order=1;
let upperDivider = schema | project ColumnName, Sep = '---' | summarize Cols=make_list(Sep) | extend String = strcat('| ', strcat_array(Cols, ' | '), ' |') | project String, Order=2;
let data = t | extend Cols=pack_array(*) | extend String = strcat('| ', strcat_array(Cols, ' | '), ' |') | project String, Order=3;
headers 
| union upperDivider
| union data
| order by Order asc 
| summarize Rows=make_list(String) 
| project array_strcat(Rows, '\r\n')
} 

然后可以像这样调用它:

let T = print x=1, y=2;
T | invoke TableToMarkdown()

关于azure - 如何从 Kusto (ADX) 查询结果生成 Markdown ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73783992/

相关文章:

azure - 如何将 Kusto 查询与 2 个表列进行比较?

azure - 库斯托 : make-series stops with first day - doesnt work as expected

azure - 如何使用 Azure Resource Graph Explorer 查询获取每个订阅的资源计数列表?

c# - 通过 Azure 混合连接连接 SQL Server?

azure - 如何对 azure data explorer 中的特定数据应用保留策略?

azure - Kusto 中两个连续值之间的差异

bigdata - 我们可以在 Kusto 中以年为单位设置表的保留期吗?

Azure 角色分配 - AKS 到 ACR - Terraform

java - 授予对 azure 表的只读访问权限

azure - Windows Azure 存储(Blob、表、队列)是否针对 Windows Azure 角色的访问进行了优化?