diff --git a/src/gausskernel/dbmind/tools/cmd/edbmind.py b/src/gausskernel/dbmind/tools/cmd/edbmind.py index 95a5fbf1b..764266470 100644 --- a/src/gausskernel/dbmind/tools/cmd/edbmind.py +++ b/src/gausskernel/dbmind/tools/cmd/edbmind.py @@ -14,6 +14,7 @@ import logging import os +import threading import signal import sys import traceback @@ -55,7 +56,6 @@ def _check_confpath(confpath): def _process_clean(force=False): global_vars.worker.terminate(cancel_futures=force) TimedTaskManager.stop() - logging.shutdown() def signal_handler(signum, frame): @@ -67,7 +67,10 @@ def signal_handler(signum, frame): elif signum == signal.SIGUSR2: # used for debugging utils.write_to_terminal('Stack frames:', color='green') - traceback.print_stack(frame) + for th in threading.enumerate(): + print(th) + traceback.print_stack(sys._current_frames()[th.ident]) + print() elif signum == signal.SIGTERM: signal.signal(signal.SIGTERM, signal.SIG_IGN) logging.info('DBMind received exit signal.') diff --git a/src/gausskernel/dbmind/tools/common/tsdb/prometheus_client.py b/src/gausskernel/dbmind/tools/common/tsdb/prometheus_client.py index a1d47fe97..6cc233ed3 100644 --- a/src/gausskernel/dbmind/tools/common/tsdb/prometheus_client.py +++ b/src/gausskernel/dbmind/tools/common/tsdb/prometheus_client.py @@ -293,3 +293,10 @@ class PrometheusClient(TsdbClient): "HTTP Status Code {} ({!r})".format(response.status_code, response.content) ) return _standardize(data) + + def timestamp(self): + seq = self.get_current_metric_value('prometheus_remote_storage_highest_timestamp_in_seconds') + if len(seq) == 0 or len(seq[0]) == 0: + return 0 + return seq[0].timestamps[0] + diff --git a/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client.py b/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client.py index 6a7c8c942..99f5e1168 100644 --- a/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client.py +++ b/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client.py @@ -11,6 +11,7 @@ # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. # See the Mulan PSL v2 for more details. +import time from datetime import datetime, timedelta @@ -48,3 +49,8 @@ class TsdbClient(object): params: dict = None): """get metric target from tsdb""" pass + + def timestamp(self): + """get the current unix-timestamp from the time-series database.""" + return int(time.time() * 1000) + diff --git a/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client_factory.py b/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client_factory.py index eac9b59a7..f4ba1f19d 100644 --- a/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client_factory.py +++ b/src/gausskernel/dbmind/tools/common/tsdb/tsdb_client_factory.py @@ -12,6 +12,7 @@ # See the Mulan PSL v2 for more details. import threading +import time from dbmind.common.exceptions import ApiClientException from dbmind.common.tsdb.tsdb_client import TsdbClient @@ -46,3 +47,9 @@ class TsdbClientFactory(object): cls.tsdb_client = client if cls.tsdb_client is None: raise ApiClientException("Failed to init TSDB client, please check config file") + + if abs(cls.tsdb_client.timestamp() - time.time() * 1000) > 60 * 1000: # threshold is 1 minute. + raise ApiClientException('Found clock drift between TSDB client and server, ' + 'please check and synchronize system clocks.') + + diff --git a/src/gausskernel/dbmind/tools/common/utils.py b/src/gausskernel/dbmind/tools/common/utils.py index da5875c1f..acde5938d 100644 --- a/src/gausskernel/dbmind/tools/common/utils.py +++ b/src/gausskernel/dbmind/tools/common/utils.py @@ -153,25 +153,28 @@ class MultiProcessingRFHandler(RotatingFileHandler): self._queue = multiprocessing.Queue(-1) self._should_exit = False - self._receiv_thr = threading.Thread(target=self._receive) + self._receiv_thr = threading.Thread(target=self._receive, name='LoggingReceiverThread') + self._receiv_thr.daemon = True self._receiv_thr.start() def _receive(self): while True: try: - record = self._queue.get_nowait() + if self._should_exit and self._queue.empty(): + break + record = self._queue.get(timeout=.2) super().emit(record) - except Empty: - time.sleep(.1) except (KeyboardInterrupt, SystemExit): raise - except EOFError: + except (OSError, EOFError): break + except Empty: + pass except: traceback.print_exc(file=sys.stderr) - if self._should_exit and self._queue.empty(): - break - + self._queue.close() + self._queue.join_thread() + def _send(self, s): self._queue.put_nowait(s) @@ -181,6 +184,7 @@ class MultiProcessingRFHandler(RotatingFileHandler): record.msg = record.msg % record.args record.args = None if record.exc_info: + self.format(record) record.exc_info = None self._send(record) except (KeyboardInterrupt, SystemExit): @@ -189,8 +193,10 @@ class MultiProcessingRFHandler(RotatingFileHandler): self.handleError(record) def close(self): - super().close() - self._should_exit = True + if not self._should_exit: + self._should_exit = True + self._receiv_thr.join(5) + super().close() class ExceptionCatch: diff --git a/src/gausskernel/dbmind/tools/misc/metric_map.conf b/src/gausskernel/dbmind/tools/misc/metric_map.conf index 1080fc74c..9394aaebe 100644 --- a/src/gausskernel/dbmind/tools/misc/metric_map.conf +++ b/src/gausskernel/dbmind/tools/misc/metric_map.conf @@ -1,19 +1,439 @@ +# Copyright (c) 2022 Huawei Technologies Co.,Ltd. +# +# openGauss is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + + # The name of different metric collectors may be different, # so we converte the different metric name here. +# For example, users can get the full list of metrics from Prometheus via the following URI: +# /api/v1/label/__name__/values + # Format: # metric name in the DBMind = metric name in the collector (e.g., Prometheus-exporter, Agent) # -os_disk_io_cnt = os_disk_io_cnt -os_disk_io_load = os_disk_io_load -os_disk_read_bytes = os_disk_read_bytes -os_disk_read_time = os_disk_read_time -os_disk_write_bytes = os_disk_write_bytes -os_disk_write_time = os_disk_write_time -os_cpu_usage = os_cpu_usage -os_system_cpu_usage = os_system_cpu_usage -os_user_cpu_usage = os_user_cpu_usage -opengauss_blocks_read_time = opengauss_blocks_read_time -opengauss_blocks_write_time = opengauss_blocks_write_time -opengauss_sql_cpu_time_rate = opengauss_sql_cpu_time_rate -disk_usage = disk_usage +gaussdb_qps_by_instance = gaussdb_qps_by_instance +io_queue_number = io_queue_number +io_read_bytes = io_read_bytes +io_read_delay_time = io_read_delay_time +io_read_total = io_read_total +io_write_bytes = io_write_bytes +io_write_delay_time = io_write_delay_time +io_write_total = io_write_total +node_arp_entries = node_arp_entries +node_boot_time_seconds = node_boot_time_seconds +node_context_switches_total = node_context_switches_total +node_cooling_device_cur_state = node_cooling_device_cur_state +node_cooling_device_max_state = node_cooling_device_max_state +node_cpu_core_throttles_total = node_cpu_core_throttles_total +node_cpu_frequency_max_hertz = node_cpu_frequency_max_hertz +node_cpu_frequency_min_hertz = node_cpu_frequency_min_hertz +node_cpu_guest_seconds_total = node_cpu_guest_seconds_total +node_cpu_package_throttles_total = node_cpu_package_throttles_total +node_cpu_scaling_frequency_hertz = node_cpu_scaling_frequency_hertz +node_cpu_scaling_frequency_max_hertz = node_cpu_scaling_frequency_max_hertz +node_cpu_scaling_frequency_min_hertz = node_cpu_scaling_frequency_min_hertz +node_cpu_seconds_total = node_cpu_seconds_total +node_disk_io_now = node_disk_io_now +node_disk_io_time_seconds_total = node_disk_io_time_seconds_total +node_disk_io_time_weighted_seconds_total = node_disk_io_time_weighted_seconds_total +node_disk_read_bytes_total = node_disk_read_bytes_total +node_disk_read_time_seconds_total = node_disk_read_time_seconds_total +node_disk_reads_completed_total = node_disk_reads_completed_total +node_disk_reads_merged_total = node_disk_reads_merged_total +node_disk_write_time_seconds_total = node_disk_write_time_seconds_total +node_disk_writes_completed_total = node_disk_writes_completed_total +node_disk_writes_merged_total = node_disk_writes_merged_total +node_disk_written_bytes_total = node_disk_written_bytes_total +node_edac_correctable_errors_total = node_edac_correctable_errors_total +node_edac_csrow_correctable_errors_total = node_edac_csrow_correctable_errors_total +node_edac_csrow_uncorrectable_errors_total = node_edac_csrow_uncorrectable_errors_total +node_edac_uncorrectable_errors_total = node_edac_uncorrectable_errors_total +node_entropy_available_bits = node_entropy_available_bits +node_entropy_pool_size_bits = node_entropy_pool_size_bits +node_exporter_build_info = node_exporter_build_info +node_filefd_allocated = node_filefd_allocated +node_filefd_maximum = node_filefd_maximum +node_filesystem_avail_bytes = node_filesystem_avail_bytes +node_filesystem_device_error = node_filesystem_device_error +node_filesystem_files = node_filesystem_files +node_filesystem_files_free = node_filesystem_files_free +node_filesystem_free_bytes = node_filesystem_free_bytes +node_filesystem_readonly = node_filesystem_readonly +node_filesystem_size_bytes = node_filesystem_size_bytes +node_forks_total = node_forks_total +node_hwmon_chip_names = node_hwmon_chip_names +node_hwmon_power_average_interval_max_seconds = node_hwmon_power_average_interval_max_seconds +node_hwmon_power_average_interval_min_seconds = node_hwmon_power_average_interval_min_seconds +node_hwmon_power_average_interval_seconds = node_hwmon_power_average_interval_seconds +node_hwmon_power_average_watt = node_hwmon_power_average_watt +node_hwmon_power_is_battery_watt = node_hwmon_power_is_battery_watt +node_hwmon_sensor_label = node_hwmon_sensor_label +node_hwmon_temp_celsius = node_hwmon_temp_celsius +node_hwmon_temp_crit_alar_celsius = node_hwmon_temp_crit_alar_celsius +node_hwmon_temp_crit_alarm_celsius = node_hwmon_temp_crit_alarm_celsius +node_hwmon_temp_crit_celsius = node_hwmon_temp_crit_celsius +node_hwmon_temp_max_celsius = node_hwmon_temp_max_celsius +node_intr_total = node_intr_total +node_load1 = node_load1 +node_load15 = node_load15 +node_load5 = node_load5 +node_memory_Active_anon_bytes = node_memory_Active_anon_bytes +node_memory_Active_bytes = node_memory_Active_bytes +node_memory_Active_file_bytes = node_memory_Active_file_bytes +node_memory_AnonHugePages_bytes = node_memory_AnonHugePages_bytes +node_memory_AnonPages_bytes = node_memory_AnonPages_bytes +node_memory_Bounce_bytes = node_memory_Bounce_bytes +node_memory_Buffers_bytes = node_memory_Buffers_bytes +node_memory_Cached_bytes = node_memory_Cached_bytes +node_memory_CmaFree_bytes = node_memory_CmaFree_bytes +node_memory_CmaTotal_bytes = node_memory_CmaTotal_bytes +node_memory_CommitLimit_bytes = node_memory_CommitLimit_bytes +node_memory_Committed_AS_bytes = node_memory_Committed_AS_bytes +node_memory_DirectMap1G_bytes = node_memory_DirectMap1G_bytes +node_memory_DirectMap2M_bytes = node_memory_DirectMap2M_bytes +node_memory_DirectMap4k_bytes = node_memory_DirectMap4k_bytes +node_memory_Dirty_bytes = node_memory_Dirty_bytes +node_memory_HardwareCorrupted_bytes = node_memory_HardwareCorrupted_bytes +node_memory_HugePages_Free = node_memory_HugePages_Free +node_memory_HugePages_Rsvd = node_memory_HugePages_Rsvd +node_memory_HugePages_Surp = node_memory_HugePages_Surp +node_memory_HugePages_Total = node_memory_HugePages_Total +node_memory_Hugepagesize_bytes = node_memory_Hugepagesize_bytes +node_memory_Inactive_anon_bytes = node_memory_Inactive_anon_bytes +node_memory_Inactive_bytes = node_memory_Inactive_bytes +node_memory_Inactive_file_bytes = node_memory_Inactive_file_bytes +node_memory_KernelStack_bytes = node_memory_KernelStack_bytes +node_memory_Mapped_bytes = node_memory_Mapped_bytes +node_memory_MemAvailable_bytes = node_memory_MemAvailable_bytes +node_memory_MemFree_bytes = node_memory_MemFree_bytes +node_memory_MemTotal_bytes = node_memory_MemTotal_bytes +node_memory_Mlocked_bytes = node_memory_Mlocked_bytes +node_memory_NFS_Unstable_bytes = node_memory_NFS_Unstable_bytes +node_memory_PageTables_bytes = node_memory_PageTables_bytes +node_memory_SReclaimable_bytes = node_memory_SReclaimable_bytes +node_memory_SUnreclaim_bytes = node_memory_SUnreclaim_bytes +node_memory_Shmem_bytes = node_memory_Shmem_bytes +node_memory_Slab_bytes = node_memory_Slab_bytes +node_memory_SwapCached_bytes = node_memory_SwapCached_bytes +node_memory_SwapFree_bytes = node_memory_SwapFree_bytes +node_memory_SwapTotal_bytes = node_memory_SwapTotal_bytes +node_memory_Unevictable_bytes = node_memory_Unevictable_bytes +node_memory_VmallocChunk_bytes = node_memory_VmallocChunk_bytes +node_memory_VmallocTotal_bytes = node_memory_VmallocTotal_bytes +node_memory_VmallocUsed_bytes = node_memory_VmallocUsed_bytes +node_memory_WritebackTmp_bytes = node_memory_WritebackTmp_bytes +node_memory_Writeback_bytes = node_memory_Writeback_bytes +node_netstat_Icmp6_InErrors = node_netstat_Icmp6_InErrors +node_netstat_Icmp6_InMsgs = node_netstat_Icmp6_InMsgs +node_netstat_Icmp6_OutMsgs = node_netstat_Icmp6_OutMsgs +node_netstat_Icmp_InErrors = node_netstat_Icmp_InErrors +node_netstat_Icmp_InMsgs = node_netstat_Icmp_InMsgs +node_netstat_Icmp_OutMsgs = node_netstat_Icmp_OutMsgs +node_netstat_Ip6_InOctets = node_netstat_Ip6_InOctets +node_netstat_Ip6_OutOctets = node_netstat_Ip6_OutOctets +node_netstat_IpExt_InOctets = node_netstat_IpExt_InOctets +node_netstat_IpExt_OutOctets = node_netstat_IpExt_OutOctets +node_netstat_Ip_Forwarding = node_netstat_Ip_Forwarding +node_netstat_TcpExt_ListenDrops = node_netstat_TcpExt_ListenDrops +node_netstat_TcpExt_ListenOverflows = node_netstat_TcpExt_ListenOverflows +node_netstat_TcpExt_SyncookiesFailed = node_netstat_TcpExt_SyncookiesFailed +node_netstat_TcpExt_SyncookiesRecv = node_netstat_TcpExt_SyncookiesRecv +node_netstat_TcpExt_SyncookiesSent = node_netstat_TcpExt_SyncookiesSent +node_netstat_TcpExt_TCPSynRetrans = node_netstat_TcpExt_TCPSynRetrans +node_netstat_Tcp_ActiveOpens = node_netstat_Tcp_ActiveOpens +node_netstat_Tcp_CurrEstab = node_netstat_Tcp_CurrEstab +node_netstat_Tcp_InErrs = node_netstat_Tcp_InErrs +node_netstat_Tcp_InSegs = node_netstat_Tcp_InSegs +node_netstat_Tcp_OutRsts = node_netstat_Tcp_OutRsts +node_netstat_Tcp_OutSegs = node_netstat_Tcp_OutSegs +node_netstat_Tcp_PassiveOpens = node_netstat_Tcp_PassiveOpens +node_netstat_Tcp_RetransSegs = node_netstat_Tcp_RetransSegs +node_netstat_Udp6_InDatagrams = node_netstat_Udp6_InDatagrams +node_netstat_Udp6_InErrors = node_netstat_Udp6_InErrors +node_netstat_Udp6_NoPorts = node_netstat_Udp6_NoPorts +node_netstat_Udp6_OutDatagrams = node_netstat_Udp6_OutDatagrams +node_netstat_Udp6_RcvbufErrors = node_netstat_Udp6_RcvbufErrors +node_netstat_Udp6_SndbufErrors = node_netstat_Udp6_SndbufErrors +node_netstat_UdpLite6_InErrors = node_netstat_UdpLite6_InErrors +node_netstat_UdpLite_InErrors = node_netstat_UdpLite_InErrors +node_netstat_Udp_InDatagrams = node_netstat_Udp_InDatagrams +node_netstat_Udp_InErrors = node_netstat_Udp_InErrors +node_netstat_Udp_NoPorts = node_netstat_Udp_NoPorts +node_netstat_Udp_OutDatagrams = node_netstat_Udp_OutDatagrams +node_netstat_Udp_RcvbufErrors = node_netstat_Udp_RcvbufErrors +node_netstat_Udp_SndbufErrors = node_netstat_Udp_SndbufErrors +node_network_address_assign_type = node_network_address_assign_type +node_network_carrier = node_network_carrier +node_network_carrier_changes_total = node_network_carrier_changes_total +node_network_device_id = node_network_device_id +node_network_dormant = node_network_dormant +node_network_flags = node_network_flags +node_network_iface_id = node_network_iface_id +node_network_iface_link = node_network_iface_link +node_network_iface_link_mode = node_network_iface_link_mode +node_network_info = node_network_info +node_network_mtu_bytes = node_network_mtu_bytes +node_network_net_dev_group = node_network_net_dev_group +node_network_protocol_type = node_network_protocol_type +node_network_receive_bytes_total = node_network_receive_bytes_total +node_network_receive_compressed_total = node_network_receive_compressed_total +node_network_receive_drop_total = node_network_receive_drop_total +node_network_receive_errs_total = node_network_receive_errs_total +node_network_receive_fifo_total = node_network_receive_fifo_total +node_network_receive_frame_total = node_network_receive_frame_total +node_network_receive_multicast_total = node_network_receive_multicast_total +node_network_receive_packets_total = node_network_receive_packets_total +node_network_speed_bytes = node_network_speed_bytes +node_network_transmit_bytes_total = node_network_transmit_bytes_total +node_network_transmit_carrier_total = node_network_transmit_carrier_total +node_network_transmit_colls_total = node_network_transmit_colls_total +node_network_transmit_compressed_total = node_network_transmit_compressed_total +node_network_transmit_drop_total = node_network_transmit_drop_total +node_network_transmit_errs_total = node_network_transmit_errs_total +node_network_transmit_fifo_total = node_network_transmit_fifo_total +node_network_transmit_packets_total = node_network_transmit_packets_total +node_network_transmit_queue_length = node_network_transmit_queue_length +node_network_up = node_network_up +node_nf_conntrack_entries = node_nf_conntrack_entries +node_nf_conntrack_entries_limit = node_nf_conntrack_entries_limit +node_procs_blocked = node_procs_blocked +node_procs_running = node_procs_running +node_rapl_dram_joules_total = node_rapl_dram_joules_total +node_rapl_package_joules_total = node_rapl_package_joules_total +node_schedstat_running_seconds_total = node_schedstat_running_seconds_total +node_schedstat_timeslices_total = node_schedstat_timeslices_total +node_schedstat_waiting_seconds_total = node_schedstat_waiting_seconds_total +node_scrape_collector_duration_seconds = node_scrape_collector_duration_seconds +node_scrape_collector_success = node_scrape_collector_success +node_sockstat_FRAG6_inuse = node_sockstat_FRAG6_inuse +node_sockstat_FRAG6_memory = node_sockstat_FRAG6_memory +node_sockstat_FRAG_inuse = node_sockstat_FRAG_inuse +node_sockstat_FRAG_memory = node_sockstat_FRAG_memory +node_sockstat_RAW6_inuse = node_sockstat_RAW6_inuse +node_sockstat_RAW_inuse = node_sockstat_RAW_inuse +node_sockstat_TCP6_inuse = node_sockstat_TCP6_inuse +node_sockstat_TCP_alloc = node_sockstat_TCP_alloc +node_sockstat_TCP_inuse = node_sockstat_TCP_inuse +node_sockstat_TCP_mem = node_sockstat_TCP_mem +node_sockstat_TCP_mem_bytes = node_sockstat_TCP_mem_bytes +node_sockstat_TCP_orphan = node_sockstat_TCP_orphan +node_sockstat_TCP_tw = node_sockstat_TCP_tw +node_sockstat_UDP6_inuse = node_sockstat_UDP6_inuse +node_sockstat_UDPLITE6_inuse = node_sockstat_UDPLITE6_inuse +node_sockstat_UDPLITE_inuse = node_sockstat_UDPLITE_inuse +node_sockstat_UDP_inuse = node_sockstat_UDP_inuse +node_sockstat_UDP_mem = node_sockstat_UDP_mem +node_sockstat_UDP_mem_bytes = node_sockstat_UDP_mem_bytes +node_sockstat_sockets_used = node_sockstat_sockets_used +node_softnet_dropped_total = node_softnet_dropped_total +node_softnet_processed_total = node_softnet_processed_total +node_softnet_times_squeezed_total = node_softnet_times_squeezed_total +node_textfile_scrape_error = node_textfile_scrape_error +node_time_seconds = node_time_seconds +node_timex_estimated_error_seconds = node_timex_estimated_error_seconds +node_timex_frequency_adjustment_ratio = node_timex_frequency_adjustment_ratio +node_timex_loop_time_constant = node_timex_loop_time_constant +node_timex_maxerror_seconds = node_timex_maxerror_seconds +node_timex_offset_seconds = node_timex_offset_seconds +node_timex_pps_calibration_total = node_timex_pps_calibration_total +node_timex_pps_error_total = node_timex_pps_error_total +node_timex_pps_frequency_hertz = node_timex_pps_frequency_hertz +node_timex_pps_jitter_seconds = node_timex_pps_jitter_seconds +node_timex_pps_jitter_total = node_timex_pps_jitter_total +node_timex_pps_shift_seconds = node_timex_pps_shift_seconds +node_timex_pps_stability_exceeded_total = node_timex_pps_stability_exceeded_total +node_timex_pps_stability_hertz = node_timex_pps_stability_hertz +node_timex_status = node_timex_status +node_timex_sync_status = node_timex_sync_status +node_timex_tai_offset_seconds = node_timex_tai_offset_seconds +node_timex_tick_seconds = node_timex_tick_seconds +node_udp_queues = node_udp_queues +node_uname_info = node_uname_info +node_vmstat_pgfault = node_vmstat_pgfault +node_vmstat_pgmajfault = node_vmstat_pgmajfault +node_vmstat_pgpgin = node_vmstat_pgpgin +node_vmstat_pgpgout = node_vmstat_pgpgout +node_vmstat_pswpin = node_vmstat_pswpin +node_vmstat_pswpout = node_vmstat_pswpout +og_context_memory_totalsize = og_context_memory_totalsize +og_context_memory_usedsize = og_context_memory_usedsize +og_cpu_load_total_cpu = og_cpu_load_total_cpu +og_memory_info_memorymbytes = og_memory_info_memorymbytes +og_session_memory_totalsize = og_session_memory_totalsize +og_session_memory_usedsize = og_session_memory_usedsize +og_state_memory_totalsize = og_state_memory_totalsize +os_cpu_iowait = os_cpu_iowait +os_cpu_processor_number = os_cpu_processor_number +os_cpu_usage = os_cpu_usage +os_disk_iocapacity = os_disk_iocapacity +os_disk_iops = os_disk_iops +os_disk_ioutils = os_disk_ioutils +os_disk_usage = os_disk_usage +os_mem_usage = os_mem_usage +pg_active_slowsql_query_runtime = pg_active_slowsql_query_runtime +pg_activity_count = pg_activity_count +pg_activity_max_conn_duration = pg_activity_max_conn_duration +pg_activity_max_duration = pg_activity_max_duration +pg_activity_max_tx_duration = pg_activity_max_tx_duration +pg_boot_time = pg_boot_time +pg_checkpoint_checkpoint_lsn = pg_checkpoint_checkpoint_lsn +pg_checkpoint_elapse = pg_checkpoint_elapse +pg_checkpoint_full_page_writes = pg_checkpoint_full_page_writes +pg_checkpoint_newest_commit_ts_xid = pg_checkpoint_newest_commit_ts_xid +pg_checkpoint_next_multi_offset = pg_checkpoint_next_multi_offset +pg_checkpoint_next_multixact_id = pg_checkpoint_next_multixact_id +pg_checkpoint_next_oid = pg_checkpoint_next_oid +pg_checkpoint_next_xid = pg_checkpoint_next_xid +pg_checkpoint_next_xid_epoch = pg_checkpoint_next_xid_epoch +pg_checkpoint_oldest_active_xid = pg_checkpoint_oldest_active_xid +pg_checkpoint_oldest_commit_ts_xid = pg_checkpoint_oldest_commit_ts_xid +pg_checkpoint_oldest_multi_dbid = pg_checkpoint_oldest_multi_dbid +pg_checkpoint_oldest_multi_xid = pg_checkpoint_oldest_multi_xid +pg_checkpoint_oldest_xid = pg_checkpoint_oldest_xid +pg_checkpoint_oldest_xid_dbid = pg_checkpoint_oldest_xid_dbid +pg_checkpoint_prev_tli = pg_checkpoint_prev_tli +pg_checkpoint_redo_lsn = pg_checkpoint_redo_lsn +pg_checkpoint_time = pg_checkpoint_time +pg_checkpoint_tli = pg_checkpoint_tli +pg_class_relage = pg_class_relage +pg_class_relpages = pg_class_relpages +pg_class_relsize = pg_class_relsize +pg_class_reltuples = pg_class_reltuples +pg_conf_reload_time = pg_conf_reload_time +pg_connections_max_conn = pg_connections_max_conn +pg_connections_res_for_normal = pg_connections_res_for_normal +pg_connections_used_conn = pg_connections_used_conn +pg_database_age = pg_database_age +pg_database_allow_conn = pg_database_allow_conn +pg_database_conn_limit = pg_database_conn_limit +pg_database_frozen_xid = pg_database_frozen_xid +pg_database_is_template = pg_database_is_template +pg_database_size_bytes = pg_database_size_bytes +pg_db_blk_read_time = pg_db_blk_read_time +pg_db_blk_write_time = pg_db_blk_write_time +pg_db_blks_access = pg_db_blks_access +pg_db_blks_hit = pg_db_blks_hit +pg_db_blks_read = pg_db_blks_read +pg_db_confl_bufferpin = pg_db_confl_bufferpin +pg_db_confl_deadlock = pg_db_confl_deadlock +pg_db_confl_lock = pg_db_confl_lock +pg_db_confl_snapshot = pg_db_confl_snapshot +pg_db_confl_tablespace = pg_db_confl_tablespace +pg_db_conflicts = pg_db_conflicts +pg_db_deadlocks = pg_db_deadlocks +pg_db_numbackends = pg_db_numbackends +pg_db_stats_reset = pg_db_stats_reset +pg_db_temp_bytes = pg_db_temp_bytes +pg_db_temp_files = pg_db_temp_files +pg_db_tup_deleted = pg_db_tup_deleted +pg_db_tup_fetched = pg_db_tup_fetched +pg_db_tup_inserted = pg_db_tup_inserted +pg_db_tup_returned = pg_db_tup_returned +pg_db_tup_updated = pg_db_tup_updated +pg_db_xact_commit = pg_db_xact_commit +pg_db_xact_rollback = pg_db_xact_rollback +pg_downstream_count = pg_downstream_count +pg_flush_lsn = pg_flush_lsn +pg_index_idx_blks_hit = pg_index_idx_blks_hit +pg_index_idx_blks_read = pg_index_idx_blks_read +pg_index_idx_scan = pg_index_idx_scan +pg_index_idx_tup_fetch = pg_index_idx_tup_fetch +pg_index_idx_tup_read = pg_index_idx_tup_read +pg_insert_lsn = pg_insert_lsn +pg_is_in_recovery = pg_is_in_recovery +pg_is_wal_replay_paused = pg_is_wal_replay_paused +pg_lag = pg_lag +pg_last_replay_time = pg_last_replay_time +pg_lock_count = pg_lock_count +pg_lock_sql_locked_times = pg_lock_sql_locked_times +pg_locker_count = pg_locker_count +pg_lsn = pg_lsn +pg_meta_info = pg_meta_info +pg_need_indexes_idx_scan = pg_need_indexes_idx_scan +pg_need_indexes_idx_tup_fetch = pg_need_indexes_idx_tup_fetch +pg_need_indexes_rate = pg_need_indexes_rate +pg_need_indexes_seq_scan = pg_need_indexes_seq_scan +pg_need_indexes_seq_tup_read = pg_need_indexes_seq_tup_read +pg_never_used_indexes_index_size = pg_never_used_indexes_index_size +pg_node_info_uptime = pg_node_info_uptime +pg_receive_lsn = pg_receive_lsn +pg_replay_lsn = pg_replay_lsn +pg_replication_slots_active = pg_replication_slots_active +pg_replication_slots_delay_lsn = pg_replication_slots_delay_lsn +pg_run_times_db_role = pg_run_times_db_role +pg_run_times_run_time = pg_run_times_run_time +pg_session_connection_count = pg_session_connection_count +pg_setting_block_size = pg_setting_block_size +pg_setting_max_connections = pg_setting_max_connections +pg_setting_max_locks_per_transaction = pg_setting_max_locks_per_transaction +pg_setting_max_prepared_transactions = pg_setting_max_prepared_transactions +pg_setting_max_replication_slots = pg_setting_max_replication_slots +pg_setting_max_wal_senders = pg_setting_max_wal_senders +pg_setting_wal_log_hints = pg_setting_wal_log_hints +pg_settings_setting = pg_settings_setting +pg_sql_statement_full_count = pg_sql_statement_full_count +pg_sql_statement_history_exc_time = pg_sql_statement_history_exc_time +pg_table_analyze_count = pg_table_analyze_count +pg_table_analyze_delay = pg_table_analyze_delay +pg_table_autoanalyze_count = pg_table_autoanalyze_count +pg_table_autovacuum_count = pg_table_autovacuum_count +pg_table_heap_blks_hit = pg_table_heap_blks_hit +pg_table_heap_blks_read = pg_table_heap_blks_read +pg_table_idx_blks_hit = pg_table_idx_blks_hit +pg_table_idx_blks_read = pg_table_idx_blks_read +pg_table_idx_scan = pg_table_idx_scan +pg_table_idx_tup_fetch = pg_table_idx_tup_fetch +pg_table_n_dead_tup = pg_table_n_dead_tup +pg_table_n_live_tup = pg_table_n_live_tup +pg_table_n_mod_since_analyze = pg_table_n_mod_since_analyze +pg_table_n_tup_del = pg_table_n_tup_del +pg_table_n_tup_hot_upd = pg_table_n_tup_hot_upd +pg_table_n_tup_ins = pg_table_n_tup_ins +pg_table_n_tup_mod = pg_table_n_tup_mod +pg_table_n_tup_upd = pg_table_n_tup_upd +pg_table_seq_scan = pg_table_seq_scan +pg_table_seq_tup_read = pg_table_seq_tup_read +pg_table_tbl_scan = pg_table_tbl_scan +pg_table_tidx_blks_hit = pg_table_tidx_blks_hit +pg_table_tidx_blks_read = pg_table_tidx_blks_read +pg_table_toast_blks_hit = pg_table_toast_blks_hit +pg_table_toast_blks_read = pg_table_toast_blks_read +pg_table_tup_read = pg_table_tup_read +pg_table_vacuum_count = pg_table_vacuum_count +pg_table_vacuum_delay = pg_table_vacuum_delay +pg_tables_expansion_rate_analyze_count = pg_tables_expansion_rate_analyze_count +pg_tables_expansion_rate_autoanalyze_count = pg_tables_expansion_rate_autoanalyze_count +pg_tables_expansion_rate_autovacuum_count = pg_tables_expansion_rate_autovacuum_count +pg_tables_expansion_rate_dead_rate = pg_tables_expansion_rate_dead_rate +pg_tables_expansion_rate_vacuum_count = pg_tables_expansion_rate_vacuum_count +pg_tables_size_bytes = pg_tables_size_bytes +pg_tables_size_indexsize = pg_tables_size_indexsize +pg_tables_size_relsize = pg_tables_size_relsize +pg_tables_size_toastsize = pg_tables_size_toastsize +pg_thread_pool_listener = pg_thread_pool_listener +pg_timestamp = pg_timestamp +pg_uptime = pg_uptime +pg_wait_events_total_wait_time = pg_wait_events_total_wait_time +pg_wait_events_wait = pg_wait_events_wait +pg_write_lsn = pg_write_lsn +process_cpu_seconds_total = process_cpu_seconds_total +process_max_fds = process_max_fds +process_open_fds = process_open_fds +process_resident_memory_bytes = process_resident_memory_bytes +process_start_time_seconds = process_start_time_seconds +process_virtual_memory_bytes = process_virtual_memory_bytes +process_virtual_memory_max_bytes = process_virtual_memory_max_bytes +statement_responsetime_percentile_p80 = statement_responsetime_percentile_p80 +statement_responsetime_percentile_p95 = statement_responsetime_percentile_p95 + + diff --git a/src/gausskernel/dbmind/tools/service/dai.py b/src/gausskernel/dbmind/tools/service/dai.py index 48a3617cf..78df0e0f2 100644 --- a/src/gausskernel/dbmind/tools/service/dai.py +++ b/src/gausskernel/dbmind/tools/service/dai.py @@ -28,6 +28,11 @@ from dbmind.common.types import Sequence from dbmind.common.types.misc import SlowQuery from dbmind.metadatabase import dao + +# Singleton pattern with starving formula +# will capture exception in the main thread. +TsdbClientFactory.get_tsdb_client() + # Notice: 'DISTINGUISHING_INSTANCE_LABEL' is a magic string, i.e., our own name. # Thus, not all collection agents (such as Prometheus's openGauss-exporter) # distinguish different instance addresses through this one.