{"info":{"_postman_id":"b5650122-d605-4517-ae17-fa21733d725d","name":"FIWARE Querying Time Series Data (Mongo-DB)","description":"<html><head></head><body><p>This tutorial is an introduction to <a href=\"https://fiware-sth-comet.readthedocs.io/\">FIWARE STH-Comet</a> - a generic enabler which is used to retrieve trend data from a Mongo-DB database. The tutorial activates the IoT sensors connected in the <a href=\"https://github.com/Fiware/tutorials.IoT-Agent\">previous tutorial</a> and persists measurements from those sensors into a database and retrieves time-based aggregations of that data.</p>\n<p>The <code>docker-compose</code> files for this tutorial can be found on GitHub: </p>\n<p><img src=\"https://fiware.github.io/tutorials.Short-Term-History/icon/GitHub-Mark-32px.png\" alt=\"GitHub\"> <a href=\"https://github.com/Fiware/tutorials.Short-Term-History\">FIWARE 303: Short Term Historic Data</a></p>\n<h1 id=\"querying-time-series-data\">Querying Time Series Data</h1>\n<blockquote>\n<p>\"The <em>\"moment\"</em> has no yesterday or tomorrow. It is not the result of thought and therefore has no time.\"</p>\n<p>— Bruce Lee</p>\n</blockquote>\n<p>Within the FIWARE platform, historical context data can be persisted to a database using a combination of the <strong>Orion \nContext Broker</strong> and the <strong>Cygnus</strong> generic enabler. This results in a series of data points being written to the\ndatabase of your choice. Each time-stamped data point represents the state of context entities at a given moment in time.\nThe individual data points are relatively meaningless on their own, it is only through combining a series data points\nthat meaningful statistics such as maxima, minima and trends can be observed.</p>\n<p>The creation and analysis of trend data is a common requirement of context-driven systems - therefore the FIWARE platform \noffers a generic enabler (<a href=\"https://fiware-sth-comet.readthedocs.io/\">STH-Comet</a>) specifically to deal with the issue of persisting and interpreting time series data. <strong>STH-Comet</strong> itself can be used in two modes:</p>\n<ul>\n<li>In <em>minimal</em> mode, <strong>STH-Comet</strong> is responsible for both data collection and interpreting the data when requested</li>\n<li>In <em>formal</em> mode, the collection of data is delegated to <strong>Cygnus</strong>, <strong>STH-Comet</strong> merely reads from an existing database.</li>\n</ul>\n<p>Of the two modes of operation, the <em>formal</em> mode is more flexible, but <em>minimal</em> mode is simpler and easier to set-up. The key differences between the two are summarized in the table below:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th></th>\n<th><em>minimal</em> mode</th>\n<th><em>formal</em> mode</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Is the system easy to set-up  properly?</td>\n<td>Only one configuration supported - Easy to set up</td>\n<td>Highly configurable - Complex to set up</td>\n</tr>\n<tr>\n<td>Which component is responsible for a data persistance?</td>\n<td><strong>STH-Comet</strong></td>\n<td><strong>Cygnus</strong></td>\n</tr>\n<tr>\n<td>What is the role of <strong>STH-Comet</strong>?</td>\n<td>Reading and writing data</td>\n<td>Data Read only</td>\n</tr>\n<tr>\n<td>What is the role of <strong>Cygnus</strong>?</td>\n<td>Not Used</td>\n<td>Data Write only</td>\n</tr>\n<tr>\n<td>Where is the data aggregated?</td>\n<td>Mongo-DB database connected to <strong>STH-Comet</strong> only</td>\n<td>Mongo-DB database connected to both <strong>Cygnus</strong> and <strong>STH-Comet</strong></td>\n</tr>\n<tr>\n<td>Can the system be configured to use other databases?</td>\n<td>No</td>\n<td>Yes</td>\n</tr>\n<tr>\n<td>Does the solution scale easily?</td>\n<td>Does not scale easily - use for simple systems</td>\n<td>Scales easily - use for complex systems</td>\n</tr>\n<tr>\n<td>Can the system cope with high rates of throughput?</td>\n<td>No - use where throughput is low</td>\n<td>Yes - use where throughput is high</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"analyzing-time-series-data\">Analyzing time series data</h2>\n<p>The appropriate use of time series data analysis will depend on your use case and the reliability of the data measurements you receive. Time series data analysis can be used to answer questions such as:</p>\n<ul>\n<li>What was the maximum measurement of a device within a given time period?</li>\n<li>What was the average measurement of a device within a given time period?</li>\n<li>What was the sum of the measurements sent by a device within a given time period?</li>\n</ul>\n<p>It can also be used to reduce the signficance of each individual data point to exclude outliers by smoothing.</p>\n<h4 id=\"device-monitor\">Device Monitor</h4>\n<p>For the purpose of this tutorial, a series of dummy IoT devices have been created, which will be attached to the context broker. Details of the architecture and protocol used can be found in the <a href=\"https://github.com/Fiware/tutorials.IoT-Sensors\">IoT Sensors tutorial</a>.\nThe state of each device can be seen on the UltraLight device monitor web-page found at: <code>http://localhost:3000/device/monitor</code></p>\n<p><img src=\"https://fiware.github.io/tutorials.Short-Term-History/img/device-monitor.png\" alt=\"FIWARE Monitor\"></p>\n<h1 id=\"architecture\">Architecture</h1>\n<p>This application builds on the components and dummy IoT devices created in \n<a href=\"https://github.com/Fiware/tutorials.IoT-Agent/\">previous tutorials</a>. It will use three or four FIWARE components depending on the configuration of the system:\nthe <a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a>, the\n<a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/\">IoT Agent for Ultralight 2.0</a>,\n<a href=\"http://fiware-cygnus.readthedocs.io/en/latest/\">STH-Comet</a> and\n<a href=\"http://fiware-cygnus.readthedocs.io/en/latest/\">Cygnus</a>. </p>\n<p>Therefore the overall architecture will consist of the following elements:</p>\n<ul>\n<li>Four <strong>FIWARE Generic Enablers</strong>:<ul>\n<li>The FIWARE <a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a> which will receive requests using <a href=\"https://fiware.github.io/specifications/OpenAPI/ngsiv2\">NGSI</a></li>\n<li>The FIWARE <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/\">IoT Agent for Ultralight 2.0</a> which will receive northbound measurements from the dummy IoT devices in <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">Ultralight 2.0</a> format and convert them to <a href=\"https://fiware.github.io/specifications/OpenAPI/ngsiv2\">NGSI</a> requests for the context broker to alter the state of the context entities</li>\n<li>FIWARE <a href=\"http://fiware-sth-comet.readthedocs.io/\">STH-Comet</a> will:<ul>\n<li>interpret time-based data queries</li>\n<li>subscribe to context changes and persist them into a <strong>Mongo-DB</strong> database  (<em>minimal</em> mode only)</li>\n</ul>\n</li>\n<li>FIWARE <a href=\"http://fiware-cygnus.readthedocs.io/en/latest/\">Cygnus</a> where it will subscribe to context changes and persist them into a <strong>Mongo-DB</strong> database (<em>formal</em> mode only)</li>\n</ul>\n</li>\n</ul>\n<blockquote>\n<p>:information_source: <strong>Note:</strong> <strong>Cygnus</strong> will only be used if <strong>STH-Comet</strong> is configured in <em>formal</em> mode.</p>\n</blockquote>\n<ul>\n<li>A <a href=\"https://www.mongodb.com/\">MongoDB</a> database:<ul>\n<li>Used by the <strong>Orion Context Broker</strong> to hold context data information such as data entities, subscriptions and registrations</li>\n<li>Used by the <strong>IoT Agent</strong> to hold device information such as device URLs and Keys</li>\n<li>Used as a data sink to hold time-based historical context data<ul>\n<li>In <em>minimal</em> mode - this is read and populated by <strong>STH-Comet</strong> </li>\n<li>In <em>formal</em> mode - this is populated by <strong>Cygnus</strong>  and read by <strong>STH-Comet</strong></li>\n</ul>\n</li>\n</ul>\n</li>\n<li>Three <strong>Context Providers</strong>:<ul>\n<li>The <strong>Stock Management Frontend</strong> is not used in this tutorial. It does the following:<ul>\n<li>Display store information and allow users to interact with the dummy IoT devices</li>\n<li>Show which products can be bought at each store</li>\n<li>Allow users to \"buy\" products and reduce the stock count.</li>\n</ul>\n</li>\n<li>A webserver acting as set of <a href=\"https://github.com/Fiware/tutorials.IoT-Sensors\">dummy IoT devices</a> using the <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">Ultralight 2.0</a> protocol running over HTTP.</li>\n<li>The <strong>Context Provider NGSI</strong> proxy is not used in this tutorial. It does the following:<ul>\n<li>receive requests using <a href=\"https://fiware.github.io/specifications/OpenAPI/ngsiv2\">NGSI</a></li>\n<li>makes requests to publicly available data sources using their own APIs in a proprietary format </li>\n<li>returns context data back to the Orion Context Broker in <a href=\"https://fiware.github.io/specifications/OpenAPI/ngsiv2\">NGSI</a> format.</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n<p>Since all interactions between the elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports. </p>\n<p>The specific architecture of both the <em>minimal</em> and <em>formal</em> configurations is discussed below.</p>\n<h1 id=\"prerequisites\">Prerequisites</h1>\n<h2 id=\"docker-and-docker-compose\">Docker and Docker Compose</h2>\n<p>To keep things simple all components will be run using <a href=\"https://www.docker.com\">Docker</a>. <strong>Docker</strong> is a container technology which allows to different components isolated into their respective environments. </p>\n<ul>\n<li>To install Docker on Windows follow the instructions <a href=\"https://docs.docker.com/docker-for-windows/\">here</a></li>\n<li>To install Docker on Mac follow the instructions <a href=\"https://docs.docker.com/docker-for-mac/\">here</a></li>\n<li>To install Docker on Linux follow the instructions <a href=\"https://docs.docker.com/install/\">here</a></li>\n</ul>\n<p><strong>Docker Compose</strong> is a tool for defining and running multi-container Docker applications. A  series of <a href=\"https://raw.githubusercontent.com/Fiware/tutorials.Historic-Context/master/cygnus\">YAML files</a> are used configure the required\nservices for the application. This means all container services can be brought up in a single command. Docker Compose is installed by default as part of Docker for Windows and  Docker for Mac, however Linux users will need to follow the instructions found <a href=\"https://docs.docker.com/compose/install/\">here</a></p>\n<h2 id=\"cygwin-for-windows\">Cygwin for Windows</h2>\n<p>We will start up our services using a simple Bash script. Windows users should download <a href=\"http://www.cygwin.com/\">cygwin</a> to provide a command line functionality similar to a Linux distribution on Windows.</p>\n<h1 id=\"start-up\">Start Up</h1>\n<p>Before you start you should ensure that you have obtained or built the necessary Docker images locally. Please run</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services create\n</code></pre>\n<blockquote>\n<p><strong>Note</strong> The <code>context-provider</code> image has not yet been pushed to Docker hub.\nFailing to build the Docker sources before proceeding will result in the following error:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>Pulling context-provider (fiware/cp-web-app:latest)...\nERROR: The image for the service you're trying to recreate has been removed.\n</code></pre></blockquote>\n<p>Thereafter, all services can be initialized from the command line by running the <a href=\"https://github.com/Fiware/tutorials.Historic-Context/blob/master/services\">services</a> Bash script provided within the repository:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services &lt;command&gt;\n</code></pre>\n<p>Where <code>&lt;command&gt;</code> will vary depending upon the mode we wish to activate.\nThis command will also import seed data from the previous tutorials and provision the dummy IoT sensors on startup.</p>\n<blockquote>\n<p>:information_source: <strong>Note:</strong> If you want to clean up and start over again you can do so with the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services stop\n</code></pre>\n</blockquote>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Querying Time Series Data","slug":"querying-time-series-data"},{"content":"Architecture","slug":"architecture"},{"content":"Prerequisites","slug":"prerequisites"},{"content":"Start Up","slug":"start-up"}],"owner":"513743","collectionId":"b5650122-d605-4517-ae17-fa21733d725d","publishedId":"RWEgqe8Q","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"233C68"},"publishDate":"2020-01-02T11:07:30.000Z"},"item":[{"name":"Minimal Mode (STH-Comet only) ","item":[{"name":"STH-Comet - Obtain version information","id":"07ebc47c-b139-4978-ab00-0ede19f38598","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/version","description":"<p>Once STH-Comet is running, You can check the status by making an HTTP request to the exposed <code>STH_PORT</code> port. \nIf the response is blank, this is usually because STH-Comet is not running or is listening on another port.</p>\n<blockquote>\n<p><strong>Troubleshooting:</strong> What if the response is blank ?</p>\n<ul>\n<li>To check that a docker container is running try</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-bash\">docker ps\n</code></pre>\n<p>You should see several containers running. If <code>sth-comet</code> is not running, you can restart the containers as necessary.</p>\n</blockquote>\n","urlObject":{"protocol":"http","path":["version"],"host":["localhost:8666"],"query":[],"variable":[]}},"response":[],"_postman_id":"07ebc47c-b139-4978-ab00-0ede19f38598"},{"name":"Orion - STH-Comet - Aggregate Motion Sensor Count Events","id":"b9e3e17f-a3f9-43d4-ac71-f7dacfc431fc","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"raw","raw":"{\n  \"description\": \"Notify STH-Comet of all Motion Sensor count changes\",\n  \"subject\": {\n    \"entities\": [\n      {\n        \"idPattern\": \"Motion.*\"\n      }\n    ],\n    \"condition\": {\n      \"attrs\": [\n        \"count\"\n      ]\n    }\n  },\n  \"notification\": {\n    \"http\": {\n      \"url\": \"http://sth-comet:8666/notify\"\n    },\n    \"attrs\": [\n      \"count\"\n    ],\n    \"attrsFormat\": \"legacy\"\n  }\n}"},"url":"http://localhost:1026/v2/subscriptions/","description":"<p>Once a dynamic context system is up and running, we need to inform <strong>STH-Comet</strong> directly of changes in context.\nThe rate of change of the <strong>Motion Sensor</strong> is driven by events in the real-world. We need to receive\nevery event to be able to aggregate the results.</p>\n<p>This is done by making a POST request to the <code>/v2/subscription</code> endpoint of the Orion Context Broker.</p>\n<ul>\n<li>The <code>fiware-service</code> and <code>fiware-servicepath</code> headers are used to filter the subscription to only listen to measurements from the attached IoT Sensors</li>\n<li>The <code>idPattern</code> in the request body ensures that <strong>STH-Comet</strong> will be informed of all <strong>Motion Sensor</strong> data changes.</li>\n<li>The notification <code>url</code> must match the configured <code>STH_PORT</code></li>\n<li>The <code>attrsFormat=legacy</code> is required since <strong>STH-Comet</strong> currently only accepts notifications in the older NGSI v1 format.</li>\n</ul>\n","urlObject":{"protocol":"http","path":["v2","subscriptions",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"b9e3e17f-a3f9-43d4-ac71-f7dacfc431fc"},{"name":"Orion - STH-Comet - Sample Lamp Luminosity","id":"aa0ede41-b8ab-4ee7-8495-82b4e2d546aa","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"raw","raw":"{\n  \"description\": \"Notify STH-Comet to sample Lamp changes every five seconds\",\n  \"subject\": {\n    \"entities\": [\n      {\n        \"idPattern\": \"Lamp.*\"\n      }\n    ],\n    \"condition\": {\n      \"attrs\": [\n        \"luminosity\"\n      ]\n    }\n  },\n  \"notification\": {\n    \"http\": {\n      \"url\": \"http://sth-comet:8666/notify\"\n    },\n    \"attrs\": [\n      \"luminosity\"\n    ],\n    \"attrsFormat\": \"legacy\"\n  },\n  \"throttling\": 5\n}"},"url":"http://localhost:1026/v2/subscriptions/","description":"<p>Once a dynamic context system is up and running, we need to inform <strong>STH-Comet</strong> directly of changes in context.</p>\n<p>The luminosity of the <strong>Smart Lamp</strong> is constantly changing, we only need to <strong>sample</strong> the values to be\nable to work out relevant statistics such as minimum and maximum values and rates of change.</p>\n<p>This is done by making a POST request to the <code>/v2/subscription</code> endpoint of the Orion Context Broker\nand including the <code>throttling</code> attribute in the request body.</p>\n<ul>\n<li>The <code>fiware-service</code> and <code>fiware-servicepath</code> headers are used to filter the subscription to only listen to measurements from the attached IoT Sensors</li>\n<li>The <code>idPattern</code> in the request body ensures that <strong>STH-Comet</strong> will be informed of all <strong>Smart Lamp</strong> data changes only</li>\n<li>The notification <code>url</code> must match the configured <code>STH_PORT</code></li>\n<li>The <code>attrsFormat=legacy</code> is required since <strong>STH-Comet</strong> currently only accepts notifications in the older NGSI v1 format.</li>\n<li>The <code>throttling</code> value defines the rate that changes are sampled.</li>\n</ul>\n","urlObject":{"protocol":"http","path":["v2","subscriptions",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"aa0ede41-b8ab-4ee7-8495-82b4e2d546aa"},{"name":"Orion - STH-Comet Check Subscriptions are working","id":"a31dc7ec-502a-48f1-acfd-441a6c1d6337","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"raw","raw":""},"url":"http://localhost:1026/v2/subscriptions/","description":"<p>If the subscription have been created, you can check to see if they are firing by making a GET \nrequest to the <code>/v2/subscriptions</code> endpoint.</p>\n<p>Within the <code>notification</code> section of the response, you can see several additional <code>attributes</code> which describe the health of the subscription</p>\n<p>If the criteria of the subscription have been met, <code>timesSent</code> should be greater than <code>0</code>.\nA zero value would indicate that the <code>subject</code> of the subscription is incorrect or the subscription \nhas created with the wrong <code>fiware-service-path</code> or <code>fiware-service</code> header</p>\n<p>The <code>lastNotification</code> should be a recent timestamp - if this is not the case, then the devices\nare not regularly sending data. Remember to unlock the <strong>Smart Door</strong> and switch on the <strong>Smart Lamp</strong></p>\n<p>The <code>lastSuccess</code> should match the <code>lastNotification</code> date - if this is not the case \nthen <strong>STH-Comet</strong> is not receiving the subscription properly. Check that the host name\nand port are correct. </p>\n<p>Finally, check that the <code>status</code> of the subscription is <code>active</code> - an expired subscription\nwill not fire.</p>\n","urlObject":{"protocol":"http","path":["v2","subscriptions",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"a31dc7ec-502a-48f1-acfd-441a6c1d6337"}],"id":"fbfe4be2-af15-41ee-9736-829c91613522","description":"<p>In the <em>minimal</em> configuration, <strong>STH-Comet</strong> is used to persisting historic context data and also used to make time-based queries.\nAll operations take place on the same port <code>8666</code>. The MongoDB instance listening on the standard\n<code>27017</code> port is used to hold data the historic context data as well as holding data related to the <strong>Orion Context Broker</strong> and the <strong>IoT Agent</strong>.\nThe overall architecture can be seen below:</p>\n<p><img src=\"https://fiware.github.io/tutorials.Short-Term-History/img/sth-comet.png\" alt /></p>\n<h2 id=\"database-server-configuration\">Database Server Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  mongo-db:\n    image: mongo:3.6\n    hostname: mongo-db\n    container_name: db-mongo\n    ports:\n        - \"27017:27017\"\n    networks:\n        - default\n    command: --bind_ip_all --smallfiles\n</code></pre>\n<h2 id=\"sth-comet-configuration\">STH-Comet Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  sth-comet:\n    image: fiware/sth-comet\n    hostname: sth-comet\n    container_name: fiware-sth-comet\n    depends_on:\n        - mongo-db\n    networks:\n        - default\n    ports:\n        - \"8666:8666\"\n    environment:\n        - STH_HOST=0.0.0.0\n        - STH_PORT=8666\n        - DB_PREFIX=sth_\n        - DB_URI=mongo-db:27017\n        - LOGOPS_LEVEL=DEBUG\n</code></pre>\n<p>The <code>sth-comet</code> container is listening on one port: </p>\n<ul>\n<li>The Operations for port for STH-Comet - <code>8666</code> is where the service will be listening for notifications from the Orion context broker as well\nas time based query requests from cUrl or Postman</li>\n</ul>\n<p>The <code>sth-comet</code> container is driven by environment variables as shown:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>STH_HOST</td>\n<td><code>0.0.0.0</code></td>\n<td>The address where STH-Comet is hosted - within this container it means all IPv4 addresses on the local machine</td>\n</tr>\n<tr>\n<td>STH_PORT</td>\n<td><code>8666</code></td>\n<td>Operations Port that STH-Comet listens on, it is also used when subscribing to context data changes</td>\n</tr>\n<tr>\n<td>DB_PREFIX</td>\n<td><code>sth_</code></td>\n<td>The prefix added to each database entity if none is provided</td>\n</tr>\n<tr>\n<td>DB_URI</td>\n<td><code>mongo-db:27017</code></td>\n<td>The  Mongo-DB server which STH-Comet will contact to persist historical context data</td>\n</tr>\n<tr>\n<td>LOGOPS_LEVEL</td>\n<td><code>DEBUG</code></td>\n<td>The logging level for STH-Comet</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"minimal-configuration---start-up\"><em>minimal</em> configuration - Start up</h2>\n<p>To start the system using the <em>minimal</em> configuration using <strong>STH-Comet</strong>  only, run the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services sth-comet\n</code></pre>\n","event":[{"listen":"prerequest","script":{"id":"a63e990e-c30a-419c-a54c-5d24baa792f2","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d2710f35-1e52-4ac5-87ad-d7a93c640386","type":"text/javascript","exec":[""]}}],"_postman_id":"fbfe4be2-af15-41ee-9736-829c91613522"},{"name":"Formal Mode (Cygnus + STH-Comet)","item":[{"name":"Cygnus - Obtain version information","id":"f8a20caf-5d0d-4a58-bd39-78657f61c6e7","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:5080/v1/version","description":"<p>Once Cygnus is running, You can check the status by making an HTTP request to the exposed <code>CYGNUS_API_PORT</code> port. \nIf the response is blank, this is usually because Cygnus is not running or is listening on another port.</p>\n<blockquote>\n<p><strong>Troubleshooting:</strong> What if the response is blank ?</p>\n<ul>\n<li>To check that a docker container is running try</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-bash\">docker ps\n</code></pre>\n<p>You should see several containers running. If <code>cygnus</code> is not running, you can restart the containers as necessary.</p>\n</blockquote>\n","urlObject":{"protocol":"http","path":["v1","version"],"host":["localhost:5080"],"query":[],"variable":[]}},"response":[],"_postman_id":"f8a20caf-5d0d-4a58-bd39-78657f61c6e7"},{"name":"STH-Comet - Obtain version information","id":"a77a2e1c-de78-431b-8aac-a1294a5b7205","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/version","description":"<p>Once STH-Comet is running, You can check the status by making an HTTP request to the exposed <code>STH_PORT</code> port. \nIf the response is blank, this is usually because STH-Comet is not running or is listening on another port.</p>\n<blockquote>\n<p><strong>Troubleshooting:</strong> What if the response is blank ?</p>\n<ul>\n<li>To check that a docker container is running try</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-bash\">docker ps\n</code></pre>\n<p>You should see several containers running. If <code>sth-comet</code> is not running, you can restart the containers as necessary.</p>\n</blockquote>\n","urlObject":{"protocol":"http","path":["version"],"host":["localhost:8666"],"query":[],"variable":[]}},"response":[],"_postman_id":"a77a2e1c-de78-431b-8aac-a1294a5b7205"},{"name":"Orion - Cygnus - Aggregate Motion Sensor Count Events","id":"2c472896-103b-4239-94cb-8bea10959d83","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"raw","raw":"{\n  \"description\": \"Notify Cygnus of all Motion Sensor count changes\",\n  \"subject\": {\n    \"entities\": [\n      {\n        \"idPattern\": \"Motion.*\"\n      }\n    ],\n    \"condition\": {\n      \"attrs\": [\n        \"count\"\n      ]\n    }\n  },\n  \"notification\": {\n    \"http\": {\n      \"url\": \"http://cygnus:5051/notify\"\n    },\n    \"attrs\": [\n      \"count\"\n    ]\n  }\n}"},"url":"http://localhost:1026/v2/subscriptions/","description":"<p>Once a dynamic context system is up and running, we need to inform <strong>Cygnus</strong> of changes in context.\n<strong>Cygnus</strong> will store the historical context data in a Mongo-DB database and <strong>STH-Comet</strong> will only\nbe used to read the persisted data.</p>\n<p>The rate of change of the <strong>Motion Sensor</strong> is driven by events in the real-world. We need to receive\nevery event to be able to aggregate the results.</p>\n<p>This is done by making a POST request to the <code>/v2/subscription</code> endpoint of the <strong>Orion Context Broker</strong>.</p>\n<ul>\n<li>The <code>fiware-service</code> and <code>fiware-servicepath</code> headers are used to filter the subscription to only listen to measurements from the attached IoT Sensors</li>\n<li>The <code>idPattern</code> in the request body ensures that <strong>Cygnus</strong>  will be informed of all <strong>Motion Sensor</strong> data changes.</li>\n<li>The notification <code>url</code> must match the configured <code>CYGNUS_MONGO_SERVICE_PORT</code></li>\n</ul>\n","urlObject":{"protocol":"http","path":["v2","subscriptions",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"2c472896-103b-4239-94cb-8bea10959d83"},{"name":"Orion - Cygnus - Sample Lamp Luminosity","id":"c7ee6bcf-f25a-40d4-b31e-a28a94e4d5bf","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"raw","raw":"{\n  \"description\": \"Notify Cygnus to sample Lamp changes every five seconds\",\n  \"subject\": {\n    \"entities\": [\n      {\n        \"idPattern\": \"Lamp.*\"\n      }\n    ],\n    \"condition\": {\n      \"attrs\": [\n        \"luminosity\"\n      ]\n    }\n  },\n  \"notification\": {\n    \"http\": {\n      \"url\": \"http://cygnus:5051/notify\"\n    },\n    \"attrs\": [\n      \"luminosity\"\n    ]\n  },\n  \"throttling\": 5\n}"},"url":"http://localhost:1026/v2/subscriptions/","description":"<p>Once a dynamic context system is up and running, we need to inform <strong>Cygnus</strong> of changes in context.\n<strong>Cygnus</strong> will store the historical context data in a Mongo-DB database and <strong>STH-Comet</strong> will only\nbe used to read the persisted data.</p>\n<p>The luminosity of the <strong>Smart Lamp</strong> is constantly changing, we only need to <strong>sample</strong> the values to be\nable to work out relevant statistics such as minimum and maximum values and rates of change.</p>\n<p>This is done by making a POST request to the <code>/v2/subscription</code> endpoint of the <strong>Orion Context Broker</strong>\nand including the <code>throttling</code> attribute in the request body.</p>\n<ul>\n<li>The <code>fiware-service</code> and <code>fiware-servicepath</code> headers are used to filter the subscription to only listen to measurements from the attached IoT Sensors</li>\n<li>The <code>idPattern</code> in the request body ensures that <strong>Cygnus</strong> will be informed of all <strong>Smart Lamp</strong> data changes only</li>\n<li>The notification <code>url</code> must match the configured <code>CYGNUS_MONGO_SERVICE_PORT</code></li>\n<li>The <code>throttling</code> value defines the rate that changes are sampled.</li>\n</ul>\n","urlObject":{"protocol":"http","path":["v2","subscriptions",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"c7ee6bcf-f25a-40d4-b31e-a28a94e4d5bf"},{"name":"Orion - Cygnus - Check Subscriptions are working","id":"6fb5017f-6a30-4cb6-a0b5-f3a26696e07d","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"raw","raw":""},"url":"http://localhost:1026/v2/subscriptions/","description":"<p>If the subscriptions have been created, you can check to see if they is firing by making a GET \nrequest to the <code>/v2/subscriptions</code> endpoint.</p>\n<p>Within the <code>notification</code> section of the response, you can see several additional <code>attributes</code> which describe the health of the subscription</p>\n<p>If the criteria of the subscription have been met, <code>timesSent</code> should be greater than <code>0</code>.\nA zero value would indicate that the <code>subject</code> of the subscription is incorrect or the subscription \nhas created with the wrong <code>fiware-service-path</code> or <code>fiware-service</code> header</p>\n<p>The <code>lastNotification</code> should be a recent timestamp - if this is not the case, then the devices\nare not regularly sending data. Remember to unlock the <strong>Smart Door</strong> and switch on the <strong>Smart Lamp</strong></p>\n<p>The <code>lastSuccess</code> should match the <code>lastNotification</code> date - if this is not the case \nthen <strong>Cygnus</strong> is not receiving the subscription properly. Check that the host name\nand port are correct. </p>\n<p>Finally, check that the <code>status</code> of the subscription is <code>active</code> - an expired subscription\nwill not fire.</p>\n","urlObject":{"protocol":"http","path":["v2","subscriptions",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"6fb5017f-6a30-4cb6-a0b5-f3a26696e07d"}],"id":"5ae8856f-954c-4e6b-a577-e03644bebb70","description":"<p>The <em>formal</em> configuration is uses <strong>Cygnus</strong> to persist historic context data into a MongoDB database in the same manner as had been presented in the\n<a href=\"https://github.com/Fiware/tutorials.Historic-Context\">previous tutorial</a>. The existing MongoDB instance (listening on the standard\n<code>27017</code> port) is used to hold data related to the <strong>Orion Context Broker</strong>, the <strong>IoT Agent</strong> and the historic\ncontext data persisted by <strong>Cygnus</strong>. <strong>STH-Comet</strong> is also attached to the same database to read data from it. The overall architecture can be seen below:</p>\n<p><img src=\"https://fiware.github.io/tutorials.Short-Term-History/img/cygnus-sth-comet.png\" alt /></p>\n<h2 id=\"database-server-configuration\">Database Server Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  mongo-db:\n    image: mongo:3.6\n    hostname: mongo-db\n    container_name: db-mongo\n    ports:\n        - \"27017:27017\"\n    networks:\n        - default\n    command: --bind_ip_all --smallfiles\n</code></pre>\n<h2 id=\"sth-comet-configuration\">STH-Comet Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  sth-comet:\n    image: fiware/sth-comet\n    hostname: sth-comet\n    container_name: fiware-sth-comet\n    depends_on:\n        - mongo-db\n    networks:\n        - default\n    ports:\n        - \"8666:8666\"\n    environment:\n        - STH_HOST=0.0.0.0\n        - STH_PORT=8666\n        - DB_PREFIX=sth_\n        - DB_URI=mongo-db:27017\n        - LOGOPS_LEVEL=DEBUG\n</code></pre>\n<h2 id=\"cygnus-configuration\">Cygnus Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  cygnus:\n    image: fiware/cygnus-ngsi:latest\n    hostname: cygnus\n    container_name: fiware-cygnus\n    depends_on:\n        - mongo-db\n    networks:\n        - default\n    expose:\n        - \"5080\"\n    ports:\n        - \"5050:5050\"\n        - \"5080:5080\"\n    environment:\n        - \"CYGNUS_MONGO_HOSTS=mongo-db:27017\"\n        - \"CYGNUS_LOG_LEVEL=DEBUG\"\n        - \"CYGNUS_SERVICE_PORT=5050\"\n        - \"CYGNUS_API_PORT=5080\"\n</code></pre>\n<p>The <code>sth-comet</code> container is listening on one port: </p>\n<ul>\n<li>The Operations for port for STH-Comet - <code>8666</code> is where the service will be listening for time based query requests from cUrl or Postman</li>\n</ul>\n<p>The <code>sth-comet</code> container is driven by environment variables as shown:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>STH_HOST</td>\n<td><code>0.0.0.0</code></td>\n<td>The address where STH-Comet is hosted - within this container it means all IPv4 addresses on the local machine</td>\n</tr>\n<tr>\n<td>STH_PORT</td>\n<td><code>8666</code></td>\n<td>Operations Port that STH-Comet listens on</td>\n</tr>\n<tr>\n<td>DB_PREFIX</td>\n<td><code>sth_</code></td>\n<td>The prefix added to each database entity if none is provided</td>\n</tr>\n<tr>\n<td>DB_URI</td>\n<td><code>mongo-db:27017</code></td>\n<td>The  Mongo-DB server which STH-Comet will contact to persist historical context data</td>\n</tr>\n<tr>\n<td>LOGOPS_LEVEL</td>\n<td><code>DEBUG</code></td>\n<td>The logging level for STH-Comet</td>\n</tr>\n</tbody>\n</table>\n</div><p>The <code>cygnus</code> container is listening on two ports: </p>\n<ul>\n<li>The Subscription Port for Cygnus - <code>5050</code> is where the service will be listening for notifications from the Orion context broker</li>\n<li>The Management Port for Cygnus - <code>5080</code> is exposed purely for tutorial access - so that cUrl or Postman can make provisioning commands\nwithout being part of the same network.</li>\n</ul>\n<p>The <code>cygnus</code> container is driven by environment variables as shown:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>CYGNUS_MONGO_HOSTS</td>\n<td><code>mongo-db:27017</code></td>\n<td>Comma separated list of Mongo-DB servers which Cygnus will contact to persist historical context data</td>\n</tr>\n<tr>\n<td>CYGNUS_LOG_LEVEL</td>\n<td><code>DEBUG</code></td>\n<td>The logging level for Cygnus</td>\n</tr>\n<tr>\n<td>CYGNUS_SERVICE_PORT</td>\n<td><code>5050</code></td>\n<td>Notification Port that Cygnus listens when subscribing to context data changes</td>\n</tr>\n<tr>\n<td>CYGNUS_API_PORT</td>\n<td><code>5080</code></td>\n<td>Port that Cygnus listens on for operational reasons</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"formal-configuration---start-up\"><em>formal</em> configuration - Start up</h2>\n<p>To start the system using the <em>formal</em> configuration using <strong>Cygnus</strong>  and <strong>STH-Comet</strong>, run the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services cygnus\n</code></pre>\n","event":[{"listen":"prerequest","script":{"id":"f8ca5d71-4eb4-42b9-95e0-c3ef11567514","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"43d701ab-eb41-472e-875e-4ac51e27579a","type":"text/javascript","exec":[""]}}],"_postman_id":"5ae8856f-954c-4e6b-a577-e03644bebb70"},{"name":"Time Series Data Queries","item":[{"name":"List  the first N Sampled Values","id":"634bac5f-2f02-428d-91dd-d17d7596ba70","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Lamp/id/Lamp:001/attributes/luminosity?hLimit=3&hOffset=0","description":"<p>This example shows the first 3 sampled <code>luminosity</code> values from <code>Lamp:001</code>. </p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>the <code>hLimit</code> parameter restricts the result to N values. <code>hOffset=0</code> will start with the first value.</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Lamp","id","Lamp:001","attributes","luminosity"],"host":["localhost:8666"],"query":[{"description":{"content":"<p>The number of entries per page.</p>\n","type":"text/plain"},"key":"hLimit","value":"3"},{"description":{"content":"<p>The pagination offset</p>\n","type":"text/plain"},"key":"hOffset","value":"0"}],"variable":[]}},"response":[],"_postman_id":"634bac5f-2f02-428d-91dd-d17d7596ba70"},{"name":"List N Sampled Values at an Offset","id":"94016943-ef04-48ed-b75e-4653cae0f707","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Motion/id/Motion:001/attributes/count?hLimit=3&hOffset=3","description":"<p>This example shows the fourth, fifth and sixth sampled <code>count</code> values from <code>Motion:001</code>. </p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>the <code>hLimit</code> parameter restricts the result to N values. \nSetting <code>hOffset</code> to a non-zero value will start from the Nth measurement</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Motion","id","Motion:001","attributes","count"],"host":["localhost:8666"],"query":[{"description":{"content":"<p>The number of entries per page.</p>\n","type":"text/plain"},"key":"hLimit","value":"3"},{"description":{"content":"<p>The pagination offset</p>\n","type":"text/plain"},"key":"hOffset","value":"3"}],"variable":[]}},"response":[],"_postman_id":"94016943-ef04-48ed-b75e-4653cae0f707"},{"name":"List the latest N sampled Values","id":"66f98b01-e076-475a-8d21-603caaae9288","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Motion/id/Motion:001/attributes/count?lastN=3","description":"<p>This example shows latest three sampled <code>count</code> values from <code>Motion:001</code>. </p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>if the <code>lastN</code> parameter is set, the result will return the N latest measurements only.</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Motion","id","Motion:001","attributes","count"],"host":["localhost:8666"],"query":[{"description":{"content":"<p>The number of entries to return</p>\n","type":"text/plain"},"key":"lastN","value":"3"}],"variable":[]}},"response":[],"_postman_id":"66f98b01-e076-475a-8d21-603caaae9288"},{"name":"List the Sum of Values over a time period","id":"be790a37-1abf-4773-8612-99b212973f0e","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Motion/id/Motion:001/attributes/count?aggrMethod=sum&aggrPeriod=minute","description":"<p>This example shows total <code>count</code> values from <code>Motion:001</code> over each minute</p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>The <code>aggrMethod</code> parameter determines the type of aggregation to perform over the time series, \nthe <code>aggrPeriod</code> is one of <code>second</code>, <code>minute</code>, <code>hour</code> or <code>day</code>. </p>\n<p>Always select the most appropiate time period based on the frequency of your data collection.\n<code>minute</code> has been selected because the <code>Motion:001</code> is firing a few times within each minute.</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Motion","id","Motion:001","attributes","count"],"host":["localhost:8666"],"query":[{"key":"aggrMethod","value":"sum"},{"key":"aggrPeriod","value":"minute"},{"disabled":true,"description":{"content":"<p>The starting date and time</p>\n","type":"text/plain"},"key":"dateFrom","value":"2018-01-01T00:00:00.000Z"},{"disabled":true,"description":{"content":"<p>The final date and time</p>\n","type":"text/plain"},"key":"dateTo","value":"2019-12-31T00:00:00.000Z"}],"variable":[]}},"response":[],"_postman_id":"be790a37-1abf-4773-8612-99b212973f0e"},{"name":"List the Minimum Values over a time period","id":"dde8db9a-fb84-454f-a5be-dddcf94f4432","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Lamp/id/Lamp:001/attributes/luminosity?aggrMethod=min&aggrPeriod=minute","description":"<p>This example shows minimum <code>luminosity</code> values from <code>Lamp:001</code> over each minute</p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>The <code>aggrMethod</code> parameter determines the type of aggregation to perform over the time series, \nthe <code>aggrPeriod</code> is one of <code>second</code>, <code>minute</code>, <code>hour</code> or <code>day</code>. </p>\n<p>The luminocity of the <strong>Smart Lamp</strong> is continually changing and therefore tracking the minimum value makes sense.\nThe <strong>Motion Sensor</strong> is not suitable for this as it only offers binary values.</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Lamp","id","Lamp:001","attributes","luminosity"],"host":["localhost:8666"],"query":[{"key":"aggrMethod","value":"min"},{"key":"aggrPeriod","value":"minute"},{"disabled":true,"description":{"content":"<p>The starting date and time</p>\n","type":"text/plain"},"key":"dateFrom","value":"2018-01-01T00:00:00.000Z"},{"disabled":true,"description":{"content":"<p>The final date and time</p>\n","type":"text/plain"},"key":"dateTo","value":"2019-12-31T00:00:00.000Z"}],"variable":[]}},"response":[],"_postman_id":"dde8db9a-fb84-454f-a5be-dddcf94f4432"},{"name":"List the Maximum Values over a time period","id":"ca3a9141-e621-4646-b7e1-b9deeec7baa0","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Lamp/id/Lamp:001/attributes/luminosity?aggrMethod=max&aggrPeriod=minute","description":"<p>This example shows maximum <code>luminosity</code> values from <code>Lamp:001</code> over each minute</p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>The <code>aggrMethod</code> parameter determines the type of aggregation to perform over the time series, \nthe <code>aggrPeriod</code> is one of <code>second</code>, <code>minute</code>, <code>hour</code> or <code>day</code>.</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Lamp","id","Lamp:001","attributes","luminosity"],"host":["localhost:8666"],"query":[{"key":"aggrMethod","value":"max"},{"key":"aggrPeriod","value":"minute"},{"disabled":true,"description":{"content":"<p>The starting date and time</p>\n","type":"text/plain"},"key":"dateFrom","value":"2018-01-01T00:00:00.000Z"},{"disabled":true,"description":{"content":"<p>The final date and time</p>\n","type":"text/plain"},"key":"dateTo","value":"2019-12-31T00:00:00.000Z"}],"variable":[]}},"response":[],"_postman_id":"ca3a9141-e621-4646-b7e1-b9deeec7baa0"},{"name":"List Average Values over a time period","id":"2e1e9b78-84f6-49c1-b0f9-93344c535ce9","request":{"method":"GET","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:8666/STH/v1/contextEntities/type/Lamp/id/Lamp:001/attributes/luminosity?aggrMethod=sum&aggrPeriod=minute","description":"<p>Querying for the mean value within a time period is not directly supported.\nThis example shows sum of <code>luminosity</code> values from <code>Lamp:001</code> over each minute.\nWhen combined with the number of samples the within the time period an average can be calculated from the data.</p>\n<p>To obtain the short term history of a context entity attribute, send a GET request to\n<code>../STH/v1/contextEntities/type/&lt;Entity&gt;/id/&lt;entity-id&gt;/attributes/&lt;attribute&gt;</code></p>\n<p>The <code>aggrMethod</code> parameter determines the type of aggregation to perform over the time series, \nthe <code>aggrPeriod</code> is one of <code>second</code>, <code>minute</code>, <code>hour</code> or <code>day</code>.</p>\n","urlObject":{"protocol":"http","path":["STH","v1","contextEntities","type","Lamp","id","Lamp:001","attributes","luminosity"],"host":["localhost:8666"],"query":[{"key":"aggrMethod","value":"sum"},{"key":"aggrPeriod","value":"minute"},{"disabled":true,"description":{"content":"<p>The starting date and time</p>\n","type":"text/plain"},"key":"dateFrom","value":"2018-01-01T00:00:00.000Z"},{"disabled":true,"description":{"content":"<p>The final date and time</p>\n","type":"text/plain"},"key":"dateTo","value":"2019-12-31T00:00:00.000Z"}],"variable":[]}},"response":[],"_postman_id":"2e1e9b78-84f6-49c1-b0f9-93344c535ce9"}],"id":"276620eb-17ba-4afa-b1fd-38c6630f21ef","description":"<p>The queries in this section assume you have already connected <strong>STH-Comet</strong> using either <em>minimal</em> mode or <em>formal</em> mode and have collected some data.</p>\n","event":[{"listen":"prerequest","script":{"id":"9e70a754-3893-4617-adc7-c0471f7372f7","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"c43d1162-ac29-4852-9094-b1b86604352b","type":"text/javascript","exec":[""]}}],"_postman_id":"276620eb-17ba-4afa-b1fd-38c6630f21ef"}],"event":[{"listen":"prerequest","script":{"id":"d1cff9ac-8932-417c-b6e2-582ba712ff79","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"cc3f098c-a786-4112-a15e-b1c8c83cc657","type":"text/javascript","exec":[""]}}],"variable":[{"key":"orion","value":"localhost:1026"},{"key":"cygnus","value":"localhost:5080"},{"key":"sth-comet","value":"localhost:8666"}]}