From 3854fdfb82d99d20dfc11bd559ea1bda66cd851c Mon Sep 17 00:00:00 2001 From: Cory LaNou Date: Fri, 3 Apr 2015 10:33:40 -0500 Subject: [PATCH] Add script to show how to query for future data --- tests/create_future_writes.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tests/create_future_writes.sh diff --git a/tests/create_future_writes.sh b/tests/create_future_writes.sh new file mode 100755 index 00000000000..ff673f7cb28 --- /dev/null +++ b/tests/create_future_writes.sh @@ -0,0 +1,22 @@ +now=$(date '+%FT%T.000Z') +tomorrow=$(date -v +1d '+%FT%T.000Z') + +echo "creating database" +curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE foo" + +echo "creating retention policy" +curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY bar ON foo DURATION INF REPLICATION 1 DEFAULT" + +echo "inserting data" +curl -d "{\"database\" : \"foo\", \"retentionPolicy\" : \"bar\", \"points\": [{\"name\": \"cpu\", \"tags\": {\"region\":\"uswest\",\"host\": \"server01\"},\"timestamp\": \"$now\",\"fields\": {\"value\": 100}}]}" -H "Content-Type: application/json" http://localhost:8086/write + +echo "inserting data" +curl -d "{\"database\" : \"foo\", \"retentionPolicy\" : \"bar\", \"points\": [{\"name\": \"cpu\", \"tags\": {\"region\":\"uswest\",\"host\": \"server01\"},\"timestamp\": \"$tomorrow\",\"fields\": {\"value\": 200}}]}" -H "Content-Type: application/json" http://localhost:8086/write + +sleep 1 + +echo "querying data" +curl -G http://localhost:8086/query --data-urlencode "db=foo" --data-urlencode "q=SELECT count(value) FROM \"foo\".\"bar\".cpu" + +echo "querying data" +curl -G http://localhost:8086/query --data-urlencode "db=foo" --data-urlencode "q=SELECT count(value) FROM \"foo\".\"bar\".cpu where time < now() + 10d"