Steps to reproduce
- Let's create some resources and fill it with data:
#!/usr/bin/env bash
set -e
METRIC=test
PROJECT_ID=$(uuidgen)
RES_COUNT=3
until [ $RES_COUNT -eq 0 ]; do
RES_ID=$(uuidgen)
gnocchi resource create --type generic -a project_id:${PROJECT_ID} -n ${METRIC} ${RES_ID}
RES_COUNT=$[RES_COUNT-1]
done
RESOURCES=$(gnocchi resource list -t generic -f value -c id)
# MAX = 86400/(5*60)
MAX=288
for R in ${RESOURCES}; do
START=$(date +%s -d '2 days ago 00:00')
START=$[START-120]
C=0
while [ ${C} -lt ${MAX} ]; do
C=$[C+1]
START=$[START+300]
# echo $C : $START : ${R}
gnocchi measures add --resource-id ${R} -m ${START}@${RANDOM} ${METRIC}
done
done
# --------------------------------------------------------------------------
- it works excellent
stack@devstack:/opt/stack$ gnocchi resource list -t generic -c id -c project_id
+--------------------------------------+--------------------------------------+
| id | project_id |
+--------------------------------------+--------------------------------------+
| 26e1490d-a048-44c9-93ca-1391c8856dc0 | a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 |
| 496d3a7b-cbcb-4449-acf1-9ab22ce562d8 | a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 |
| 31dff914-4531-4554-8a1a-94458e94462a | a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 |
+--------------------------------------+--------------------------------------+
- check aggregation resample within resources:
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'id=26e1490d-a048-44c9-93ca-1391c8856dc0' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T09:00:00 --aggregation sum
+---------------------------+-------------+----------+
| timestamp | granularity | value |
+---------------------------+-------------+----------+
| 2017-05-31T05:00:00+00:00 | 3600.0 | 144796.0 |
| 2017-05-31T06:00:00+00:00 | 3600.0 | 213656.0 |
| 2017-05-31T07:00:00+00:00 | 3600.0 | 171416.0 |
| 2017-05-31T08:00:00+00:00 | 3600.0 | 318284.0 |
+---------------------------+-------------+----------+
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'id=496d3a7b-cbcb-4449-acf1-9ab22ce562d8' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T09:00:00 --aggregation sum
+---------------------------+-------------+----------+
| timestamp | granularity | value |
+---------------------------+-------------+----------+
| 2017-05-31T05:00:00+00:00 | 3600.0 | 203921.0 |
| 2017-05-31T06:00:00+00:00 | 3600.0 | 236775.0 |
| 2017-05-31T07:00:00+00:00 | 3600.0 | 196118.0 |
| 2017-05-31T08:00:00+00:00 | 3600.0 | 209570.0 |
+---------------------------+-------------+----------+
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'id=31dff914-4531-4554-8a1a-94458e94462a' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T09:00:00 --aggregation sum
+---------------------------+-------------+----------+
| timestamp | granularity | value |
+---------------------------+-------------+----------+
| 2017-05-31T05:00:00+00:00 | 3600.0 | 214240.0 |
| 2017-05-31T06:00:00+00:00 | 3600.0 | 205139.0 |
| 2017-05-31T07:00:00+00:00 | 3600.0 | 186773.0 |
| 2017-05-31T08:00:00+00:00 | 3600.0 | 234381.0 |
+---------------------------+-------------+----------+
Excelent!
- check aggregation resample throughout resources in project_id:
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--resource-type generic \
--query 'project_id=a52ba4f1-07a1-4c77-8cf6-2cf48b22b249' \
--fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T09:00:00 --aggregation sum
+---------------------------+-------------+----------+
| 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 |
+---------------------------+-------------+----------+
Marvelous!
- Let's create one more resource:
stack@devstack:/opt/stack$ gnocchi resource create --type generic -a project_id:a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 -n test $(uuidgen | sed -e 's/-.\{4\}-/-BAAD-/g')
+-----------------------+-------------------------------------------------------------------+
| Field | Value |
+-----------------------+-------------------------------------------------------------------+
| created_by_project_id | cb894d1f7a374e2492d6cb66898d8fb4 |
| created_by_user_id | 3d87bef886874de4a3d1b76a1902964e |
| creator | 3d87bef886874de4a3d1b76a1902964e:cb894d1f7a374e2492d6cb66898d8fb4 |
| ended_at | None |
| id | ca261c80-baad-4cf3-baad-e9199d312630 |
| metrics | test: 93d88b5b-c55f-4aff-bd02-1100b5db2996 |
| original_resource_id | ca261c80-BAAD-4cf3-BAAD-e9199d312630 |
| project_id | a52ba4f1-07a1-4c77-8cf6-2cf48b22b249 |
| revision_end | None |
| revision_start | 2017-06-02T13:44:31.668693+00:00 |
| started_at | 2017-06-02T13:44:31.668689+00:00 |
| type | generic |
| user_id | None |
+-----------------------+-------------------------------------------------------------------+
- Time for tests:
stack@devstack:/opt/stack$ gnocchi measures aggregation -m test \
--query 'id=ca261c80-baad-4cf3-baad-e9199d312630' \
--resource-type generic --fill 0 --granularity 300 --resample 3600 \
--start 2017-05-31T05:00:00 --stop 2017-05-31T09:00:00 --aggregation sum
<!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! :(
For part 2 see: Gnocchi bug analyze. Part 2