Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor delegation - Fetching data fails or gets incomplete data set #60

Open
haraldfianbakken opened this issue May 27, 2020 · 1 comment

Comments

@haraldfianbakken
Copy link
Contributor

When invoking https://management.azure.com/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&`$filter=eventTimestamp ge '$($dateFormatForQuery)

you get in certain cases an empty result with a nextlink to fetch - or you get multiple pages with nextLink in response - so you need to iterate and fetch the result (fix coming)

haraldfianbakken added a commit to haraldfianbakken/Azure-Lighthouse-samples that referenced this issue May 27, 2020
archunz-zz pushed a commit that referenced this issue Jun 17, 2020
@cholmes12
Copy link

cholmes12 commented Sep 11, 2020

Hi.

$list = Invoke-RestMethod @listOperations

Comment: First link can be empty - and point to a next link (or potentially multiple pages)
Comment: While you get more data - continue fetching and add result
while($list.nextLink){
$list2 = Invoke-RestMethod $list.nextLink -Headers $listOperations.Headers -Method Get
$data+=$list2.value;
$list.nextLink = $list2.nextlink;
}

$showOperations = $data;

$data does not get set if there is no value for $list.nextLink. Then the script does not work.

For the same tenant - if I set $showOperations = $list.value, I get an event as expected.

This works for me:
Comment: First link can be empty - and point to a next link (or potentially multiple pages)
Comment: While you get more data - continue fetching and add result

if ($null -ne $list.nextLink){
while($list.nextLink){
$list2 = Invoke-RestMethod $list.nextLink -Headers $listOperations.Headers -Method Get
$data+=$list2.value;
$list.nextLink = $list2.nextlink;
}
$showOperations = $data
}else{

Comment: Sometimes the first link is not empty.
$showOperations = $list.value

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants