Getting started
Speculare Server is the core of the infrastructure. It is where all clients will send their metrics and where the dashboard will ask for historical data.
Note that the repository linked above host both Speculare Server and Speculare Alerts, the latter is cover in another section. We'll only cover Speculare Server on this page.

Setup

As of now Speculare Server does not provide easy setup solution such as a one-line installer (but it's planned). The current recommanded way to install Speculare Server is to build it from source. But don't be afraid, it's easy and straightforwards.

Install dependencies

Speculare Server is a Rust project that rely on some dependencies to be able to be built correctly. Much of them are default deps in most servers.
1
# Install Rust
2
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
3
4
# Install APT dependencies
5
sudo apt-get install libssl-dev libpq-dev pkg-config build-essential
Copied!

Build the binary

You can build the binary using:
1
cargo build --release
Copied!
The resulting binary will be located in ./target/release/server.

Setup an env file

The server config depends on a Server.toml file located at the root of the working dir.
This does not mean you will have to keep the source code after compilation, this just mean the Server.toml must be present at in the workdir from where you will execute the binary.
You can create your Server.toml from the ExampleServer.toml given in the source code or using the following template:
1
BINDING = "0.0.0.0:8080"
2
3
DATABASE_URL = "postgres://postgres:[email protected]/speculare?sslmode=disable"
4
5
DATABASE_MAX_CONNECTION = 10 # (optional [default = 10])
6
7
KEY_PRIV = "key.pem" # (optional)
8
KEY_CERT = "cert.pem" # (optional)
9
HTTPS = true # (optional [default = false])
10
11
API_TOKEN = "secret_password" # (used in Speculare-client)
12
13
RUST_LOG = "warn,server=info,actix_server=info,actix_web=info" # (optional [default = "error,actix_server=info,actix_web=error"])
Copied!

Apply setup migration to construct database

For this step you will have to methods:
Doing nothing...
Using Diesel_cli
This is the easiest solution... Just do nothing and the migrations will be applied automatically. Once you launch the binary, it will check if all the lastest migrations has been applied, and will applied them if not.
You might, however need to create the DATABASE inside TimescaleDB.
1
CREATE DATABASE database_name;
Copied!
This method is recommended if you want to work on the development of Speculare.
1
# Install the diesel_cli tool
2
cargo install diesel_cli --no-default-features --features postgres
3
4
# For diesel setup to works you need to be at the root of the project
5
diesel setup --database-url="postgres://xxx"
6
7
# If you've installed the diesel_cli you can also use it's migration commands
8
diesel migration run/add/revert/redo --database-url="postgres://xxx"
Copied!

Install as a service

Here is a sample speculare-server.service for systemd:
1
[Unit]
2
Description=Speculare Server Process
3
After=network.target postgresql.service
4
StartLimitIntervalSec=600
5
StartLimitBurst=10
6
7
[Service]
8
Restart=on-failure
9
RestartSec=60s
10
Group=www-data
11
WorkingDirectory=/root/speculare-server
12
ExecStart=/root/speculare-server/target/release/speculare-server
13
14
[Install]
15
WantedBy=multi-user.target
Copied!
The above service will start after postgres, this is important. The server cannot start before postgresql.
Last modified 2mo ago
Copy link
Contents
Setup