#Figure 2 For our demo, we'll use the theme of website visitor tracking, i.e. visitor arrive, browse, click and we collect data on their actions.
Let's start with a simple recording of a user visiting our website.
{
"user": "itay",
"visits": 1
}
Note that the event contain a single dimension named user with the value itay and a single metric named visits with the value of 1.
We will pushing the above event into the visits
collection. Joola will create the collection if it doesn't exist.
$ curl -X POST -H 'Content-Type: application/json' -d '{
"user": "itay",
"visits": 1
}' http://localhost:8080/insert/visits?APIToken=apitoken-demo
#####Response
Joola returns the document as it was saved into MongoDB. Note that Joola added a timestamp
indicating the exact point in time it received the event for processing. Also, the saved document contains a timebucket
to assist with future queries.
[
{
"user": "itay",
"visits": 1,
"timestamp": "2014-12-29T21:09:33.530Z",
"timestamp_timebucket": {
"dow": 1,
"hod": 23,
"second": "2014-12-29T21:09:33.000Z",
"minute": "2014-12-29T21:09:00.000Z",
"hour": "2014-12-29T21:00:00.000Z",
"ddate": "2014-12-29T00:00:00.000Z",
"month": "2014-12-01T00:00:00.000Z",
"year": "2014-01-01T00:00:00.000Z"
},
"ourTimestamp": "2014-12-29T21:09:33.537Z",
"saved": true
}
]
#####Response Headers There are a bunch of response headers you might find useful.
HTTP/1.1 200 OK
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
X-joola-Request-Id: MSQELAXayqsDR5HwHG123rx1f1KUfLWN:1419887621341:mt5uLtJSD92HbPxXkluXRP1coxhla0Qd
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-RateLimit-Limit: 9999999999
X-RateLimit-Remaining: 9999999933
X-RateLimit-Reset: 1419890341
Retry-After: 2720
X-joola-Duration: 15
X-joola-Requested-By: MSQELAXayqsDR5HwHG123rx1f1KUfLWN
X-joola-Fulfilled-By: MSQELAXayqsDR5HwHG123rx1f1KUfLWN
X-joola-Duration-Fulfilled: 10
Content-Type: application/json; charset=utf-8
Content-Length: 374
Vary: Accept-Encoding
Date: Mon, 29 Dec 2014 21:13:41 GMT
Connection: keep-alive