简体   繁体   English

仅获取 Kusto 查询语言(Azure Monitor 日志)中的类别中的唯一值

[英]Getting only unique values within a category in Kusto Query Language (Azure Monitor Logs)

I have data in this format:我有这种格式的数据:

Category Session_ID  Step_Name

  A         100        1
  A         100        2 
  A         200        1
  A         200        1    <--
  A         200        1    <--
  A         200        2
  B         300        1
  B         300        1    <--

I need to remove the duplicate values of step names within each Session_ID .我需要删除每个 Session_ID中步骤名称的重复值。 For example in ID = 200, there are three '1's which need to be changed to one '1', so the final data looks like:例如ID = 200,有3个'1'需要改成1个'1',所以最终数据如下:

Category Session_ID  Step_Name

  A         100        1
  A         100        2 
  A         200        1
  A         200        2
  B         300        1

You should use distinct operator in your case:您应该在您的情况下使用distinct 运算符

your_table
| distinct Category, Session_ID, Step_Name

then you can get the expected output like below, it works at my side:然后你可以得到预期的 output 如下所示,它在我身边工作:

Category Session_ID  Step_Name

  A         100        1
  A         100        2 
  A         200        1
  A         200        2
  B         300        1

And for your question in the comment, if you use the above query, the record like "A 100 1" would consider as one entity, and only if there are 2 or more exact same record like "A 100 1" would remain only 1 record if using distinct.对于您在评论中的问题,如果您使用上述查询,则“A 100 1”之类的记录将被视为一个实体,并且只有当有 2 个或更多完全相同的记录(例如“A 100 1”)时,才会仅保留 1如果使用 distinct 则记录。

And if there is another record like "B 100 1", then the both 2 records "A 100 1" and "B 100 1" would remain.如果有另一条记录,如“B 100 1”,则两条记录“A 100 1”和“B 100 1”都将保留。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 监控日志(Kusto 查询语言)中列内的日期时间差 - Date time difference within a column in Azure Monitor Logs (Kusto Query Language) 如何使用 Kusto 查询语言在 Azure 日志中显示具有多个自定义指标的时间表 - How do I display a timechart with more than one custom metric in Azure Logs with Kusto Query Language Azure Logs Kusto 查询输出到数据库表 - Azure Logs Kusto Query Output to database table Kusto 查询语言 - 如何准确获取前一天的日志 7 - Kusto query language - How to get exactly logs from previous day 7 在 Azure(Kusto 查询语言)中聚合多个列 - Aggregate over multiple columns in Azure (Kusto Query Language) 如何监视Azure中的连续异常? (库斯托) - How to monitor consecutive exceptions in Azure? (Kusto) 如何使用 Kusto 日志查询、Azure Monitor 读取/获取虚拟机后台进程 - How to read/get Virtual machine background processes using Kusto LOg query , Azure Monitor 如何使用 Azure Kusto 查询语言 (KQL) 查询 Jmeter Graph,例如 Active Threads Over times - How to use Azure Kusto Query Language (KQL) to query Jmeter Graph such as Active Threads Over times Azure Kusto 查询 output 格式 - Azure Kusto Query output format 将连续的非零行标记为不同的分区,这次使用 kusto - Azure AppInsights 的查询语言 - Tag consecutive non zero rows into distinct partitions, this time using kusto - the query language of the Azure AppInsights
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM