Skip to content
Stand with Ukraine flag

Database Configuration

All parameters listed here correspond to settings in tb-edge.yml (or tb-edge.conf on Linux). Set them as environment variables in /etc/tb-edge/conf/tb-edge.conf (Linux) or as container environment variables (Docker / Kubernetes). For instructions on applying changes, see How to change configuration.

ParameterEnv variableDefaultDescription
database.ts_max_intervalsDATABASE_TS_MAX_INTERVALS700Max number of DB queries generated by a single API call to fetch telemetry records
database.ts.typeDATABASE_TS_TYPEsqlsql or timescale (for hybrid mode, DATABASE_TS_TYPE value should be timescale)
database.ts_latest.typeDATABASE_TS_LATEST_TYPEsqlsql or timescale (for hybrid mode, DATABASE_TS_TYPE value should be timescale)
ParameterEnv variableDefaultDescription
sql.attributes.batch_sizeSQL_ATTRIBUTES_BATCH_SIZE1000Batch size for persisting attribute updates
sql.attributes.batch_max_delaySQL_ATTRIBUTES_BATCH_MAX_DELAY_MS50Max timeout for attributes entries queue polling. The value is set in milliseconds
sql.attributes.stats_print_interval_msSQL_ATTRIBUTES_BATCH_STATS_PRINT_MS10000Interval in milliseconds for printing attributes updates statistic
sql.attributes.batch_threadsSQL_ATTRIBUTES_BATCH_THREADS3batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.attributes.value_no_xss_validationSQL_ATTRIBUTES_VALUE_NO_XSS_VALIDATIONfalseIf true attribute values will be checked for XSS vulnerability
sql.ts.batch_sizeSQL_TS_BATCH_SIZE10000Batch size for persisting timeseries inserts
sql.ts.batch_max_delaySQL_TS_BATCH_MAX_DELAY_MS100Max timeout for time-series entries queue polling. The value set in milliseconds
sql.ts.stats_print_interval_msSQL_TS_BATCH_STATS_PRINT_MS10000Interval in milliseconds for printing timeseries insert statistic
sql.ts.batch_threadsSQL_TS_BATCH_THREADS3batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.ts.value_no_xss_validationSQL_TS_VALUE_NO_XSS_VALIDATIONfalseIf true telemetry values will be checked for XSS vulnerability
sql.ts_latest.batch_sizeSQL_TS_LATEST_BATCH_SIZE1000Batch size for persisting latest telemetry updates
sql.ts_latest.batch_max_delaySQL_TS_LATEST_BATCH_MAX_DELAY_MS50Maximum timeout for latest telemetry entries queue polling. The value set in milliseconds
sql.ts_latest.stats_print_interval_msSQL_TS_LATEST_BATCH_STATS_PRINT_MS10000Interval in milliseconds for printing latest telemetry updates statistic
sql.ts_latest.batch_threadsSQL_TS_LATEST_BATCH_THREADS3batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.ts_latest.update_by_latest_tsSQL_TS_UPDATE_BY_LATEST_TIMESTAMPtrueUpdate latest values only if the timestamp of the new record is greater or equals the timestamp of the previously saved latest value. The latest values are stored separately from historical values for fast lookup from DB. Insert of historical value happens in any case
sql.events.batch_sizeSQL_EVENTS_BATCH_SIZE10000Batch size for persisting events inserts
sql.events.batch_max_delaySQL_EVENTS_BATCH_MAX_DELAY_MS100Max timeout for events entries queue polling. The value set in milliseconds
sql.events.stats_print_interval_msSQL_EVENTS_BATCH_STATS_PRINT_MS10000Interval in milliseconds for printing events insert statistic
sql.events.batch_threadsSQL_EVENTS_BATCH_THREADS3batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.events.partition_sizeSQL_EVENTS_REGULAR_PARTITION_SIZE_HOURS168Number of hours to partition the events. The current value corresponds to one week.
sql.events.debug_partition_sizeSQL_EVENTS_DEBUG_PARTITION_SIZE_HOURS1Number of hours to partition the debug events. The current value corresponds to one hour.
sql.edge_events.batch_sizeSQL_EDGE_EVENTS_BATCH_SIZE1000Batch size for persisting edge events inserts
sql.edge_events.batch_max_delaySQL_EDGE_EVENTS_BATCH_MAX_DELAY_MS100Max timeout for edge events entries queue polling. The value set in milliseconds
sql.edge_events.stats_print_interval_msSQL_EDGE_EVENTS_BATCH_STATS_PRINT_MS10000Interval in milliseconds for printing edge events insert statistic
sql.edge_events.partition_sizeSQL_EDGE_EVENTS_PARTITION_SIZE_HOURS168Number of hours to partition the edge events. The current value corresponds to one week.
sql.audit_logs.partition_sizeSQL_AUDIT_LOGS_PARTITION_SIZE_HOURS168Default value - 1 week
sql.cloud_events.batch_sizeSQL_CLOUD_EVENTS_BATCH_SIZE1000Batch size for persisting cloud events inserts
sql.cloud_events.batch_max_delaySQL_CLOUD_EVENTS_BATCH_MAX_DELAY_MS100Max timeout for cloud events entries queue polling. The value set in milliseconds
sql.cloud_events.stats_print_interval_msSQL_CLOUD_EVENTS_BATCH_STATS_PRINT_MS10000Interval in milliseconds for printing cloud events insert statistic
sql.cloud_events.partition_sizeSQL_CLOUD_EVENTS_PARTITION_SIZE_HOURS24Number of hours to partition the cloud events. The current value corresponds to one week.
sql.alarm_comments.partition_sizeSQL_ALARM_COMMENTS_PARTITION_SIZE_HOURS168Default value - 1 week
sql.notifications.partition_sizeSQL_NOTIFICATIONS_PARTITION_SIZE_HOURS168Default value - 1 week
sql.batch_sortSQL_BATCH_SORTtrueSpecify whether to sort entities before batch update. Should be enabled for cluster mode to avoid deadlocks
sql.remove_null_charsSQL_REMOVE_NULL_CHARStrueSpecify whether to remove null characters from strValue of attributes and timeseries before insert
sql.log_queriesSQL_LOG_QUERIESfalseSpecify whether to log database queries and their parameters generated by the entity query repository
sql.log_queries_thresholdSQL_LOG_QUERIES_THRESHOLD5000Threshold of slow SQL queries to log. The value set in milliseconds
sql.log_tenant_statsSQL_LOG_TENANT_STATStrueEnable/Disable logging statistic information about tenants
sql.log_tenant_stats_interval_msSQL_LOG_TENANT_STATS_INTERVAL_MS60000Interval in milliseconds for printing the latest statistic information about the tenant
sql.postgres.ts_key_value_partitioningSQL_POSTGRES_TS_KV_PARTITIONINGMONTHSSpecify partitioning size for timestamp key-value storage. Example: DAYS, MONTHS, YEARS, INDEFINITE.
sql.timescale.chunk_time_intervalSQL_TIMESCALE_CHUNK_TIME_INTERVAL604800000Specify Interval size for new data chunks storage.
sql.timescale.batch_threadsSQL_TIMESCALE_BATCH_THREADS3batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.ttl.ts.enabledSQL_TTL_TS_ENABLEDtrueEnable/disable TTL (Time To Live) for timeseries records
sql.ttl.ts.execution_interval_msSQL_TTL_TS_EXECUTION_INTERVAL86400000Number of milliseconds. The current value corresponds to one day
sql.ttl.ts.ts_key_value_ttlSQL_TTL_TS_TS_KEY_VALUE_TTL0The parameter to specify system TTL(Time To Live) value for timeseries records. Value set in seconds. 0 - records are never expired.
sql.ttl.events.enabledSQL_TTL_EVENTS_ENABLEDtrueEnable/disable TTL (Time To Live) for event records
sql.ttl.events.execution_interval_msSQL_TTL_EVENTS_EXECUTION_INTERVAL3600000Number of milliseconds (max random initial delay and fixed period).
sql.ttl.events.events_ttlSQL_TTL_EVENTS_EVENTS_TTL0Number of seconds. TTL is disabled by default. The accuracy of the cleanup depends on the sql.events.partition_size parameter.
sql.ttl.events.debug_events_ttlSQL_TTL_EVENTS_DEBUG_EVENTS_TTL604800Number of seconds. The current value corresponds to one week. The accuracy of the cleanup depends on the sql.events.debug_partition_size parameter.
sql.ttl.edge_events.enabledSQL_TTL_EDGE_EVENTS_ENABLEDtrueEnable/disable TTL (Time To Live) for edge event records
sql.ttl.edge_events.execution_interval_msSQL_TTL_EDGE_EVENTS_EXECUTION_INTERVAL86400000Number of milliseconds. The current value corresponds to one day
sql.ttl.edge_events.edge_events_ttlSQL_TTL_EDGE_EVENTS_TTL2628000Number of seconds. The current value corresponds to one month
sql.ttl.alarms.checking_intervalSQL_ALARMS_TTL_CHECKING_INTERVAL7200000Number of milliseconds. The current value corresponds to two hours
sql.ttl.alarms.removal_batch_sizeSQL_ALARMS_TTL_REMOVAL_BATCH_SIZE3000To delete outdated alarms not all at once but in batches
sql.ttl.rpc.enabledSQL_TTL_RPC_ENABLEDtrueEnable/disable TTL (Time To Live) for rpc call records
sql.ttl.rpc.checking_intervalSQL_RPC_TTL_CHECKING_INTERVAL7200000Number of milliseconds. The current value corresponds to two hours
sql.ttl.audit_logs.enabledSQL_TTL_AUDIT_LOGS_ENABLEDtrueEnable/disable TTL (Time To Live) for audit log records
sql.ttl.audit_logs.ttlSQL_TTL_AUDIT_LOGS_SECS0Disabled by default. The accuracy of the cleanup depends on the sql.audit_logs.partition_size
sql.ttl.audit_logs.checking_interval_msSQL_TTL_AUDIT_LOGS_CHECKING_INTERVAL_MS86400000Default value - 1 day
sql.ttl.cloud_events.enabledSQL_TTL_CLOUD_EVENTS_ENABLEDtrueEnable/disable TTL (Time To Live) for cloud event records
sql.ttl.cloud_events.execution_interval_msSQL_TTL_CLOUD_EVENTS_EXECUTION_INTERVAL86400000Number of milliseconds. The current value corresponds to one day
sql.ttl.cloud_events.cloud_events_ttlSQL_TTL_CLOUD_EVENTS_TTL2628000Number of seconds. The current value corresponds to one month
sql.ttl.notifications.enabledSQL_TTL_NOTIFICATIONS_ENABLEDtrueEnable/disable TTL (Time To Live) for notification center records
sql.ttl.notifications.ttlSQL_TTL_NOTIFICATIONS_SECS2592000Default value - 30 days
sql.ttl.notifications.checking_interval_msSQL_TTL_NOTIFICATIONS_CHECKING_INTERVAL_MS86400000Default value - 1 day
sql.relations.max_levelSQL_RELATIONS_MAX_LEVEL50This value has to be reasonably small to prevent infinite recursion as early as possible
sql.relations.pool_sizeSQL_RELATIONS_POOL_SIZE4This value has to be reasonably small to prevent the relation query from blocking all other DB calls
sql.relations.query_timeoutSQL_RELATIONS_QUERY_TIMEOUT_SEC20This value has to be reasonably small to prevent the relation query from blocking all other DB calls
ParameterEnv variableDefaultDescription
spring.data.jpa.repositories.enabled_(none)_"true"Enable/Disable the Spring Data JPA repositories support
spring.jpa.properties.jakarta.persistence.query.timeoutJAVAX_PERSISTENCE_QUERY_TIMEOUT30000General timeout for JDBC queries
spring.jpa.open-in-view_(none)_"false"Enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
spring.jpa.hibernate.ddl-auto_(none)_"none"You can set a Hibernate feature that controls the DDL behavior in a more fine-grained way. The standard Hibernate property values are none, validate, update, create-drop. Spring Boot chooses a default value for you based on whether it thinks your database is embedded (default create-drop) or not (default none)
spring.datasource.driverClassNameSPRING_DRIVER_CLASS_NAMEorg.postgresql.DriverDatabase driver for Spring JPA - org.postgresql.Driver
spring.datasource.urlSPRING_DATASOURCE_URLjdbc:postgresql://localhost:5432/tb_edgeDatabase connection URL
spring.datasource.usernameSPRING_DATASOURCE_USERNAMEpostgresDatabase user name
spring.datasource.passwordSPRING_DATASOURCE_PASSWORDpostgresDatabase user password
spring.datasource.hikari.leakDetectionThresholdSPRING_DATASOURCE_HIKARI_LEAK_DETECTION_THRESHOLD0This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak. A value of 0 means leak detection is disabled
spring.datasource.hikari.maximumPoolSizeSPRING_DATASOURCE_MAXIMUM_POOL_SIZE16This property increases the number of connections in the pool as demand increases. At the same time, the property ensures that the pool doesn’t grow to the point of exhausting a system’s resources, which ultimately affects an application’s performance and availability
spring.datasource.hikari.registerMbeansSPRING_DATASOURCE_HIKARI_REGISTER_MBEANSfalseEnable MBean to diagnose pools state via JMX
spring.datasource.events.enabledSPRING_DEDICATED_EVENTS_DATASOURCE_ENABLEDfalseEnable dedicated datasource (a separate database) for events and audit logs. Before enabling this, make sure you have set up the following tables in the new DB: error_event, lc_event, rule_chain_debug_event, rule_node_debug_event, stats_event, audit_log
spring.datasource.events.driverClassNameSPRING_EVENTS_DATASOURCE_DRIVER_CLASS_NAMEorg.postgresql.DriverDatabase driver for Spring JPA for events datasource
spring.datasource.events.urlSPRING_EVENTS_DATASOURCE_URLjdbc:postgresql://localhost:5432/thingsboard_eventsDatabase connection URL for events datasource
spring.datasource.events.usernameSPRING_EVENTS_DATASOURCE_USERNAMEpostgresDatabase username for events datasource
spring.datasource.events.passwordSPRING_EVENTS_DATASOURCE_PASSWORDpostgresDatabase user password for events datasource
spring.datasource.events.hikari.leakDetectionThresholdSPRING_EVENTS_DATASOURCE_HIKARI_LEAK_DETECTION_THRESHOLD0This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak for events datasource. A value of 0 means leak detection is disabled
spring.datasource.events.hikari.maximumPoolSizeSPRING_EVENTS_DATASOURCE_MAXIMUM_POOL_SIZE4This property increases the number of connections in the pool as demand increases for events datasource. At the same time, the property ensures that the pool doesn’t grow to the point of exhausting a system’s resources, which ultimately affects an application’s performance and availability
spring.datasource.events.hikari.registerMbeansSPRING_EVENTS_DATASOURCE_HIKARI_REGISTER_MBEANSfalseEnable MBean to diagnose pools state via JMX for events datasource