Set up and run
-
Create an API key.
-
Add your Device Management
API_KEY
towebapp/settings/development.py
. -
Download the
mbed_cloud_dev_credentials.c
file from Device Management Portal. -
Add your
mbed_cloud_dev_credentials.c
file to thembed-cloud-client-example
directory. -
Run the following in the root of your project:
docker-compose build docker-compose up --scale linux_client=3
This spins up four items:
- Three Linux client instances, each generating a data stream simulating a product on a shelf.
- The proxy web application for pushing the data stream from Device Management to InfluxDB.
- An InfluxDB instance.
- Grafana, where all the data aggregation and visualization happens.
-
To use Grafana to configure a visualization platform for analytics, go to
http://localhost:3001
. The login credentials are admin, admin.-
To add the Influx DB data source, select
InfluxDB
from the dropdown list.- URL:
http://influxdb:8086
. Docker automatically handles the resolution from InfluxDB to its URL according to its label in thedocker-compose
script. - DB: example
- Username: root
- Pass: root
- URL:
-
To add a dashboard:
- Create a graph.
- Select edit on the graph title.
- Go to metrics and add the following:
- FROM:
default product_count
- SELECT:
field(count) count() non_negative_difference()
- GROUP BY:
time(1s) tag(product_id) fill(previous)
- ALIAS BY:
$tag_product_id
- FROM:
-
This metric determines the level of product activity by first counting the number of interactions with a product (product taken, product returned) in a one-second interval. This is useful in understanding how much activity a particular shelf has. Additionally, computing the non-negative difference between the values gives insight into how consistent they are, and roughly translates to the velocity of product activity on a shelf.
Shutting down the application
Shut down the application with Ctrl-Z
and either:
-
Bring down the docker containers in the working directory with
docker-compose down
. -
Destroy the containers and delete persistent storage of saved TSDB values with
docker-compose down -v
.