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

Added new data query option "allow_past" #10112

Merged
merged 4 commits into from
Oct 22, 2020

Conversation

stelfrag
Copy link
Collaborator

Summary

Adds a new query option allow_past for the data endpoint that will allow the after parameter to extend before the first timestamp stored. The entries that do not exist will be returned as null

Component Name

database

Test Plan
  • Start agent will no history (e.g. if using dbengine memory mode, delete the dbengine files)
  • Run a query such as:
    /api/v1/data?chart=system.cpu
    • This should return just a few entries (the number of seconds the agent is up and running)
  • Run the query
    /api/v1/data?chart=system.cpu&options=allow_past
    • You should get 600 entries returned, most of them null

Calculate "after" and allow it to extend to the past if "allow_past" is given
@stelfrag stelfrag marked this pull request as ready for review October 21, 2020 14:34
web/api/queries/query.c Show resolved Hide resolved
@thiagoftsm
Copy link
Contributor

Hi @stelfrag ,

Please, can you also change the swagger file and yaml file with this PR for we do not have options without documentation?

Thank you!

@stelfrag
Copy link
Collaborator Author

Hi @stelfrag ,

Please, can you also change the swagger file and yaml file with this PR for we do not have options without documentation?

Thank you!

good point !!! 👍

@thiagoftsm
Copy link
Contributor

thiagoftsm commented Oct 21, 2020

Run a query such as:
/api/v1/data?chart=system.cpu

    This should return just a few entries (the number of seconds the agent is up and running)

Run the query
/api/v1/data?chart=system.cpu&options=allow_past

    You should get 600 entries returned, most of them null

@stelfrag I tested now with memory mode = ram and memory mode = dbengine, for this last I removed everything inside /var/cache/netdata/dbengine before to test, and I could not see the results that you described.

I executed the following requests to simplify the comparison:

$ curl -k -o without.json https://localhost:19999/api/v1/data?chart=system.cpu ; curl -k -o with.json https://localhost:19999/api/v1/data?chart=system.cpu&options=allow_past
$ wc -l with*

@stelfrag
Copy link
Collaborator Author

Run a query such as:
/api/v1/data?chart=system.cpu

    This should return just a few entries (the number of seconds the agent is up and running)

Run the query
/api/v1/data?chart=system.cpu&options=allow_past

    You should get 600 entries returned, most of them null

@stelfrag I tested now with memory mode = ram and memory mode = dbengine, for this last I removed everything inside /var/cache/netdata/dbengine before to test, and I could not see the results that you described.

I executed the following requests to simplify the comparison:

$ curl -k -o without.json https://localhost:19999/api/v1/data?chart=system.cpu ; curl -k -o with.json https://localhost:19999/api/v1/data?chart=system.cpu&options=allow_past
$ wc -l with*

Ah, yes I have been tricked quite a few times by this.

Please escape the & because you sent the command to the background 😄

Copy link
Contributor

@thiagoftsm thiagoftsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After to add quotes for curl 👀 , everything worked as expected.
Thank you @stelfrag !

@stelfrag stelfrag merged commit f3d00f7 into netdata:master Oct 22, 2020
@stelfrag stelfrag deleted the allow_past_first_entry_query branch October 23, 2020 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants