Stand with Ukraine flag
Try it now Pricing
Trendz Analytics
Community Edition Professional Edition Cloud Edge PE Edge IoT Gateway License Server Trendz Analytics Mobile Application PE Mobile Application MQTT Broker
Installation > On premise > Ubuntu Server
Getting Started Documentation Guides
On this page

Installing ThingsBoard Trendz Analytics on Ubuntu

Prerequisites

This guide describes how to install Trendz Analytics on Ubuntu 18.04 LTS / Ubuntu 20.04 LTS.

Hardware requirements depend on amount of analyzed data and amount of devices connected to the system. To run Trendz Analytics on a single machine you will need at least 1Gb of free RAM.

In small and medium installations Trendz can be installed on the same server with ThingsBoard.

Step 1. Install Java 11 (OpenJDK)

ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11:

1
2
sudo apt update
sudo apt install openjdk-11-jdk

Please don’t forget to configure your operating system to use OpenJDK 11 by default. You can configure which version is the default using the following command:

1
sudo update-alternatives --config java

You can check the installation using the following command:

1
java -version

Expected command output is:

1
2
3
openjdk version "11.0.xx"
OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (build ...)

Step 2. Trendz Analytics service installation

Download installation package.

1
wget https://dist.thingsboard.io/trendz-1.11.0-RC7.deb

Install Trendz Analytics as a service

1
sudo dpkg -i trendz-1.11.0-RC7.deb

Step 3. Obtain and configure license key

We assume you have already chosen subscription plan for Trendz and have license key. If not, please get your Free Trial license before you proceed. See How-to get pay-as-you-go subscription for more details.

Once you get the license secret, you should put it to the trendz configuration file. Open the file for editing using the following command:

1
sudo nano /etc/trendz/conf/trendz.conf

Add the following lines to the configuration file and put your license secret:

1
2
# License secret obtained from ThingsBoard License Portal (https://license.thingsboard.io)
export TRENDZ_LICENSE_SECRET=YOUR_LICENSE_SECRET_HERE

Step 4. Configure connection with ThingsBoard Platform

You can connect Trendz Analytics to the ThingsBoard Community Edition or ThingsBoard Professional Edition.

Edit ThingsBoard configuration file

1
sudo nano /etc/trendz/conf/trendz.conf

Add ThingsBoard REST API URL that would be used for communicating with ThingsBoard Platform. In most cases, when Trendz installed in the same server with ThingsBoard, API_URL would be http://localhost:8080. Otherwise you should use ThingsBoard domain name.

1
2
# ThingsBoard URL that will be used by Trendz
export TB_API_URL=http://localhost:8080

Step 5. Configure Trendz database

Trendz uses PostgreSQL as a database. You can install PostgreSQL on the same serverfor Trendz or use managed PostgreSQL service from your cloud vendor.

PostgreSQL Installation

Instructions listed below will help you to install PostgreSQL.

1
2
3
4
5
6
7
8
9
10
11
12
13
# install **wget** if not already installed:
sudo apt install -y wget

# import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# add repository contents to your system:
echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee  /etc/apt/sources.list.d/pgdg.list

# install and launch the postgresql service:
sudo apt update
sudo apt -y install postgresql-15
sudo service postgresql start

Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. The instructions below will help to set the password for main postgresql user

1
2
3
4
sudo su - postgres
psql
\password
\q

Create Database for Trendz

Then, press “Ctrl+D” to return to main user console and connect to the database to create trendz DB:

1
2
3
psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE trendz;
\q

Configure database connection for Trendz

Edit Trendz configuration file

1
sudo nano /etc/trendz/conf/trendz.conf

Add the following lines to the configuration file. Don’t forget to replace “PUT_YOUR_POSTGRESQL_PASSWORD_HERE” with your real postgres user password:

1
2
3
4
# DB Configuration 
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/trendz
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE

Step 6. Run installation script

Once Trendz service is installed and DB configuration is updated, you can execute the following script:

