{"action":"created","comment":{"url":"https://api.github.com/repos/smartsdk/guided-tour/pulls/comments/184976748","pull_request_review_id":116274500,"id":184976748,"diff_hunk":"@@ -1,7 +1,113 @@\n # Store historical data, query them and use them to create dashboards\n \n+## Prerequisites\n+\n+This section of the guide starts assuming you have already\n+[deployed your platform](../platform/swarmcluster.md)\n+and [deployed the core services](../platform/deployservices.md). It also\n+assumes you have a data flow comming to your Orion Context Broker, as pointed\n+out in [this section](.contextbroker.md).\n+\n ## Store Air Quality data from Context Broker in QuantumLeap\n \n+QuantumLeap tracks historical data of the entities when it receives NGSI\n+notifications about inserts in Orion. Therefore, we need to create an NGSI\n+subscription in Orion to notify QuantumLeap of changes in the entities for which\n+we want to keep historical records.\n+\n+If you are well experienced with [Orion Subscriptions](http://fiware-orion.readthedocs.io/en/latest/user/walkthrough_apiv2/index.html#subscriptions),\n+you can create the subscription in Orion as you prefer, just make sure to use\n+the correct notify_url that the Orion instance would need to find QuantumLeap.\n+\n+Otherwise, you can ask QuantumLeap to do it for you. For this, there is an API\n+endpoint `/v2/subscribe` that will create the subscription in Orion. By default,\n+it will create a subscription to receive notification for ALL changes of ALL\n+entities that enter Orion. For this guide this is good enough; however, if you\n+want to adjust the scope of notifications, have a look at the `/v2/ui` endpoint\n+of your deployed QL (E.g `${QL_URL}/v2/ui`).\n+\n+If you are using the [SmartSDK Postman Collection](https://github.com/smartsdk/smartsdk-recipes/blob/master/recipes/tools/postman_collection.json),\n+you have already a prepared call for this endpoint within the QuantumLeap folder\n+(QL Subscribe).\n+\n+Otherwise, you can call the endpoint from the command line as follows (mind the IPs)...\n+\n+```\n+$ curl -X POST \\\n+  '${QL_URL}/v2/subscribe?orionUrl=${ORION_URL}/v2&quantumleapUrl=http://quantumleap:8668/v2' \\\n+  -H 'Accept: application/json'\n+```\n+\n+You should have received a **201 CREATED** code from the previous POST.\n+If you want to double-check all worked fine, query Orion subscriptions and see\n+if you spot this subscription for QuantumLeap. You'll find this query in the\n+postman collection also, otherwise you can do it using curl...\n+\n+```\n+$ curl -X GET ${ORION_URL}/v2/subscriptions/ -H 'Accept: application/json'\n+[{\"id\":\"5ae2faa8cfdf0100fa49eb1f\",\"description\":\"Created by QuantumLeap ...]\n+```\n+\n+If you want to track specific entity types only, use one subscription per each entity type.\n+\n+At this point, you may be thinking \"hold on, why asking QL to ask Orion to\n+notify him back?\". The answer is, Orion remains the central piece of many FIWARE\n+deployments, and being a Broker, all information flows through it for the first\n+time.\n+\n ## Query Air Quality data using QuantumLeap\n \n+QuantumLeap's Querying API is still under development, however you can already\n+make some tests with simple queries of historical data for 1 or N attributes of\n+a given entity.\n+\n+You will find these queries in the Postman Collection, or you can try them from\n+the command line...\n+\n+E.g: Historical values of `airqualityobserved_0`'s `precipitation`.\n+\n+```\n+$ curl -X GET \\\n+  '${QL_URL}/v2/entities/airqualityobserved_0/attrs/precipitation?type=AirQualityObserved' \\\n+  -H 'Accept: application/json'\n+```\n+\n+E.g: Last 4 Historical values of `airqualityobserved_0`'s `NO2` and `CO2`.\n+\n+```\n+$ curl -X GET \\\n+  '${QL_URL}/v2/entities/airqualityobserved_0?type=AirQualityObserved&attrs=NO2,CO&lastN=4' \\\n+  -H 'Accept: application/json'\n+```\n+\n+You can explore QuantumLeap's API at `${QL_URL}/v2/ui` or directly into the\n+[swagger specification](https://github.com/smartsdk/ngsi-timeseries-api/blob/master/specification/quantumleap.yml).\n+\n ## Creating nice dashboards using QuantumLeap and Grafana\n+\n+If you followed the section on [deploying your services](../platform/deployservices.md),\n+you should have access to an instance of [Grafana](https://grafana.com/) almost\n+ready to interact with your historical data.\n+\n+Let's assume you have your instance url saved in a variable called `GRAFANA_URL`.\n+\n+```\n+export GRAFANA_URL=http://192.168.99.100:3000\n+```\n+\n+Login to your instance ${GRAFANA_URL}/login. The default\n+credentials are `admin`/`admin`, but remember to change them afterwards.\n+\n+You need to first configure a datasource, which can only be done once you have\n+gone through the previous steps (i.e, QuantumLeap is already processing data).\n+Create one datasource per entity type you care about. Follow [these instructions](https://smartsdk.github.io/ngsi-timeseries-api/admin/grafana/).\n+\n+You are now ready to create your dashboards using the datasources!. If you want\n+to have something to get started with, you can got to [${GRAFANA_URL}/dashboard/import](${GRAFANA_URL}/dashboard/import)","path":"docs/services/quantumleap.md","position":108,"original_position":106,"commit_id":"f2d81ac6abf6dc26484a448d7c6f76facfaeef54","original_commit_id":"f121154b7b4505257f8b5969b2e39e8d1f2b6c15","user":{"login":"chicco785","id":777218,"avatar_url":"https://avatars3.githubusercontent.com/u/777218?v=4","gravatar_id":"","url":"https://api.github.com/users/chicco785","html_url":"https://github.com/chicco785","followers_url":"https://api.github.com/users/chicco785/followers","following_url":"https://api.github.com/users/chicco785/following{/other_user}","gists_url":"https://api.github.com/users/chicco785/gists{/gist_id}","starred_url":"https://api.github.com/users/chicco785/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chicco785/subscriptions","organizations_url":"https://api.github.com/users/chicco785/orgs","repos_url":"https://api.github.com/users/chicco785/repos","events_url":"https://api.github.com/users/chicco785/events{/privacy}","received_events_url":"https://api.github.com/users/chicco785/received_events","type":"User","site_admin":false},"body":"so it would be better not to document it as a link.","created_at":"2018-04-30T12:47:18Z","updated_at":"2018-04-30T12:47:18Z","html_url":"https://github.com/smartsdk/guided-tour/pull/9#discussion_r184976748","pull_request_url":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/smartsdk/guided-tour/pulls/comments/184976748"},"html":{"href":"https://github.com/smartsdk/guided-tour/pull/9#discussion_r184976748"},"pull_request":{"href":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9"}},"in_reply_to_id":184736527},"pull_request":{"url":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9","id":184635105,"html_url":"https://github.com/smartsdk/guided-tour/pull/9","diff_url":"https://github.com/smartsdk/guided-tour/pull/9.diff","patch_url":"https://github.com/smartsdk/guided-tour/pull/9.patch","issue_url":"https://api.github.com/repos/smartsdk/guided-tour/issues/9","number":9,"state":"open","locked":false,"title":"Add services documentation","user":{"login":"taliaga","id":4542117,"avatar_url":"https://avatars1.githubusercontent.com/u/4542117?v=4","gravatar_id":"","url":"https://api.github.com/users/taliaga","html_url":"https://github.com/taliaga","followers_url":"https://api.github.com/users/taliaga/followers","following_url":"https://api.github.com/users/taliaga/following{/other_user}","gists_url":"https://api.github.com/users/taliaga/gists{/gist_id}","starred_url":"https://api.github.com/users/taliaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taliaga/subscriptions","organizations_url":"https://api.github.com/users/taliaga/orgs","repos_url":"https://api.github.com/users/taliaga/repos","events_url":"https://api.github.com/users/taliaga/events{/privacy}","received_events_url":"https://api.github.com/users/taliaga/received_events","type":"User","site_admin":false},"body":"Complete services/contexbroker.md and services/quantumleap.md\r\n\r\nDepends on https://github.com/smartsdk/smartsdk-recipes/pull/37","created_at":"2018-04-27T14:16:47Z","updated_at":"2018-04-30T12:47:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9ce66a2d0a2839c3136b3a5114620df2234868e","assignee":null,"assignees":[],"requested_reviewers":[{"login":"smartsdkInfotec","id":22534090,"avatar_url":"https://avatars1.githubusercontent.com/u/22534090?v=4","gravatar_id":"","url":"https://api.github.com/users/smartsdkInfotec","html_url":"https://github.com/smartsdkInfotec","followers_url":"https://api.github.com/users/smartsdkInfotec/followers","following_url":"https://api.github.com/users/smartsdkInfotec/following{/other_user}","gists_url":"https://api.github.com/users/smartsdkInfotec/gists{/gist_id}","starred_url":"https://api.github.com/users/smartsdkInfotec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartsdkInfotec/subscriptions","organizations_url":"https://api.github.com/users/smartsdkInfotec/orgs","repos_url":"https://api.github.com/users/smartsdkInfotec/repos","events_url":"https://api.github.com/users/smartsdkInfotec/events{/privacy}","received_events_url":"https://api.github.com/users/smartsdkInfotec/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9/commits","review_comments_url":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9/comments","review_comment_url":"https://api.github.com/repos/smartsdk/guided-tour/pulls/comments{/number}","comments_url":"https://api.github.com/repos/smartsdk/guided-tour/issues/9/comments","statuses_url":"https://api.github.com/repos/smartsdk/guided-tour/statuses/f2d81ac6abf6dc26484a448d7c6f76facfaeef54","head":{"label":"smartsdk:doc-services","ref":"doc-services","sha":"f2d81ac6abf6dc26484a448d7c6f76facfaeef54","user":{"login":"smartsdk","id":26279498,"avatar_url":"https://avatars1.githubusercontent.com/u/26279498?v=4","gravatar_id":"","url":"https://api.github.com/users/smartsdk","html_url":"https://github.com/smartsdk","followers_url":"https://api.github.com/users/smartsdk/followers","following_url":"https://api.github.com/users/smartsdk/following{/other_user}","gists_url":"https://api.github.com/users/smartsdk/gists{/gist_id}","starred_url":"https://api.github.com/users/smartsdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartsdk/subscriptions","organizations_url":"https://api.github.com/users/smartsdk/orgs","repos_url":"https://api.github.com/users/smartsdk/repos","events_url":"https://api.github.com/users/smartsdk/events{/privacy}","received_events_url":"https://api.github.com/users/smartsdk/received_events","type":"Organization","site_admin":false},"repo":{"id":114655439,"name":"guided-tour","full_name":"smartsdk/guided-tour","owner":{"login":"smartsdk","id":26279498,"avatar_url":"https://avatars1.githubusercontent.com/u/26279498?v=4","gravatar_id":"","url":"https://api.github.com/users/smartsdk","html_url":"https://github.com/smartsdk","followers_url":"https://api.github.com/users/smartsdk/followers","following_url":"https://api.github.com/users/smartsdk/following{/other_user}","gists_url":"https://api.github.com/users/smartsdk/gists{/gist_id}","starred_url":"https://api.github.com/users/smartsdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartsdk/subscriptions","organizations_url":"https://api.github.com/users/smartsdk/orgs","repos_url":"https://api.github.com/users/smartsdk/repos","events_url":"https://api.github.com/users/smartsdk/events{/privacy}","received_events_url":"https://api.github.com/users/smartsdk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smartsdk/guided-tour","description":"A short guide to use SmartSDK platform","fork":false,"url":"https://api.github.com/repos/smartsdk/guided-tour","forks_url":"https://api.github.com/repos/smartsdk/guided-tour/forks","keys_url":"https://api.github.com/repos/smartsdk/guided-tour/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smartsdk/guided-tour/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smartsdk/guided-tour/teams","hooks_url":"https://api.github.com/repos/smartsdk/guided-tour/hooks","issue_events_url":"https://api.github.com/repos/smartsdk/guided-tour/issues/events{/number}","events_url":"https://api.github.com/repos/smartsdk/guided-tour/events","assignees_url":"https://api.github.com/repos/smartsdk/guided-tour/assignees{/user}","branches_url":"https://api.github.com/repos/smartsdk/guided-tour/branches{/branch}","tags_url":"https://api.github.com/repos/smartsdk/guided-tour/tags","blobs_url":"https://api.github.com/repos/smartsdk/guided-tour/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smartsdk/guided-tour/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smartsdk/guided-tour/git/refs{/sha}","trees_url":"https://api.github.com/repos/smartsdk/guided-tour/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smartsdk/guided-tour/statuses/{sha}","languages_url":"https://api.github.com/repos/smartsdk/guided-tour/languages","stargazers_url":"https://api.github.com/repos/smartsdk/guided-tour/stargazers","contributors_url":"https://api.github.com/repos/smartsdk/guided-tour/contributors","subscribers_url":"https://api.github.com/repos/smartsdk/guided-tour/subscribers","subscription_url":"https://api.github.com/repos/smartsdk/guided-tour/subscription","commits_url":"https://api.github.com/repos/smartsdk/guided-tour/commits{/sha}","git_commits_url":"https://api.github.com/repos/smartsdk/guided-tour/git/commits{/sha}","comments_url":"https://api.github.com/repos/smartsdk/guided-tour/comments{/number}","issue_comment_url":"https://api.github.com/repos/smartsdk/guided-tour/issues/comments{/number}","contents_url":"https://api.github.com/repos/smartsdk/guided-tour/contents/{+path}","compare_url":"https://api.github.com/repos/smartsdk/guided-tour/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smartsdk/guided-tour/merges","archive_url":"https://api.github.com/repos/smartsdk/guided-tour/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smartsdk/guided-tour/downloads","issues_url":"https://api.github.com/repos/smartsdk/guided-tour/issues{/number}","pulls_url":"https://api.github.com/repos/smartsdk/guided-tour/pulls{/number}","milestones_url":"https://api.github.com/repos/smartsdk/guided-tour/milestones{/number}","notifications_url":"https://api.github.com/repos/smartsdk/guided-tour/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smartsdk/guided-tour/labels{/name}","releases_url":"https://api.github.com/repos/smartsdk/guided-tour/releases{/id}","deployments_url":"https://api.github.com/repos/smartsdk/guided-tour/deployments","created_at":"2017-12-18T15:14:47Z","updated_at":"2018-04-26T12:33:46Z","pushed_at":"2018-04-30T09:19:10Z","git_url":"git://github.com/smartsdk/guided-tour.git","ssh_url":"git@github.com:smartsdk/guided-tour.git","clone_url":"https://github.com/smartsdk/guided-tour.git","svn_url":"https://github.com/smartsdk/guided-tour","homepage":null,"size":2225,"stargazers_count":2,"watchers_count":2,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":4,"open_issues":4,"watchers":2,"default_branch":"master"}},"base":{"label":"smartsdk:master","ref":"master","sha":"6c825f7ceb18cc66514bc9a7d3a2ce159d7694cc","user":{"login":"smartsdk","id":26279498,"avatar_url":"https://avatars1.githubusercontent.com/u/26279498?v=4","gravatar_id":"","url":"https://api.github.com/users/smartsdk","html_url":"https://github.com/smartsdk","followers_url":"https://api.github.com/users/smartsdk/followers","following_url":"https://api.github.com/users/smartsdk/following{/other_user}","gists_url":"https://api.github.com/users/smartsdk/gists{/gist_id}","starred_url":"https://api.github.com/users/smartsdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartsdk/subscriptions","organizations_url":"https://api.github.com/users/smartsdk/orgs","repos_url":"https://api.github.com/users/smartsdk/repos","events_url":"https://api.github.com/users/smartsdk/events{/privacy}","received_events_url":"https://api.github.com/users/smartsdk/received_events","type":"Organization","site_admin":false},"repo":{"id":114655439,"name":"guided-tour","full_name":"smartsdk/guided-tour","owner":{"login":"smartsdk","id":26279498,"avatar_url":"https://avatars1.githubusercontent.com/u/26279498?v=4","gravatar_id":"","url":"https://api.github.com/users/smartsdk","html_url":"https://github.com/smartsdk","followers_url":"https://api.github.com/users/smartsdk/followers","following_url":"https://api.github.com/users/smartsdk/following{/other_user}","gists_url":"https://api.github.com/users/smartsdk/gists{/gist_id}","starred_url":"https://api.github.com/users/smartsdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smartsdk/subscriptions","organizations_url":"https://api.github.com/users/smartsdk/orgs","repos_url":"https://api.github.com/users/smartsdk/repos","events_url":"https://api.github.com/users/smartsdk/events{/privacy}","received_events_url":"https://api.github.com/users/smartsdk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/smartsdk/guided-tour","description":"A short guide to use SmartSDK platform","fork":false,"url":"https://api.github.com/repos/smartsdk/guided-tour","forks_url":"https://api.github.com/repos/smartsdk/guided-tour/forks","keys_url":"https://api.github.com/repos/smartsdk/guided-tour/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smartsdk/guided-tour/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smartsdk/guided-tour/teams","hooks_url":"https://api.github.com/repos/smartsdk/guided-tour/hooks","issue_events_url":"https://api.github.com/repos/smartsdk/guided-tour/issues/events{/number}","events_url":"https://api.github.com/repos/smartsdk/guided-tour/events","assignees_url":"https://api.github.com/repos/smartsdk/guided-tour/assignees{/user}","branches_url":"https://api.github.com/repos/smartsdk/guided-tour/branches{/branch}","tags_url":"https://api.github.com/repos/smartsdk/guided-tour/tags","blobs_url":"https://api.github.com/repos/smartsdk/guided-tour/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smartsdk/guided-tour/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smartsdk/guided-tour/git/refs{/sha}","trees_url":"https://api.github.com/repos/smartsdk/guided-tour/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smartsdk/guided-tour/statuses/{sha}","languages_url":"https://api.github.com/repos/smartsdk/guided-tour/languages","stargazers_url":"https://api.github.com/repos/smartsdk/guided-tour/stargazers","contributors_url":"https://api.github.com/repos/smartsdk/guided-tour/contributors","subscribers_url":"https://api.github.com/repos/smartsdk/guided-tour/subscribers","subscription_url":"https://api.github.com/repos/smartsdk/guided-tour/subscription","commits_url":"https://api.github.com/repos/smartsdk/guided-tour/commits{/sha}","git_commits_url":"https://api.github.com/repos/smartsdk/guided-tour/git/commits{/sha}","comments_url":"https://api.github.com/repos/smartsdk/guided-tour/comments{/number}","issue_comment_url":"https://api.github.com/repos/smartsdk/guided-tour/issues/comments{/number}","contents_url":"https://api.github.com/repos/smartsdk/guided-tour/contents/{+path}","compare_url":"https://api.github.com/repos/smartsdk/guided-tour/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smartsdk/guided-tour/merges","archive_url":"https://api.github.com/repos/smartsdk/guided-tour/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smartsdk/guided-tour/downloads","issues_url":"https://api.github.com/repos/smartsdk/guided-tour/issues{/number}","pulls_url":"https://api.github.com/repos/smartsdk/guided-tour/pulls{/number}","milestones_url":"https://api.github.com/repos/smartsdk/guided-tour/milestones{/number}","notifications_url":"https://api.github.com/repos/smartsdk/guided-tour/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smartsdk/guided-tour/labels{/name}","releases_url":"https://api.github.com/repos/smartsdk/guided-tour/releases{/id}","deployments_url":"https://api.github.com/repos/smartsdk/guided-tour/deployments","created_at":"2017-12-18T15:14:47Z","updated_at":"2018-04-26T12:33:46Z","pushed_at":"2018-04-30T09:19:10Z","git_url":"git://github.com/smartsdk/guided-tour.git","ssh_url":"git@github.com:smartsdk/guided-tour.git","clone_url":"https://github.com/smartsdk/guided-tour.git","svn_url":"https://github.com/smartsdk/guided-tour","homepage":null,"size":2225,"stargazers_count":2,"watchers_count":2,"language":"Shell","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":4,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9"},"html":{"href":"https://github.com/smartsdk/guided-tour/pull/9"},"issue":{"href":"https://api.github.com/repos/smartsdk/guided-tour/issues/9"},"comments":{"href":"https://api.github.com/repos/smartsdk/guided-tour/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/smartsdk/guided-tour/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/smartsdk/guided-tour/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/smartsdk/guided-tour/statuses/f2d81ac6abf6dc26484a448d7c6f76facfaeef54"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"chicco785"}}