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

az monitor metrics list returns null for future times #6196

Closed
ElvenSpellmaker opened this issue Apr 24, 2018 · 4 comments · Fixed by #7525
Closed

az monitor metrics list returns null for future times #6196

ElvenSpellmaker opened this issue Apr 24, 2018 · 4 comments · Fixed by #7525
Assignees
Labels
Monitor az monitor Monitor-cli Service Attention This issue is responsible by Azure service team.
Milestone

Comments

@ElvenSpellmaker
Copy link

ElvenSpellmaker commented Apr 24, 2018

Hi there,

~~~I've noticed that the command used to extract this data seems to return null for any recent time (randomly, it was working early yesterday evening until a certain point, but then has stopped again).~~~

~~~Commands such as:~~~
```bash
az monitor metrics list --resource /subscriptions/<id>/resourceGroups/POC-JACK-BS-METRICS/providers/Microsoft.Compute/virtualMachines/poc-jack-bs-metrics --metric 'CPU Credits Consumed,CPU Credits Remaining' --interval PT1M --start-time 2018-04-23T21:01:02Z --end-time 2018-04-23T21:02:02Z
```
~~~work absolutely fine (but didn't last night when the time was recent), whereas:~~~
```bash
az monitor metrics list --resource /subscriptions/<id>/resourceGroups/POC-JACK-BS-METRICS/providers/Microsoft.Compute/virtualMachines/poc-jack-bs-metrics --metric 'CPU Credits Consumed,CPU Credits Remaining' --interval PT1M --start-time 2018-04-24T07:14:02Z --end-time 2018-04-24T07:15:02Z
```
~~~doesn't work and returns:~~~
```json
{
  "additionalProperties": {},
  "cost": 0.0,
  "interval": "0:01:00",
  "namespace": "Microsoft.Compute/virtualMachines",
  "resourceregion": "westeurope",
  "timespan": "2018-04-24T07:14:02Z/2018-04-24T07:15:02Z",
  "value": [
    {
      "additionalProperties": {},
      "id": "/subscriptions/<id>/resourceGroups/POC-JACK-BS-METRICS/providers/Microsoft.Compute/virtualMachines/poc-jack-bs-metrics/providers/Microsoft.Insights/metrics/CPU Credits Consumed",
      "name": {
        "additionalProperties": {},
        "localizedValue": "CPU Credits Consumed",
        "value": "CPU Credits Consumed"
      },
      "resourceGroup": "POC-JACK-BS-METRICS",
      "timeseries": [
        {
          "additionalProperties": {},
          "data": [
            {
              "additionalProperties": {},
              "average": null,
              "count": null,
              "maximum": null,
              "minimum": null,
              "timeStamp": "2018-04-24T07:14:00+00:00",
              "total": null
            }
          ],
          "metadatavalues": []
        }
      ],
      "type": "Microsoft.Insights/metrics",
      "unit": "Count"
    },
    {
      "additionalProperties": {},
      "id": "/subscriptions/<id>/resourceGroups/POC-JACK-BS-METRICS/providers/Microsoft.Compute/virtualMachines/poc-jack-bs-metrics/providers/Microsoft.Insights/metrics/CPU Credits Remaining",
      "name": {
        "additionalProperties": {},
        "localizedValue": "CPU Credits Remaining",
        "value": "CPU Credits Remaining"
      },
      "resourceGroup": "POC-JACK-BS-METRICS",
      "timeseries": [
        {
          "additionalProperties": {},
          "data": [
            {
              "additionalProperties": {},
              "average": null,
              "count": null,
              "maximum": null,
              "minimum": null,
              "timeStamp": "2018-04-24T07:14:00+00:00",
              "total": null
            }
          ],
          "metadatavalues": []
        }
      ],
      "type": "Microsoft.Insights/metrics",
      "unit": "Count"
    }
  ]
}
```

If I run a similar query for the whole last day, I get a point of crossover:
```json
            {
              "additionalProperties": {},
              "average": 636.0,
              "count": null,
              "maximum": null,
              "minimum": null,
              "timeStamp": "2018-04-24T06:47:00+00:00",
              "total": null
            },
            {
              "additionalProperties": {},
              "average": null,
              "count": null,
              "maximum": null,
              "minimum": null,
              "timeStamp": "2018-04-24T06:48:00+00:00",
              "total": null
            },
```

~~~The portal seems to have all this information:~~~
![image](https://user-images.githubusercontent.com/2286713/39170611-17e85e22-4794-11e8-846b-de029c54f72d.png)

~~~I'm puzzled as to what the problem is here and any help would be great thanks.~~~ 🤔
@ElvenSpellmaker
Copy link
Author

What I'm most puzzled about is that if I use date then it seems to work:
Running a command like:

az monitor metrics list --resource /subscriptions/<id>/resourceGroups/POC-JACK-BS-METRICS/providers/Microsoft.Compute/virtualMachines/poc-jack-bs-metrics --metric 'CPU Credits Consumed,CPU Credits Remaining' --interval PT1M --start-time $(date -u +"%Y-%m-%dT%H:%M:%SZ" --date='2 minutes ago') --end-time $(date -u +"%Y-%m-%dT%H:%M:%SZ" --date='1 minute ago')

seems to work. 🤔

@ElvenSpellmaker
Copy link
Author

ElvenSpellmaker commented Apr 24, 2018

Just worked it out, it's timezone related, the Ruby script I'm using isn't taking the timezone into account, date in bash does and so I'm querying times an hour into the future.

To be honest the output from this command should probably error if times in the future are queried?

@ElvenSpellmaker ElvenSpellmaker changed the title az monitor metrics list returns null for any recent time az monitor metrics list returns null for future times Apr 24, 2018
@mayurid mayurid added the Monitor az monitor label Apr 24, 2018
@tjprescott tjprescott self-assigned this Oct 8, 2018
@tjprescott tjprescott added this to the Sprint 47 milestone Oct 8, 2018
@tjprescott tjprescott added Monitor Service Attention This issue is responsible by Azure service team. and removed Monitor az monitor labels Oct 8, 2018
@tjprescott tjprescott assigned tjprescott and unassigned tjprescott Oct 8, 2018
@tjprescott
Copy link
Member

It is arguable whether this should fail if a future time is given. We will help the user diagnose issues by showing the OData filter supplied when the user supplied --verbose.

@ElvenSpellmaker
Copy link
Author

Out of interest, what's the argument for it not returning an error for a future time?

It seems pretty logical to me to throw an error to the user if they're querying metrics for something that hasn't happened yet (as opposed to a time that's happened but has no metrics).

@mozehgir mozehgir added the Monitor az monitor label Jul 24, 2019
@haroldrandom haroldrandom added Monitor az monitor Monitor-cli Service Attention This issue is responsible by Azure service team. labels Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monitor az monitor Monitor-cli Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants