Skip to content

Fix issue 208: /data API with points=X returns (X-1) points#253

Closed
whitejava wants to merge 1 commit intonetdata:masterfrom
whitejava:master
Closed

Fix issue 208: /data API with points=X returns (X-1) points#253
whitejava wants to merge 1 commit intonetdata:masterfrom
whitejava:master

Conversation

@whitejava
Copy link
Copy Markdown

No description provided.

@ktsaou
Copy link
Copy Markdown
Member

ktsaou commented Apr 17, 2016

It makes sense!
Thanks!

Have to tested it? Is it ok now? The worst thing that can happen there is to overflow RRDR *r. Have you checked it does not overflow after this patch?

@ktsaou
Copy link
Copy Markdown
Member

ktsaou commented Apr 25, 2016

ok. I traced it and I don't think we should merge this.

Let me explain why:

When netdata is reducing metrics, it tries to return always the same boundaries. So, when you say you want 10s averages, it will always return points starting at a unix timestamp % 10 = 0.

Let's see why this is needed. I will show you the error case.

Assume we have 5 points:

time value
00:01 1
00:02 2
00:03 3
00:04 4
00:05 5

At 00:04 you ask for 2 points for 4 seconds in the past. So group = 2. netdata would return:

point time value
1 00:01 - 00:02 1.5
2 00:03 - 00:04 3.5

A second later the chart is to be refreshed, and makes again the same request at 00:05. These are the points that would have been returned:

point time value
1 00:02 - 00:03 2.5
2 00:04 - 00:05 4.5

Wait a moment! The chart was shifted just one point and it changed value! Point 2 was 3.5 and when shifted to point 1 is 2.5 !

If you see this in a chart is a mess. The charts change shape constantly.

For this reason, netdata always aligns the data it returns to the group.

When you request points=1, netdata understands that you need 1 point for the whole database, so group = 3600. Then it tries to find the starting point which would be timestamp % 3600 = 0 Within a database of 3600 seconds, there is one such point for sure. Then it tries to find the average of 3600 points. But, most probably it will not find 3600 of them (for just 1 out of 3600 seconds this query will return something).

So, the proper way to query the database is to also set at least after. If you say:

http://netdata.firehol.org/api/v1/data?chart=system.cpu&points=1&after=-10&options=seconds

it returns 1 point for the last complete 10-second duration (it starts at timestamp % 10 = 0). Check it. It will return one new value every 10 seconds, and the timestamp will always end with zero. Similarly if you say points=1&after=-5 it will always return timestamps ending with 0 or 5.

So, I don't think we should merge this.

@ktsaou ktsaou added the wontfix label Apr 25, 2016
@ktsaou
Copy link
Copy Markdown
Member

ktsaou commented Apr 25, 2016

I should also add that even after this PR, the returned value will be misleading. The returned value will not be the average of the 3600 points. It will be the average of 1 up to 3600 points depending on the time you asked for it.

@ktsaou
Copy link
Copy Markdown
Member

ktsaou commented Apr 28, 2016

I am thinking of adding an option to the API for disabling this alignment for the specific request. This can be useful if you really want to get misaligned data: #316 #205

ktsaou added a commit to ktsaou/netdata that referenced this pull request Jun 5, 2016
@ktsaou ktsaou self-assigned this Jun 5, 2016
@ktsaou ktsaou closed this in #489 Jun 5, 2016
@ktsaou ktsaou removed the in progress label Jun 5, 2016
@ktsaou ktsaou mentioned this pull request Oct 18, 2016
@ktsaou ktsaou mentioned this pull request Jul 11, 2017
vkalintiris pushed a commit to vkalintiris/netdata that referenced this pull request Dec 13, 2023
* Ported php-fpm to Go
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.

2 participants