grafana / ibm-db2-prometheus-exporter

A golang based prometheus metrics exporter for IBM DB2.
Apache License 2.0
10 stars 6 forks source link

initial exporter implementation #1

Closed dpaasman00 closed 1 year ago

dpaasman00 commented 1 year ago

This pr is an initial implementation of the ibm db2 exporter.

Sample Metrics Output ``` # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 10 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.19.9"} 1 # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use. # TYPE go_memstats_alloc_bytes gauge go_memstats_alloc_bytes 243536 # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter go_memstats_alloc_bytes_total 243536 # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table. # TYPE go_memstats_buck_hash_sys_bytes gauge go_memstats_buck_hash_sys_bytes 4630 # HELP go_memstats_frees_total Total number of frees. # TYPE go_memstats_frees_total counter go_memstats_frees_total 0 # HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata. # TYPE go_memstats_gc_sys_bytes gauge go_memstats_gc_sys_bytes 7.728688e+06 # HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use. # TYPE go_memstats_heap_alloc_bytes gauge go_memstats_heap_alloc_bytes 243536 # HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used. # TYPE go_memstats_heap_idle_bytes gauge go_memstats_heap_idle_bytes 1.703936e+06 # HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use. # TYPE go_memstats_heap_inuse_bytes gauge go_memstats_heap_inuse_bytes 2.031616e+06 # HELP go_memstats_heap_objects Number of allocated objects. # TYPE go_memstats_heap_objects gauge go_memstats_heap_objects 847 # HELP go_memstats_heap_released_bytes Number of heap bytes released to OS. # TYPE go_memstats_heap_released_bytes gauge go_memstats_heap_released_bytes 1.703936e+06 # HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system. # TYPE go_memstats_heap_sys_bytes gauge go_memstats_heap_sys_bytes 3.735552e+06 # HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection. # TYPE go_memstats_last_gc_time_seconds gauge go_memstats_last_gc_time_seconds 0 # HELP go_memstats_lookups_total Total number of pointer lookups. # TYPE go_memstats_lookups_total counter go_memstats_lookups_total 0 # HELP go_memstats_mallocs_total Total number of mallocs. # TYPE go_memstats_mallocs_total counter go_memstats_mallocs_total 847 # HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures. # TYPE go_memstats_mcache_inuse_bytes gauge go_memstats_mcache_inuse_bytes 4800 # HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system. # TYPE go_memstats_mcache_sys_bytes gauge go_memstats_mcache_sys_bytes 15600 # HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures. # TYPE go_memstats_mspan_inuse_bytes gauge go_memstats_mspan_inuse_bytes 48960 # HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system. # TYPE go_memstats_mspan_sys_bytes gauge go_memstats_mspan_sys_bytes 65088 # HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place. # TYPE go_memstats_next_gc_bytes gauge go_memstats_next_gc_bytes 4.194304e+06 # HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations. # TYPE go_memstats_other_sys_bytes gauge go_memstats_other_sys_bytes 1.21257e+06 # HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator. # TYPE go_memstats_stack_inuse_bytes gauge go_memstats_stack_inuse_bytes 458752 # HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator. # TYPE go_memstats_stack_sys_bytes gauge go_memstats_stack_sys_bytes 458752 # HELP go_memstats_sys_bytes Number of bytes obtained from system. # TYPE go_memstats_sys_bytes gauge go_memstats_sys_bytes 1.322088e+07 # HELP go_threads Number of OS threads created. # TYPE go_threads gauge go_threads 8 # HELP ibm_db2_application_active The number of applications that are currently connected to the database. # TYPE ibm_db2_application_active gauge ibm_db2_application_active{database_name="sampledb"} 1 # HELP ibm_db2_application_executing The number of applications for which the database manager is currently processing a request. # TYPE ibm_db2_application_executing gauge ibm_db2_application_executing{database_name="sampledb"} 1 # HELP ibm_db2_bufferpool_hit_ratio The percentage of time that the database manager did not need to load a page from disk to service a page request. # TYPE ibm_db2_bufferpool_hit_ratio gauge ibm_db2_bufferpool_hit_ratio{bufferpool_name="IBMDEFAULTBP",database_name="sampledb"} 81.53 # HELP ibm_db2_connections_top_total The maximum number of concurrent connections to the database since the database was activated. # TYPE ibm_db2_connections_top_total counter ibm_db2_connections_top_total{database_name="sampledb"} 16 # HELP ibm_db2_deadlock_total The total number of deadlocks that have occurred. # TYPE ibm_db2_deadlock_total counter ibm_db2_deadlock_total{database_name="sampledb"} 0 # HELP ibm_db2_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which ibm_db2_exporter was built, and the goos and goarch for the build. # TYPE ibm_db2_exporter_build_info gauge ibm_db2_exporter_build_info{branch="",goarch="amd64",goos="linux",goversion="go1.19.9",revision="unknown",tags="unknown",version=""} 1 # HELP ibm_db2_lock_timeout_total The number of timeouts that a request to lock an object occurred instead of being granted. # TYPE ibm_db2_lock_timeout_total counter ibm_db2_lock_timeout_total{database_name="sampledb"} 0 # HELP ibm_db2_lock_usage The number of agents waiting on a lock. # TYPE ibm_db2_lock_usage gauge ibm_db2_lock_usage{database_name="sampledb",lock_state="active"} 3 ibm_db2_lock_usage{database_name="sampledb",lock_state="waiting"} 0 # HELP ibm_db2_lock_wait_time The average wait time for a lock. # TYPE ibm_db2_lock_wait_time gauge ibm_db2_lock_wait_time{database_name="sampledb"} 0 # HELP ibm_db2_log_operations_total The number of log pages read and written to by the logger. # TYPE ibm_db2_log_operations_total counter ibm_db2_log_operations_total{database_name="sampledb",log_member="0",log_operation_type="read"} 0 ibm_db2_log_operations_total{database_name="sampledb",log_member="0",log_operation_type="write"} 0 # HELP ibm_db2_log_usage The disk blocks of active logs pace in the database that is not being used by uncommitted transactions. Each block correlates to 4 KiB blocks of storage. # TYPE ibm_db2_log_usage gauge ibm_db2_log_usage{database_name="sampledb",log_member="0",log_usage_type="available"} 26086 ibm_db2_log_usage{database_name="sampledb",log_member="0",log_usage_type="used"} 0 # HELP ibm_db2_row_total The total number of rows inserted, updated, read or deleted. # TYPE ibm_db2_row_total counter ibm_db2_row_total{database_name="sampledb",row_state="deleted"} 0 ibm_db2_row_total{database_name="sampledb",row_state="inserted"} 0 ibm_db2_row_total{database_name="sampledb",row_state="read"} 732 ibm_db2_row_total{database_name="sampledb",row_state="updated"} 0 # HELP ibm_db2_tablespace_usage The size and usage of table space in bytes. # TYPE ibm_db2_tablespace_usage gauge ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="SYSCATSPACE",tablespace_type="free"} 1.2976128e+07 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="SYSCATSPACE",tablespace_type="total"} 1.34217728e+08 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="SYSCATSPACE",tablespace_type="used"} 1.21225216e+08 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="SYSTOOLSPACE",tablespace_type="free"} 3.293184e+07 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="SYSTOOLSPACE",tablespace_type="total"} 3.3554432e+07 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="SYSTOOLSPACE",tablespace_type="used"} 606208 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="TEMPSPACE1",tablespace_type="free"} 0 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="TEMPSPACE1",tablespace_type="total"} 4096 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="TEMPSPACE1",tablespace_type="used"} 4096 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="USERSPACE1",tablespace_type="free"} 3.3030144e+07 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="USERSPACE1",tablespace_type="total"} 3.3554432e+07 ibm_db2_tablespace_usage{database_name="sampledb",tablespace_name="USERSPACE1",tablespace_type="used"} 393216 # HELP ibm_db2_up Metric indicating the status of the exporter collection. 1 indicates that the connection to IBM DB2 was successful, and all available metrics were collected. A 0 indicates that the exporter failed to collect 1 or more metrics, due to an inability to connect to IBM DB2. # TYPE ibm_db2_up gauge ibm_db2_up{database_name="sampledb"} 1 # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds. # TYPE process_cpu_seconds_total counter process_cpu_seconds_total 0.03 # HELP process_max_fds Maximum number of open file descriptors. # TYPE process_max_fds gauge process_max_fds 524288 # HELP process_open_fds Number of open file descriptors. # TYPE process_open_fds gauge process_open_fds 9 # HELP process_resident_memory_bytes Resident memory size in bytes. # TYPE process_resident_memory_bytes gauge process_resident_memory_bytes 3.8944768e+07 # HELP process_start_time_seconds Start time of the process since unix epoch in seconds. # TYPE process_start_time_seconds gauge process_start_time_seconds 1.6861598362e+09 # HELP process_virtual_memory_bytes Virtual memory size in bytes. # TYPE process_virtual_memory_bytes gauge process_virtual_memory_bytes 1.256849408e+09 # HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes. # TYPE process_virtual_memory_max_bytes gauge process_virtual_memory_max_bytes 1.8446744073709552e+19 # HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served. # TYPE promhttp_metric_handler_requests_in_flight gauge promhttp_metric_handler_requests_in_flight 1 # HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code. # TYPE promhttp_metric_handler_requests_total counter promhttp_metric_handler_requests_total{code="200"} 0 promhttp_metric_handler_requests_total{code="500"} 0 promhttp_metric_handler_requests_total{code="503"} 0 ```
CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

dpaasman00 commented 1 year ago

@Dasomeone I believe I've addressed all your review comments, please let me know if I missed anything or if you notice something else. Thanks for taking a look!

Also I want to note that during the mixin process I've noticed some new behavior with DB2. To get the most accurate data from DB2, the database being monitored needs to be "explicitly activated". This does have a performance impact on the DB2 instance, but to get the most accurate data it is recommended. We leave it up to the user to enable and take the performance hit for accuracy depending on their environment. I added new documentation to the README detailing the effects of activating a database and how to do so. Let me know if you've got any thoughts on this!

Dasomeone commented 1 year ago

@Dasomeone I believe I've addressed all your review comments, please let me know if I missed anything or if you notice something else. Thanks for taking a look!

Also I want to note that during the mixin process I've noticed some new behavior with DB2. To get the most accurate data from DB2, the database being monitored needs to be "explicitly activated". This does have a performance impact on the DB2 instance, but to get the most accurate data it is recommended. We leave it up to the user to enable and take the performance hit for accuracy depending on their environment. I added new documentation to the README detailing the effects of activating a database and how to do so. Let me know if you've got any thoughts on this!

That is an excellent catch, thank you for documenting it! Definitely something we should mention in the integration instructions as well, when we get to them :)