GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TimeSeries Query for last 5 Minutes not Last 5 Minutes · Issue #2459 · googleapis/google-cloud-python

TimeSeries Query for last 5 Minutes not Last 5 Minutes #2459

New issue
Copy link
New issue
Copy link
Closed
Closed
TimeSeries Query for last 5 Minutes not Last 5 Minutes#2459
Copy link
Assignees
tseaver
Labels
api: monitoringIssues related to the Cloud Monitoring API.

Description

@waprin
waprin
opened on Sep 28, 2016
Issue body actions

The usage docs say

query = client.query(METRIC, minutes=5)

will give you stats for the last five minutes. But since the code replaces seconds and microseconds with 0, it's not actually the last 5 minutes since you won't be querying any time interval between the end of the previous minute and the current second.

The reason this came up is in the system tests, I write a point, then try to query it back, but I never get the time series even if they are there, since I

write_point: 2016-09-28T19:29:57.726637
query end_time: 2016-09-28T19:29:00.000000Z

so even though write_point happened first, it's end_time is after the end_time of the query.

Maybe people think second granularity doesn't matter? I'm curious why replacing the second/microseconds with 0 was done in the first place. I think at a minimum the docs are slightly misleading, since it's not the last 5 minutes in the colloquial sense (doesn't include the seconds up until now in the current minute).

cc @rimey @supriyagarg

Activity

  1. supriyagarg commented on Sep 28, 2016

    @supriyagarg
    supriyagarg
    on Sep 28, 2016
    Contributor
    More actions

    @waprin: To get the data for a time period ending exactly now, it is recommended to explicitly specify the end time either during initialization or using select_interval. Given that you can write up to one point per minute, this could miss the latest data point.

    The end time of the query determines the exact timestamps when using alignment, so zeroing out seconds and microseconds makes the results look nicer, and easier to understand.

  2. waprin commented on Sep 28, 2016

    @waprin
    waprin
    on Sep 28, 2016
    ContributorAuthor
    More actions

    Ok, that's what I did in #2460 so we could leave it at that. However I still think the behavior is a bit surprising so I'm curious if you

    • Can explain the motivation for replacing the seconds
    • Agree we should at least call this out more explicitly in the docs, rather than just say "the last 5 minutes"
  3. supriyagarg commented on Sep 28, 2016

    @supriyagarg
    supriyagarg
    on Sep 28, 2016
    Contributor
    More actions

    The motivation is as I mentioned in the previous comment:

    The end time of the query determines the exact timestamps when using alignment, so zeroing out seconds and microseconds makes the results look nicer, and easier to understand.

    In most cases alignment is indeed required, so this applies to a majority of use cases. Also, for specifying exact time intervals select_interval is better. The init method is designed to support common use cases, especially when trying out the library.

    Agreed that the top level docs should be updated. Something like the following would work:

    Display CPU utilization across your GCE instances over a 5 minute duration ending at the start of the current minute.

  4. rimey commented on Sep 28, 2016

    @rimey
    rimey
    on Sep 28, 2016
    Contributor
    More actions

    It's good to know that this pitfall exists, but we have to focus on normal end-user use-cases. Using a round minute as the default end time makes aligned data much prettier. I found the library annoying to use with the exact current time as the default.

  5. waprin commented on Sep 28, 2016

    @waprin
    waprin
    on Sep 28, 2016
    ContributorAuthor
    More actions

    Yeah it makes sense to me, writing a time series and immediately reading it back is probably only something we'll do in the system test, and I'm sure on charts and graphs having round minutes is cleaner. I think the doc change is still a good idea just in case, so after that gets merged I think we can close the issue.

  6. dhermes
    added
    api: monitoringIssues related to the Cloud Monitoring API.
    on Sep 29, 2016
  7. tseaver
    closed this as completedin #2461on Sep 29, 2016
  8. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  9. parthea
    added 2 commits that reference this issue on Oct 21, 2023

    docs: add samples from tables/automl (#54)

    c829cc3

    chore: release 2.0.0 (#68)

    629a2a6
  10. parthea
    added a commit that references this issue on Nov 24, 2025

    chore(main): release 1.28.0 (#2459)

    6730b9f
  11. parthea
    added a commit that references this issue on Apr 1, 2026

    chore: Update project links for pypi (#2459)

    9660357
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: monitoringIssues related to the Cloud Monitoring API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.