Invoke-AzOperationalInsightsQuery
语法
ByWorkspaceId (默认值)
Invoke-AzOperationalInsightsQuery
-WorkspaceId <String>
-Query <String>
[-Timespan <TimeSpan>]
[-Wait <Int32>]
[-IncludeRender]
[-IncludeStatistics]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ByWorkspaceObject
Invoke-AzOperationalInsightsQuery
-Workspace <PSWorkspace>
-Query <String>
[-Timespan <TimeSpan>]
[-Wait <Int32>]
[-IncludeRender]
[-IncludeStatistics]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
示例
示例 1:使用查询获取搜索结果
$query = "union * | take 10"
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId "63613592-b6f7-4c3d-a390-22ba13102111" -Query $query
$queryResults.Results
调用后,$queryResults.Results 将包含查询中的所有生成的行。
示例 2:转换$results。数组的结果 IEnumerable
$query = "union * | take 10"
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId "63613592-b6f7-4c3d-a390-22ba13102111" -Query $query
$resultsArray = [System.Linq.Enumerable]::ToArray($queryResults.Results)
某些查询可能会导致返回非常大的数据集。 因此,cmdlet 的默认行为是返回 IEnumerable 以降低内存成本。 如果希望获得结果数组,可以使用 LINQ Enumerable.ToArray() 扩展方法将 IEnumerable 转换为数组。
示例 3:在特定时间范围内使用查询获取搜索结果
$query = "union * | take 10"
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId "63613592-b6f7-4c3d-a390-22ba13102111" -Query $query -Timespan (New-TimeSpan -Hours 24)
$queryResults.Results
此查询的结果将限制为过去 24 小时。
示例 4:在查询结果中包含呈现和统计信息
$query = "union * | take 10"
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId "63613592-b6f7-4c3d-a390-22ba13102111" -Query $query -IncludeRender -IncludeStatistics
$queryResults.Results
$queryResults.Render
$queryResults.Statistics
参数
-AsJob
在后台运行 cmdlet
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-IncludeRender
如果指定,则指标查询的呈现信息将包含在响应中。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-IncludeStatistics
如果指定,查询统计信息将包含在响应中。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Query
要执行的查询。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Timespan
要绑定查询依据的时间跨度。
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Wait
将上限放在服务器处理查询所花费的时间量上。 请参阅:https://learn.microsoft.com/azure/azure-monitor/logs/api/timeouts
参数属性
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Workspace
工作区
参数属性
参数集
ByWorkspaceObject
Position: | Named |
必需: | True |
来自管道的值: | True |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-WorkspaceId
工作区 ID。
参数属性
类型: | String
|
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
ByWorkspaceId
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输出