1

我在 Log Analytics 中有一个完整的计算机列。例如,“window432、linus909、windows322、linux432”。我正在过滤我的磁盘利用率,但我也想按特定单词“window”或“lin”进行过滤。那可能吗?我正在使用 Kusto 进行查询,所以这是我的思考过程的一个示例:

Perf
| where Name == "Utilization Percentage"
and "win" in Computer

像这样的东西。那可能吗?谢谢你。

4

2 回答 2

2

根据问题中的给定信息并根据我的理解,要求是根据以“window”或“lin”开头的计算机名称进行过滤。

如果是这种情况,那么您可以使用startswith string operator来完成要求。

查询看起来像:

Perf
| where CounterName == @"% Processor Time" and InstanceName == "_Total"
| where Computer startswith "window" or Computer startswith "lin"

或者

InsightsMetrics
| where Name == "UtilizationPercentage"
| where Computer startswith "window" or Computer startswith "lin"

同样,根据要求,您可以利用其他字符串运算符,如“in”、“has”、“endswith”等。字符串运算符或任何其他适当的运算符或函数。有关详细信息,请参阅Kusto 查询语言 (KQL)文档。

于 2020-07-30T14:13:23.520 回答
0

如果我正确理解描述,这可以工作。

它:

  1. 使用拆分原始逗号分隔的字符串split()
  2. 扩展那些使用mv-apply
  3. 过滤掉不包含的值win
  4. 将剩余的值聚合成一个新的(过滤的)逗号分隔的字符串
datatable(Computers:string, id:int)
[
    "window432, linus909, windows322, linux432", 1,
    "window451, linux459, windows444, linux234", 2,
    "android222, ios222, linux333"             , 3
]
| mv-apply Computer = split(Computers, ", ") on (
    where Computer contains "win"
    | summarize Computers = strcat_array(make_list(Computer), ", ")
)
| where isnotempty(Computers)

输入:

| Computers                                 | id |
|-------------------------------------------|----|
| window432, linus909, windows322, linux432 | 1  |
| window451, linux459, windows444, linux234 | 2  |
| android222, ios222, linux333              | 3  |

输出:

| id | Computers             |
|----|-----------------------|
| 1  | window432, windows322 |
| 2  | window451, windows444 |
于 2020-07-29T20:27:45.017 回答