See Gnocchi bug analyze. Part 1
Let's do some more tests:
Is this resource empty?
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'id=ca261c80-baad-4cf3-baad-e9199d312630' \
--print-empty --resource-type generic --fill 0 --granularity 300 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T09:00:00 --aggregation sum
+-----------+-------------+-------+
| timestamp | granularity | value |
+-----------+-------------+-------+
+-----------+-------------+-------+
It's empty - but shouldn't "--fill 0 --granularity 300" fill the gaps?
- So let's fill it with some data and try again:
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id ca261c80-baad-4cf3-baad-e9199d312630 -m 2017-05-31T05:00:00@100 test
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id ca261c80-baad-4cf3-baad-e9199d312630 -m 2017-05-31T07:00:00@200 test
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id ca261c80-baad-4cf3-baad-e9199d312630 -m 2017-05-31T09:00:00@300 test
stack@devstack:/opt/stack$ gnocchi measures show \
--resource-id ca261c80-baad-4cf3-baad-e9199d312630 test --refresh
+---------------------------+-------------+-------+
| timestamp | granularity | value |
+---------------------------+-------------+-------+
| 2017-05-31T05:00:00+00:00 | 300.0 | 100.0 |
| 2017-05-31T07:00:00+00:00 | 300.0 | 200.0 |
| 2017-05-31T09:00:00+00:00 | 300.0 | 300.0 |
+---------------------------+-------------+-------+
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T11:00:00 --aggregation sum \
--refresh
+---------------------------+-------------+----------+
| timestamp | granularity | value |
+---------------------------+-------------+----------+
| 2017-05-31T05:00:00+00:00 | 3600.0 | 562957.0 |
| 2017-05-31T06:00:00+00:00 | 3600.0 | 655570.0 |
| 2017-05-31T07:00:00+00:00 | 3600.0 | 554307.0 |
| 2017-05-31T08:00:00+00:00 | 3600.0 | 762235.0 |
| 2017-05-31T09:00:00+00:00 | 3600.0 | 665654.0 |
| 2017-05-31T10:00:00+00:00 | 3600.0 | 520001.0 |
+---------------------------+-------------+----------+
WOW Does it work now? but wait:
stack@devstack:/opt/stack$ gnocchi resource create --type generic \
-a project_id:a52ba4f1-07a1-4c77-8cf6-2cf48b22b249
-n test $(uuidgen)
+-----------------------+-------------------------------------------------------------------+
| Field | Value |
+-----------------------+-------------------------------------------------------------------+
| created_by_project_id | cb894d1f7a374e2492d6cb66898d8fb4 |
| created_by_user_id | 3d87bef886874de4a3d1b76a1902964e |
| creator | 3d87bef886874de4a3d1b76a1902964e:cb894d1f7a374e2492d6cb66898d8fb4 |
| ended_at | None |
| id | 8b2ae691-baad-460d-baad-50c32dcb14de |
| metrics | test: c8d3493d-3940-4cd3-b542-a3826a374788 |
| original_resource_id | 8b2ae691-BAAD-460d-BAAD-50c32dcb14de |
| project_id | a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 |
| revision_end | None |
| revision_start | 2017-06-02T14:03:07.180209+00:00 |
| started_at | 2017-06-02T14:03:07.180165+00:00 |
| type | generic |
| user_id | None |
+-----------------------+-------------------------------------------------------------------+
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T11:00:00 --aggregation sum \
--refresh
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
[no address given] to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 172.22.23.24 Port 8041</address>
</body></html>
(HTTP 500)
Of course, It's empty
Add some data - but before our time range:
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id 8b2ae691-baad-460d-baad-50c32dcb14de \
-m 2017-05-20T10:10:00@52010 test
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T11:00:00 --aggregation sum --refresh
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
[no address given] to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 172.22.23.24 Port 8041</address>
</body></html>
(HTTP 500)
OOPS
maybe another measure helps
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id 8b2ae691-baad-460d-baad-50c32dcb14de \
-m 2017-05-30T10:10:00@52010 test
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T11:00:00 --aggregation sum --refresh
+---------------------------+-------------+----------+
| timestamp | granularity | value |
+---------------------------+-------------+----------+
| 2017-05-31T05:00:00+00:00 | 3600.0 | 562957.0 |
| 2017-05-31T06:00:00+00:00 | 3600.0 | 655570.0 |
| 2017-05-31T07:00:00+00:00 | 3600.0 | 554307.0 |
| 2017-05-31T08:00:00+00:00 | 3600.0 | 762235.0 |
| 2017-05-31T09:00:00+00:00 | 3600.0 | 665654.0 |
| 2017-05-31T10:00:00+00:00 | 3600.0 | 520001.0 |
+---------------------------+-------------+----------+
YES !!! So lets try again:
stack@devstack:/opt/stack$ gnocchi resource create --type generic \
-a project_id:a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 -n test $(uuidgen)
+-----------------------+-------------------------------------------------------------------+
| Field | Value |
+-----------------------+-------------------------------------------------------------------+
| created_by_project_id | cb894d1f7a374e2492d6cb66898d8fb4 |
| created_by_user_id | 3d87bef886874de4a3d1b76a1902964e |
| creator | 3d87bef886874de4a3d1b76a1902964e:cb894d1f7a374e2492d6cb66898d8fb4 |
| ended_at | None |
| id | 7b793531-0edc-48ac-96e0-27b5f5e1178d |
| metrics | test: df4e4e1b-5b54-438c-a882-b06d56b76182 |
| original_resource_id | 7b793531-0edc-48ac-96e0-27b5f5e1178d |
| project_id | a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 |
| revision_end | None |
| revision_start | 2017-06-02T14:05:43.675784+00:00 |
| started_at | 2017-06-02T14:05:43.675675+00:00 |
| type | generic |
| user_id | None |
+-----------------------+-------------------------------------------------------------------+
Test:
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T11:00:00 --aggregation sum --refresh
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
[no address given] to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 172.22.23.24 Port 8041</address>
</body></html>
(HTTP 500)
failed so add some data (outside time range)
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id 7b793531-0edc-48ac-96e0-27b5f5e1178d \
-m 2010-05-30T10:10:00@$RANDOM test
test -> failed
more data:
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id 7b793531-0edc-48ac-96e0-27b5f5e1178d \
-m 2011-05-30T10:10:00@$RANDOM test
test -> failed
more data WITHIN time range:
stack@devstack:/opt/stack$ gnocchi measures add \
--resource-id 7b793531-0edc-48ac-96e0-27b5f5e1178d \
-m 2013-05-30T10:10:00@$RANDOM test
test:
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T11:00:00 --aggregation sum --refresh
+---------------------------+-------------+----------+
| timestamp | granularity | value |
+---------------------------+-------------+----------+
| 2017-05-31T05:00:00+00:00 | 3600.0 | 562957.0 |
| 2017-05-31T06:00:00+00:00 | 3600.0 | 655570.0 |
| 2017-05-31T07:00:00+00:00 | 3600.0 | 554307.0 |
| 2017-05-31T08:00:00+00:00 | 3600.0 | 762235.0 |
| 2017-05-31T09:00:00+00:00 | 3600.0 | 665654.0 |
| 2017-05-31T10:00:00+00:00 | 3600.0 | 520001.0 |
+---------------------------+-------------+----------+
Succeed!