Database
1. Overview
Friendly QoE Monitoring operates with four databases:
| Database | Engine | Description |
|---|---|---|
Main DB |
MySQL / Oracle |
Core IoT ACS data — CPE devices, product class groups, monitored parameters, user accounts |
UI DB |
MySQL / Oracle |
QoE-specific data — KPI definitions, custom views, device groups, group templates, alarm thresholds |
Quartz DB |
MySQL / Oracle |
Scheduler persistence — job definitions, triggers, cluster coordination |
ClickHouse |
ClickHouse |
Time-series storage — KPI measurements, diagnostic results, alarm history |
2. Configuration (MySQL / Oracle)
The application uses Spring profiles to switch between MySQL and Oracle databases. Set the active profile via the SPRING_PROFILES_ACTIVE environment variable.
2.1. MySQL Profile
spring:
profiles: mysql
datasource:
main:
url: ${MAIN_DB_URL}
username: ${MAIN_DB_USERNAME}
password: ${MAIN_DB_PASSWORD}
ui:
url: ${UI_DB_URL}
username: ${UI_DB_USERNAME}
password: ${UI_DB_PASSWORD}
2.2. Oracle Profile
spring:
profiles: oracle
datasource:
main:
url: ${MAIN_DB_URL}
username: ${MAIN_DB_USERNAME}
password: ${MAIN_DB_PASSWORD}
ui:
url: ${UI_DB_URL}
username: ${UI_DB_USERNAME}
password: ${UI_DB_PASSWORD}
2.3. Externalized SQL
Database queries are stored in sql.properties files with separate variants for MySQL and Oracle. When modifying queries:
-
Check
sql.propertiesfor the externalized query -
Update both MySQL and Oracle variants if applicable
-
Test with both profiles if the query differs between dialects
3. ClickHouse Time-Series Storage
ClickHouse stores all time-series monitoring data. It is optimized for high-volume analytical queries over large datasets.
3.1. Connection Configuration
clickhouse:
url: ${CLICKHOUSE_DB_URL}
username: ${CLICKHOUSE_DB_USERNAME}
password: ${CLICKHOUSE_DB_PASSWORD}
3.3. Monitoring Data Tables
| Table | Engine | Description |
|---|---|---|
|
MergeTree |
Raw monitored parameter values received from devices (created, serial, name_id, value, periodic, location_id, orig_name_id). Partitioned by date, ordered by serial, name_id, created. |
|
MergeTree |
Calculated KPI values displayed on graphs (created, serial, kpi_id, value, periodic, kpi_value_num, name_id, name_ids_in_formula). Partitioned by date, ordered by serial, kpi_id, created. |
|
MergeTree |
KPI data points that triggered an alarm. Same structure as |
|
ReplacingMergeTree |
Monitor start/stop timestamps per device and parameter (started, finished, serial, name_id). |
|
MergeTree |
User action audit log (created, username, type_id, session_id, description). |
|
TinyLog |
Database schema version tracking (version, created). |
3.4. Alarm Tables
| Table | Engine | Description |
|---|---|---|
|
ReplacingMergeTree |
Single device alarm history (id, created, updated, serial, kpi_id, child_kpi_id, value, threshold_condition, state, level, isp_id, group_id). |
|
ReplacingMergeTree |
Devices participating in group alarms (group_id, kpi_id, child_kpi_id, serials array, isp_id, cnt, created). Partitioned by group_id. |
3.5. Diagnostic Tables
| Table | Engine | Description |
|---|---|---|
|
ReplacingMergeTree |
Upload/Download diagnostic results — FCC (created, serial, completed, name, value, value_total, file_size, test_bytes, total_bytes, num_conn, bom_time, eom_time, gpv_sent, ip_addr, login_name, host_url). |
|
ReplacingMergeTree |
IPPing diagnostic results — FCC (created, serial, completed, value, success_cnt, failure_cnt, avg_resp_time, gpv_sent, ip_addr, login_name, host). |
|
ReplacingMergeTree |
Trace route diagnostic state (id UUID, created, serial, completed, data_size, max_hops, host, gpv_sent, ip_addr, login_name). |
|
MergeTree |
Trace route hop-by-hop results (diag_trace_id, created, hop, error_code, host, host_address, times). |
|
ReplacingMergeTree |
UDP echo diagnostic results (id UUID, created, serial, completed, success_cnt, failure_cnt, avg_resp_time, min_resp_time, max_resp_time, gpv_sent, ip_addr, login_name, host). |
|
MergeTree |
UDP echo individual packet results (udp_echo_id, created, serial, num, success, send_time, receive_time, gen_sn, resp_sn, rcv_ts, reply_ts, failure_cnt). |
3.6. Wi-Fi Tables
| Table | Engine | Description |
|---|---|---|
|
ReplacingMergeTree |
Wi-Fi Neighboring Diagnostic results and channel change history (created, completed, serial, name_id, ssid, channel, changing, thresh_ssid, thresh_signal, prev_channel, isp_id). |
|
MergeTree |
Detected Wi-Fi channel collisions (created, serial, name_id, ssid, channel, signal). |
|
ReplacingMergeTree |
Wi-Fi diagnostic task tracking (created, serial, completed, gpv_sent). |
3.7. User Experience Tables
| Table | Engine | Description |
|---|---|---|
|
MergeTree |
User experience host data (created, serial, name_id, mac, name, interface_type, layer1, layer3, addr, active). |
|
MergeTree |
User experience associated device data (created, serial, name_id, mac, rssi, signal). |
|
MergeTree |
Connected hosts data — ETL feature (created, serial, name_id, name, mac, ipv4, ipv6, connectivity, ssid, bssid, rssi). |
|
MergeTree |
Router device data — ETL feature (created, serial, mac, ipv4, ipv6, ssid24, bssid24, ssid5, bssid5, byte_sent, byte_received). |
3.8. Cached Data from Main DB
| Table | Engine | Description |
|---|---|---|
|
ReplacingMergeTree |
Device product data (serial, group_id, product_class, manufacturer_name, created). |
|
Join(ANY, LEFT, serial) |
QoE CPE data (serial, mac, periodic, product_class, manufacturer_name, last_connection, updated). |
|
Join(ANY, LEFT, serial) |
Account information (serial, login_name, name, location, telephone, userid, userstatus, user_tag, zip, latitude, longitude, updated, cust1-cust20). |
|
Join(ANY, LEFT, serial) |
Domain data (id, isp_id, serial, updated, isp_name). |
|
Tables with |
3.9. Materialized Views
| View | Engine | Description |
|---|---|---|
|
AggregatingMergeTree |
Pre-aggregated KPI data in 5-minute intervals for Device Groups page. Stores avg, min, max states per kpi_id, kpi_value_num, serial. |
|
ReplacingMergeTree |
Latest KPI value per device and KPI. Automatically updated when |
|
ReplacingMergeTree |
Latest raw parameter value per device and parameter. Automatically updated when |
3.10. Data Retention
The nightly job QoeOldDataDeleteTask removes history older than Keep data (days) (Settings > General, default 90, at most 3650; 0 switches retention off). All history tables are partitioned by the day of their row date, so an expired day is removed as a whole partition with ALTER TABLE … DROP PARTITION. This is a metadata operation, unlike the ALTER TABLE … DELETE mutation the job used before. The cutoff is computed once in ClickHouse server time, and only days strictly before the day of the cutoff are dropped. As long as the cutoff is correct, no row inside the retention window is removed; a partition that still holds live state is kept whole (see the table).
The job checks the cutoff before it drops anything. The cutoff is today() - n in ClickHouse Date arithmetic (subtractDays(today(), n)), not a DateTime interval, so a daylight-saving change at midnight (Santiago, Cairo, Tehran and others) cannot move it by a day. ClickHouse Date is a 16-bit day count and wraps for a very large number of days (subtractDays(today(), 20746) gives a date in 2149, 99999 days a date in 2111), which would put the cutoff in the future or on an unrelated day. The job therefore stops with an ERROR in the log and removes nothing when the cutoff is not strictly before the server’s today, is before 1970-01-02, or is not exactly Keep data (days) before today; the ERROR names the cutoff received and the one expected. The settings page rejects values above 3650 for the same reason.
A partition is also dropped only if its partition column is a plain Date/DateTime or a DateTime in the server time zone. A column such as DateTime('UTC') on a server in another zone reports the same partition expression toDate(created) but its days start at a different hour, so the table is skipped with a warning. Zone names are compared by their rules, so an alias of the server zone (Europe/Kiev and Europe/Kyiv, Etc/UTC and UTC) is accepted.
| Table | Partition key | Handling |
|---|---|---|
|
|
Expired partitions are dropped. |
|
|
Expired partitions are dropped, except a partition that still holds an active alarm (latest row by |
|
|
Expired partitions are dropped, except a partition that holds an interval that is still open ( |
|
|
Materialized view. The partitions are listed from, and dropped in, the inner table ( |
If a table has a different partition key than the one above (an older schema), the job does not guess: cpe_data, kpi_data and kpi_data_in_alarm fall back to ALTER TABLE … DELETE WHERE created < toDateTime(toDate('<cutoff day>')) (midnight of the cutoff day, server time); every other table is skipped with a warning.
Never cleaned by this job:
-
ft_cpe_info(partitioned by the device creation date),serials_in_group_alarm, the Join tablesft_cust_device,ft_cpe_domain_info,ft_qoe_cpe_info, thetmp_*tables andschema_version: current state, not history. -
cpe_data_latest,kpi_data_latest: these views keep the last known value per device and parameter or KPI. That is current state, however old its timestamp: a device that has been silent for longer than the retention period still has a last known value, and dropping the partition would make those keys disappear from the current-value reads. -
user_activity: an audit log. No retention setting covers it. -
router_data,host_data,network_*,user_exp_*: not written by the running application.
Every dropped partition is logged at INFO (QoE: dropped partition <day> of table <table>), every failure at ERROR with the table; one failing table or partition does not stop the rest. A partition larger than ClickHouse’s max_partition_size_to_drop (50 GB by default) is refused by the server and shows up as such an error.