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:

  1. Check sql.properties for the externalized query

  2. Update both MySQL and Oracle variants if applicable

  3. 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.2. Database Name

The ClickHouse database name is ftacs_qoe_ui_data.

3.3. Monitoring Data Tables

Table Engine Description

cpe_data

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.

kpi_data

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.

kpi_data_in_alarm

MergeTree

KPI data points that triggered an alarm. Same structure as kpi_data with additional level (alarm severity) and group_id columns.

cpe_monitor_history

ReplacingMergeTree

Monitor start/stop timestamps per device and parameter (started, finished, serial, name_id).

user_activity

MergeTree

User action audit log (created, username, type_id, session_id, description). type_id is the fixed id of UserActivityEnum, not its position in the list. The ids are frozen as of this release: 0-19 equal the position each action had in every earlier build of this application (for example User login is 15, User logout 16, Delete KPI 9), so rows written so far read correctly. A new action gets the next free id (20 and up) and an id is never changed or reused. The original (monolith) application numbered the actions differently from id 9 on (it had no separate Delete KPI; its id 8 reads the same as here, Delete custom KPI; its User login is 14). On an installation migrated from the monolith, rows the monolith wrote with types 9 to 18 therefore show the meaning this application gives those ids. There is no migration. The table is not purged by the retention job.

schema_version

TinyLog

Database schema version tracking (version, created).

3.4. Alarm Tables

Table Engine Description

kpi_threshold_history_repl

ReplacingMergeTree

Single device alarm history (id, created, updated, serial, kpi_id, child_kpi_id, value, threshold_condition, state, level, isp_id, group_id).

serials_in_group_alarm

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

diag_speed_test

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).

diag_ip_ping

ReplacingMergeTree

IPPing diagnostic results — FCC (created, serial, completed, value, success_cnt, failure_cnt, avg_resp_time, gpv_sent, ip_addr, login_name, host).

diag_trace

ReplacingMergeTree

Trace route diagnostic state (id UUID, created, serial, completed, data_size, max_hops, host, gpv_sent, ip_addr, login_name).

diag_trace_hops

MergeTree

Trace route hop-by-hop results (diag_trace_id, created, hop, error_code, host, host_address, times).

diag_udp_echo

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).

diag_udp_echo_packet

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

wifi_cpe_data

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).

wifi_collisions

MergeTree

Detected Wi-Fi channel collisions (created, serial, name_id, ssid, channel, signal).

wifi_cpe_diagnostic_sent

ReplacingMergeTree

Wi-Fi diagnostic task tracking (created, serial, completed, gpv_sent).

3.7. User Experience Tables

Table Engine Description

user_exp_host

MergeTree

User experience host data (created, serial, name_id, mac, name, interface_type, layer1, layer3, addr, active).

user_exp_assoc_device

MergeTree

User experience associated device data (created, serial, name_id, mac, rssi, signal).

host_data

MergeTree

Connected hosts data — ETL feature (created, serial, name_id, name, mac, ipv4, ipv6, connectivity, ssid, bssid, rssi).

router_data

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

ft_cpe_info

ReplacingMergeTree

Device product data (serial, group_id, product_class, manufacturer_name, created).

ft_qoe_cpe_info

Join(ANY, LEFT, serial)

QoE CPE data (serial, mac, periodic, product_class, manufacturer_name, last_connection, updated).

ft_cust_device

Join(ANY, LEFT, serial)

Account information (serial, login_name, name, location, telephone, userid, userstatus, user_tag, zip, latitude, longitude, updated, cust1-cust20).

ft_cpe_domain_info

Join(ANY, LEFT, serial)

Domain data (id, isp_id, serial, updated, isp_name).

Tables with Join engine are populated from the Main DB via JDBC and serve as lookup tables for accelerating ClickHouse queries. Corresponding temporary tables (tmp_ft_qoe_cpe_info, tmp_ft_cust_device, tmp_ft_cpe_domain_info) with Memory engine are used during the sync process.

3.9. Materialized Views

View Engine Description

kpi_data_aggregated

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.

kpi_data_latest

ReplacingMergeTree

Latest KPI value per device and KPI. Automatically updated when kpi_data receives new rows.

cpe_data_latest

ReplacingMergeTree

Latest raw parameter value per device and parameter. Automatically updated when cpe_data receives new rows.

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

cpe_data, kpi_data, kpi_data_in_alarm, wifi_cpe_data, wifi_collisions, wifi_cpe_diagnostic_sent, diag_ip_ping, diag_speed_test, diag_trace, diag_trace_hops, diag_udp_echo, diag_udp_echo_packet

toDate(created)

Expired partitions are dropped.

kpi_threshold_history_repl

toDate(created)

Expired partitions are dropped, except a partition that still holds an active alarm (latest row by updated DESC, state ASC has state = 1). That partition is kept and logged.

cpe_monitor_history

toDate(started)

Expired partitions are dropped, except a partition that holds an interval that is still open (finished IS NULL) or that ended inside the retention window. That partition is kept and logged, so closed intervals in it are kept too until the last live interval in it has ended.

kpi_data_aggregated

date

Materialized view. The partitions are listed from, and dropped in, the inner table (.inner_id.<uuid>). ClickHouse 24.8 and 26.2 also forward ALTER TABLE <view> DROP PARTITION to 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 tables ft_cust_device, ft_cpe_domain_info, ft_qoe_cpe_info, the tmp_* tables and schema_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.

← Back | Main Page