Skip to content

Instantly share code, notes, and snippets.

@dgnorton
Created February 17, 2015 20:57
Show Gist options
  • Save dgnorton/71c37265159c96fe5664 to your computer and use it in GitHub Desktop.
Save dgnorton/71c37265159c96fe5664 to your computer and use it in GitHub Desktop.
printf "creating database\n"
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE foo"
printf "creating retention policy\n"
curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY bar ON foo DURATION 5s REPLICATION 3 DEFAULT"
printf "inserting data\n"
curl -d '{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2015-01-26T22:01:11.703Z","values": {"value": 100}}]}' -H "Content-Type: application/json" http://localhost:8086/write
printf "querying data\n"
curl -G http://localhost:8086/query --data-urlencode "db=foo" --data-urlencode "q=SELECT * FROM cpu"
printf "\nwaiting for retention cleanup\n"
sleep 12
printf "inserting data after retention cleanup\n"
curl -d '{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2015-01-26T22:01:11.704Z","values": {"value": 200}}]}' -H "Content-Type: application/json" http://localhost:8086/write
printf "querying data after retention cleanup\n"
curl -G http://localhost:8086/query --data-urlencode "db=foo" --data-urlencode "q=SELECT * FROM cpu"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment