optakt / flow-dps

Flow Data Provisioning Service
Apache License 2.0
29 stars 13 forks source link

Add metrics server and move badger metrics to dedicated package #492

Closed Ullaakut closed 2 years ago

Ullaakut commented 2 years ago

Goal of this PR

Fixes #489

Additional Notes

This PR is a draft until I can test it and ensure that it works as expected.

Checklist

Ullaakut commented 2 years ago

@awfm9 Did you test it and run it?

awfm9 commented 2 years ago

@awfm9 Did you test it and run it?

No.

Ullaakut commented 2 years ago

@awfm9 If the current solution works for you, I'll give it a test today and if I can confirm it works as expected, I'll set the PR as ready for review.

Not sure if including tests for the metrics makes sense, as it's mostly just calls to prometheus that can't fail.

Ullaakut commented 2 years ago

Here is the result of calling the prometheus metrics endpoint while it's running:

# HELP badger_badger_pending_writes_total tracks the number of pending writes
# TYPE badger_badger_pending_writes_total untyped
badger_badger_pending_writes_total{path="data"} 0
badger_badger_pending_writes_total{path="index"} 0
# HELP badger_blocked_puts_total number of blocked puts
# TYPE badger_blocked_puts_total untyped
badger_blocked_puts_total 0
# HELP badger_disk_reads_total cumulative number of reads
# TYPE badger_disk_reads_total untyped
badger_disk_reads_total 108618
# HELP badger_disk_writes_total cumulative number of writes
# TYPE badger_disk_writes_total untyped
badger_disk_writes_total 0
# HELP badger_gets_total number of gets
# TYPE badger_gets_total untyped
badger_gets_total 16659
# HELP badger_lsm_bloom_hits_total number of LSM bloom hits
# TYPE badger_lsm_bloom_hits_total untyped
badger_lsm_bloom_hits_total{level="l0"} 1
badger_lsm_bloom_hits_total{level="l1"} 2
# HELP badger_lsm_level_gets_total number of LSM gets
# TYPE badger_lsm_level_gets_total untyped
badger_lsm_level_gets_total{level="l0"} 2
badger_lsm_level_gets_total{level="l1"} 16655
# HELP badger_lsm_size_bytes size of the LSM in bytes
# TYPE badger_lsm_size_bytes untyped
badger_lsm_size_bytes{path="data"} 7.3496726e+07
badger_lsm_size_bytes{path="index"} 2.43510223e+08
# HELP badger_memtable_gets_total number of memtable gets
# TYPE badger_memtable_gets_total untyped
badger_memtable_gets_total 16659
# HELP badger_puts_total number of puts
# TYPE badger_puts_total untyped
badger_puts_total 0
# HELP badger_read_bytes cumulative number of bytes read
# TYPE badger_read_bytes untyped
badger_read_bytes 4.35384187e+08
# HELP badger_vlog_size_bytes size of the value log in bytes
# TYPE badger_vlog_size_bytes untyped
badger_vlog_size_bytes{path="data"} 1.678600198e+09
badger_vlog_size_bytes{path="index"} 1.499839982e+09
# HELP badger_written_bytes cumulative number of bytes written
# TYPE badger_written_bytes untyped
badger_written_bytes 0
# 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"} 4.43e-05
go_gc_duration_seconds{quantile="0.25"} 5.44e-05
go_gc_duration_seconds{quantile="0.5"} 6.4e-05
go_gc_duration_seconds{quantile="0.75"} 0.0001863
go_gc_duration_seconds{quantile="1"} 0.000278
go_gc_duration_seconds_sum 0.0010199
go_gc_duration_seconds_count 9
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 164
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.17.1"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 4.117042488e+09
# 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 4.87062208e+09
# 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 1.528718e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 2.675543e+06
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 4.580282913055718e-05
# 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 1.53922288e+08
# 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 4.117042488e+09
# 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 3.97549568e+08
# 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 4.125548544e+09
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 1.737738e+06
# 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.974272e+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 4.523098112e+09
# 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 1.6335159369197462e+09
# 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 4.413281e+06
# 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 153600
# 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 163840
# 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 5.888664e+06
# 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 9.617408e+06
# 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 7.582384976e+09
# 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 2.404794e+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 2.555904e+06
# 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 2.555904e+06
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 4.693291064e+09
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 17
# HELP indexed_blocks the number of indexed blocks
# TYPE indexed_blocks counter
indexed_blocks 2081
# HELP indexed_collections the number of indexed collections
# TYPE indexed_collections counter
indexed_collections 2
# HELP indexed_events the number of indexed events
# TYPE indexed_events counter
indexed_events 5
# HELP indexed_registers the number of indexed registers
# TYPE indexed_registers counter
indexed_registers 239
# HELP indexed_seals the number of indexed seals
# TYPE indexed_seals counter
indexed_seals 2073
# HELP indexed_transactions the number of indexed transactions
# TYPE indexed_transactions counter
indexed_transactions 7
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 11.95
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1024
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 480
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.638162432e+09
# 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.63351592764e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 6.536953856e+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

As you can see we have access to:

LGTY @awfm9 ?