1
sudo /usr/share/trendz/bin/install/install.sh

Step 7. Start Trendz service

Execute the following command to start Trendz Analytics:

1
sudo service trendz start

Once started, you will be able to open Web UI using the following link:

1
http://localhost:8888/trendz

Note: If Trendz installed on a remote server, you have to replace localhost with the public IP address of the server or with a domain name. Also, check that port 8888 opened for public access.

Authentication

For first authentication you need to use Tenant Administrator credentials from your ThingsBoard

Trendz uses ThingsBoard as an authentication service. During first sign in ThingsBoard service should be also available to validate credentials.

Step 8. Install Trendz Python executor

For writing custom Python models and transformation script you need to install Python libraries on the server where Trendz is installed. Alternative option is to run executor as a docker container, you can find how to do that in install instructions for Docker. But in this section we will write how to install Python libraries directly on the server with Trendz.

  • Install Python3
    1
    2
    3
    
    sudo apt update
    sudo apt install python3
    sudo apt install python3-pip
    
  • Install required python packages
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    echo "flask == 2.3.2" > requirements.txt
    echo "numpy == 1.24.1" >> requirements.txt
    echo "statsmodels == 0.13.5" >> requirements.txt
    echo "pandas == 1.5.3" >> requirements.txt
    echo "scikit-learn == 1.2.2" >> requirements.txt
    echo "prophet == 1.1.3" >> requirements.txt
    echo "seaborn == 0.12.2" >> requirements.txt
    echo "pmdarima == 2.0.3" >> requirements.txt
    sudo -u trendz pip3 install --user --no-cache-dir -r requirements.txt
    

Step 9. HTTPS configuration

You may want to configure HTTPS access using HAProxy. This is possible in case you are hosting Trendz in the cloud and have a valid DNS name assigned to your instance.

Trendz and ThingsBoard hosted on same server

Use this section if HAProxy/Let’s Encrypt already installed in the server and HTTPS enabled for ThingsBoard.

Open HAProxy configuration file

1
sudo nano /etc/haproxy/haproxy.cfg

Locate frontend https_in section, add new access list that will match traffic by domain name and redirect this traffic to Trendz backend:

1
2
acl trendz_http hdr(host) -i new-trendz-domain.com
use_backend tb-trendz if trendz_http

In the same file register Trendz backend:

1
2
3
4
5
6
backend tb-trendz
  balance leastconn
  option tcp-check
  option log-health-checks
  server tbTrendz1 127.0.0.1:8888 check inter 5s
  http-request set-header X-Forwarded-Port %[dst_port]

Generate SSL certificates for new domain:

1
sudo certbot-certonly --domain new-trendz-domain.com --email [email protected]

Refresh HAProxy configuration:

1
sudo haproxy-refresh

That’s it, HTTPS for Trendz UI configured and now you can access it via: https://new-trendz-domain.com

Fresh installation on new server

Please follow this guide to install HAProxy and generate valid SSL certificate using Let’s Encrypt.

Step 10. Host ThingsBoard and Trendz on the same domain

ThingsBoard and Trendz can share same domain name. In this case ThingsBoard web page would be loaded using following link:

1
https://{my-domain}/

and Trendz web page would be loaded using following link

1
https://{my-domain}/trendz

For enabling such configuration we have to update HAProxy config to route specific requests to Trendz service. Open HAProxy configuration file

1
sudo nano /etc/haproxy/haproxy.cfg

Locate frontend https_in section, add new access list that will match traffic by URL path and redirect this traffic to Trendz backend:

1
2
3
4
...
acl trendz_acl path_beg /trendz path_beg /apiTrendz
....
use_backend tb-trendz if trendz_acl

Troubleshooting

Trendz logs are stored in the following directory:

1
/var/log/trendz

You can issue the following command in order to check if there are any errors on the backend side:

1
cat /var/log/trendz/trendz.log | grep ERROR

Next steps