多くの Azure Monitor API は、収集される一連のデータをフィルター処理または制約するために使用できるパラメーター {filter-expression}
を受け取ります。
複数のリソースを要求する際のフィルター '*' の使用
Von Bedeutung
複数のリソースのフィルター内の *
は、ワイルドカードではありません。 これは、複数のリソースを要求するために使用されるリテラル文字列です。 この *
は、1 つの時系列で複数のリソースを要求するために使用されます。
次のサンプルでは、 $filter=Microsoft.ResourceId eq '*'
は、サブスクリプションとリージョン内の仮想マシン リソースごとに個別の時系列を返すように API に指示します。 フィルターがないと、API はすべての VM の平均 CPU を集計した 1 つの時系列を返します。 各リソースの時系列は、各時系列エントリの Microsoft.ResourceId メタデータ値によって区別されます。
$filter=Microsoft.ResourceId eq '*'
を使用していて、リソース (この場合は指定された時系列内の VM) がない場合、要求されたディメンションのセットには次のような結果がないため、空の時系列timeseries:[]
が返されます。ResourceId
フィルターを使用しない同じクエリでは、要求されたすべてのディメンションの合計であるため、すべての VM の集計平均 CPU = 0
を返す 1 つの時系列が返されます。
GET https://management.azure.com/subscriptions/12345678-abcd-98765432-abcdef012345/providers/microsoft.Insights/metrics?timespan=2023-06-25T22:20:00.000Z/2023-06-26T22:25:00.000Z&interval=PT5M&metricnames=Percentage CPU&aggregation=average&api-version=2021-05-01®ion=eastus&metricNamespace=microsoft.compute/virtualmachines&$filter=Microsoft.ResourceId eq '*'
使用例 $filter
{filter-expression}
として渡すことができる式文字列を次に示します。 他の構文は許可されません。
リソース グループのイベントを一覧表示する
$filter=eventTimestamp ge <Start Time> and eventTimestamp le <End Time> and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'
例:
$filter=eventTimestamp ge 2014-12-29T22:00:37Z and eventTimestamp le 2014-12-29T23:36:37Z and eventChannels eq 'Admin, Operation' and resourceGroupName eq 'CloudLab'
リソースのイベントを一覧表示する
$filter=eventTimestamp ge <Start Time> and eventTimestamp le <End Time> and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'
例:
$filter=eventTimestamp ge 2014-12-29T22:00:37Z and eventTimestamp le 2014-12-29T23:36:37Z and eventChannels eq 'Admin, Operation' and resourceUri eq '/subscriptions/089bd33f-d4ec-47fe-8ba5-0753aa5c5b33/resourcegroups/CloudLab/providers/Microsoft.Web/sites/mytestweb004'
Azure サブスクリプションのイベントを一覧表示する
$filter=eventTimestamp ge <Start Time> and eventTimestamp le <End Time> and eventChannels eq 'Admin, Operation'
例:
$filter=eventTimestamp ge 2014-12-29T22:00:37Z and eventTimestamp le 2014-12-29T23:36:37Z and eventChannels eq 'Admin, Operation'
Azure リソース プロバイダーのイベントを一覧表示する
$filter=eventTimestamp ge <Start Time> and eventTimestamp le <End Time> and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'
例:
$filter=eventTimestamp ge 2014-12-29T22:00:37Z and eventTimestamp le 2014-12-29T23:36:37Z and eventChannels eq 'Admin, Operation' and resourceProvider eq 'Microsoft.Web'
相関 ID のイベントを一覧表示する
api-version=2014-04-01&$filter=eventTimestamp ge 2014-07-16T04:36:37.6407898Z and eventTimestamp le 2014-07-20T04:36:37.6407898Z and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'
例: api-version=2014-04-01&$filter=eventTimestamp ge 2014-12-29T22:00:37Z and eventTimestamp le 2014-12-29T23:36:37Z and eventChannels eq 'Admin, Operation' and correlationId eq '07c85493-5e87-4efd-9200-0c64d904d878'