Finishing example text
|
|
@ -29,12 +29,14 @@ services:
|
|||
depends_on:
|
||||
- postgres
|
||||
|
||||
# scripts:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: Dockerfile.scripts
|
||||
# depends_on:
|
||||
# - thingsboard-ce
|
||||
scripts:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.scripts
|
||||
environment:
|
||||
TOKEN_COMPUTER: "c6ghQDyusdlqp2alV7rP"
|
||||
depends_on:
|
||||
- thingsboard-ce
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 134 KiB |
BIN
report/images/dashboard_customer.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
report/images/dashboard_widget.png
Normal file
|
After Width: | Height: | Size: 194 KiB |
BIN
report/images/device_active.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 211 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
102
report/report.md
|
|
@ -14,74 +14,112 @@ Idk small introduction text
|
|||
|
||||
Setup of ThingsBoard...
|
||||
|
||||
## Using ThingsBoard
|
||||
## Using ThingsBoard for Telemetry Data Injection
|
||||
|
||||
We will now demonstrate how to use ThingsBoard by injecting telemetry data. First we will create a tenant. This tenant can then add customers, and add users, assets, devices, dashboards and edges to each customer.
|
||||
In this guide, we will walk through the process of setting up and using ThingsBoard to inject telemetry data. This includes creating a tenant (i.e. a business that owns or produces devices and assets), adding customers (i.e. an individual, or an organization that purchases or uses tenant devices and / or assets) and devices, and visualizing data on a dashboard. By the end of this section, you will be able to monitor telemetry data live in ThingsBoard.
|
||||
|
||||
### Setting up a tenant
|
||||
### Creating a tenant
|
||||
|
||||
In this section we will set up a new tenant. When browsing to `http://localhost:8080` we land on the login page. We log in with the following credentials, the email is `sysadmin@thingsboard.org` with password `sysadmin`. Once we successfully logged in, we land on the home page.
|
||||
A tenant is the highest-level organizational unit in ThingsBoard, and all other entities like customers, devices and dashboards are linked to a tenant.
|
||||
|
||||
![[sysadmin_home.png]]
|
||||
Start by navigating to `http://localhost:8080`, where you will land on the login page. Use the following credentials to log in:
|
||||
- **Email**: `sysadmin@thingsboard.org`
|
||||
- **Password**: `sysadmin`
|
||||
Once logged in, you will be redirected to the home page.
|
||||
|
||||
To add a tenant we can navigate to the `tenants` page by using sidebar and clicking the `+` icon, or click on the `Add tenant` button on the home page.
|
||||
![[images/sysadmin_home.png]]
|
||||
|
||||
![[images/add_tenant.png]]
|
||||
To create a new tenant, go the the **Tenants** page from the sidebar and click the **+** icon
|
||||
, or click **Add Tenant** button directly from the home page.
|
||||
|
||||
After filling in the necessary information and adding the tenant, it should show up in the list of tenants.
|
||||
![[images/create_tenant.png]]
|
||||
|
||||
![[images/tenants_list.png]]
|
||||
Fill in the required information for the tenant and click **Add**. The tenant will appear in the tenant list.
|
||||
|
||||
To be able to log in as that tenant, we need to create an admin user for that tenant. Click on the three dots of our tenant, and click on `Manage tenant admins`. Fill in the information, click `Add` and activate the account (can be done through email if needed).
|
||||
![[images/tenant_list.png]]
|
||||
|
||||
![[add_tenant_admin.png]]
|
||||
To enable login for the tenant, you need to create an admin user. Click on the three dots next to the tenant name and select **Manage Tenant Admins**. Fill in the user details and click **Add**. Activate the account via email if needed.
|
||||
|
||||
If everything was successful, you are now redirected to the home page, logged in as the tenant sysadmin.
|
||||
![[images/create_tenant_admin.png]]
|
||||
|
||||
![[tenant_admin_home.png]]
|
||||
If successful, you will be redirected back to the home page, but now logged in as the tenant's sysadmin.
|
||||
|
||||
This concludes this section where we created a tenant. In the next section we will add a customer for this tenant.
|
||||
![[images/tenant_home.png]]
|
||||
|
||||
Now that the tenant is set up, we can proceed to add a customer in the next section.
|
||||
|
||||
### Setting up a customer
|
||||
|
||||
In this section we will add a customer to the tenant and also create a dashboard and add a device for this customer so we can inject data in the next section. We assume you are logged in as the tenant administrator. We can navigate to `customers` and click the `+` icon to create a new customer.
|
||||
A customer represents an organization or group that will have access to specific devices and dashboards. We will set everything up as the tenant administrator account.
|
||||
|
||||
![[images/add_customer.png]]
|
||||
In the **Customers** section, click the **+** icon to create a new customer.
|
||||
|
||||
The list of customer should be updated.
|
||||
![[images/create_customer.png]]
|
||||
|
||||
Once created, the customer will appear in the customer list.
|
||||
|
||||
![[images/customer_list.png]]
|
||||
|
||||
What we will do now is add a user, so we can log in as that customer and create a dashboard for the customer. We will start with adding the user, click on `Manage customer users`.
|
||||
To create a dashboard for the customer, navigate to the **Dashboards** section and click **Add Dashboard**. This will create an empty dashboard. Always make sure to save the dashboard before leaving the page.
|
||||
|
||||
![[images/add_user.png]]
|
||||
![[images/create_dashboard.png]]
|
||||
|
||||
This automatically redirects us to the new user account, but stay logged in as the tenant administrator. Now we can add a new dashboard to the customer by navigating to `Dashboards` and click `Add dashboard`.
|
||||
To inject data into the dashboard, we need to add a device from which the data will come. Navigate to **Entities > Devices** and click **Add Device**.
|
||||
|
||||
![[images/add_dashboard.png]]
|
||||
Fill in the required information for the device and assign it to the customer created earlier. After adding the device, you get a screen showing the instructions on how to send telemetry data to the platform.
|
||||
|
||||
This creates an empty dashboard, which we will fill in the next section. Don't forget to save when leaving the page! The only thing left to do is to add a device to our customer. Navigate to `Entities/Devices` and click `Add device`.
|
||||
![[create_device_1.png]]
|
||||
|
||||
![[images/add_device_1.png]]
|
||||
![[images/create_device_2.png]]
|
||||
|
||||
![[images/add_device_2.png]]
|
||||
|
||||
The second screen shows how to make a connection. For example, this is how you send data to the platform as the newly created device.
|
||||
For HTTP it essentially comes down to the following.
|
||||
|
||||
```
|
||||
curl -v -X POST http://localhost:8080/api/v1/qTbjXOHQTgRYzjbn3UxF/telemetry --header Content-Type:application/json --data "{temperature:25}"
|
||||
curl http://<server>/api/v1/<access_key>/telemetry --header Content-Type:application/json --data "{<key>:<value>}"
|
||||
```
|
||||
|
||||
The header is made up in the following way.
|
||||
When you try this out, you should see that the device is active and telemetry data has been received.
|
||||
|
||||
```
|
||||
http://<server>/api/v1/<key>/telemetry
|
||||
![[images/device_active.png]]
|
||||
|
||||
The last thing we need to do as a tenant, is to create a regular user account.
|
||||
|
||||
Navigate to **Customers** and click on **Manage customer users**. Click on the **+** icon to add a new user and fill in the required information.
|
||||
|
||||
![[images/create_user.png]]
|
||||
|
||||
After activating the account, you will be redirect to the home page of this user account. This user can not change any settings to the dashboard, devices ... as this is a read-only account. You could give the user the right privileges through role-based permissions, but this requires the Professional Edition of ThingsBoard!
|
||||
|
||||
### Visualizing telemetry data
|
||||
|
||||
Now that the everything is set up and we are able to send telemetry data, we can visualize the data on the dashboard. To make changes we need to be logged in as the tenant!
|
||||
|
||||
Navigate to **Dashboards** and select the dashboard associated with the customer. Edit the dashboard and click **Add Widget**. We chose for **Charts > Line Chart** as our visualization. The chart has many options, but we will set the most basic ones.
|
||||
- Changed the window to display the last 10 minutes.
|
||||
- Chose the created device as our source.
|
||||
- Changed the series to use the `memory_used` key-value pair.
|
||||
- Changed the series to read from MB but convert to GB
|
||||
- Changed the Y axes to better display the memory used.
|
||||
|
||||
![[images/dashboard_widget.png]]
|
||||
|
||||
To make this dashboard a live display of the memory used, we need to keep sending telemetry data. This is why we made a small script to do this, and made it as a docker service.
|
||||
|
||||
```bash
|
||||
while true; do
|
||||
memory_used=$(free -m | grep 'Mem' | awk '{print $3}')
|
||||
curl -s http://thingsboard-ce:8080/api/v1/qTbjXOHQTgRYzjbn3UxF/telemetry --header Content-Type:application/json --data "{memory_used:$memory_used}"
|
||||
sleep 1
|
||||
done
|
||||
```
|
||||
|
||||
And simply sends JSON data. Now that everything is created, and we briefly saw how to send data from the device, we can go to the next section to inject the telemetry data and make this visible on the dashboard.
|
||||
This should send the used memory to the platform every second.
|
||||
|
||||
### Injecting telemetry data
|
||||
The following is how the dashboard looks from the user account.
|
||||
|
||||
![[dashboard_customer.png]]
|
||||
|
||||
A lot more can be done, but then we suggest to read the [documentation](https://thingsboard.io/docs/).
|
||||
|
||||
## Discussion
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
while true; do
|
||||
mem_used=$(free -m | grep 'Mem' | awk '{print $3}')
|
||||
curl -s -X POST http://localhost:8080/api/v1/$KEY/telemetry --header Content-Type:application/json --data "{mem_used:$mem_used}"
|
||||
memory_used=$(free -m | grep 'Mem' | awk '{print $3}')
|
||||
curl -s -X POST http://thingsboard-ce:8080/api/v1/$TOKEN_COMPUTER/telemetry --header Content-Type:application/json --data "{memory_used:$memory_used}"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
|
|
|||