Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prometheus metrics support #180

Merged
merged 1 commit into from
Sep 5, 2018

Conversation

gouthamve
Copy link
Contributor

Fixes: #178

➜ ghostunnel git:(add-prometheus-support) curl -k --cacert test-keys/cacert.pem

https://localhost:6060/_metrics\?format\=prometheus
# HELP ghostunnel_accept_error accept.error
# TYPE ghostunnel_accept_error gauge
ghostunnel_accept_error 0
# HELP ghostunnel_accept_success accept.success
# TYPE ghostunnel_accept_success gauge
ghostunnel_accept_success 1
# HELP ghostunnel_accept_timeout accept.timeout
# TYPE ghostunnel_accept_timeout gauge
ghostunnel_accept_timeout 0
# HELP ghostunnel_accept_total accept.total
# TYPE ghostunnel_accept_total gauge
ghostunnel_accept_total 1
# HELP ghostunnel_conn_handshake conn.handshake
# TYPE ghostunnel_conn_handshake gauge
ghostunnel_conn_handshake 0
# HELP ghostunnel_conn_lifetime conn.lifetime
# TYPE ghostunnel_conn_lifetime gauge
ghostunnel_conn_lifetime 0
# HELP ghostunnel_conn_open conn.open
# TYPE ghostunnel_conn_open gauge
ghostunnel_conn_open 1
# HELP ghostunnel_runtime_cgo_calls runtime.cgo-calls
# TYPE ghostunnel_runtime_cgo_calls gauge
ghostunnel_runtime_cgo_calls 13
# HELP ghostunnel_runtime_goroutines runtime.goroutines
# TYPE ghostunnel_runtime_goroutines gauge
ghostunnel_runtime_goroutines 10
# HELP ghostunnel_runtime_mem_alloc runtime.mem.alloc
# TYPE ghostunnel_runtime_mem_alloc gauge
ghostunnel_runtime_mem_alloc 3.74868e+06
# HELP ghostunnel_runtime_mem_frees runtime.mem.frees
# TYPE ghostunnel_runtime_mem_frees gauge
ghostunnel_runtime_mem_frees 809
# HELP ghostunnel_runtime_mem_gc_cpu_fraction runtime.mem.gc.cpu-fraction
# TYPE ghostunnel_runtime_mem_gc_cpu_fraction gauge
ghostunnel_runtime_mem_gc_cpu_fraction 0
# HELP ghostunnel_runtime_mem_gc_num_gc runtime.mem.gc.num-gc
# TYPE ghostunnel_runtime_mem_gc_num_gc gauge
ghostunnel_runtime_mem_gc_num_gc 0
# HELP ghostunnel_runtime_mem_heap_alloc runtime.mem.heap.alloc
# TYPE ghostunnel_runtime_mem_heap_alloc gauge
ghostunnel_runtime_mem_heap_alloc 3.74868e+06
# HELP ghostunnel_runtime_mem_heap_idle runtime.mem.heap.idle
# TYPE ghostunnel_runtime_mem_heap_idle gauge
ghostunnel_runtime_mem_heap_idle 499712
# HELP ghostunnel_runtime_mem_heap_inuse runtime.mem.heap.inuse
# TYPE ghostunnel_runtime_mem_heap_inuse gauge
ghostunnel_runtime_mem_heap_inuse 5.20192e+06
# HELP ghostunnel_runtime_mem_heap_objects runtime.mem.heap.objects
# TYPE ghostunnel_runtime_mem_heap_objects gauge
ghostunnel_runtime_mem_heap_objects 67891
# HELP ghostunnel_runtime_mem_heap_released runtime.mem.heap.released
# TYPE ghostunnel_runtime_mem_heap_released gauge
ghostunnel_runtime_mem_heap_released 0
# HELP ghostunnel_runtime_mem_heap_sys runtime.mem.heap.sys
# TYPE ghostunnel_runtime_mem_heap_sys gauge
ghostunnel_runtime_mem_heap_sys 5.701632e+06
# HELP ghostunnel_runtime_mem_lookups runtime.mem.lookups
# TYPE ghostunnel_runtime_mem_lookups gauge
ghostunnel_runtime_mem_lookups 22
# HELP ghostunnel_runtime_mem_mallocs runtime.mem.mallocs
# TYPE ghostunnel_runtime_mem_mallocs gauge
ghostunnel_runtime_mem_mallocs 68700
# HELP ghostunnel_runtime_mem_stack_inuse runtime.mem.stack.inuse
# TYPE ghostunnel_runtime_mem_stack_inuse gauge
ghostunnel_runtime_mem_stack_inuse 589824
# HELP ghostunnel_runtime_mem_stack_sys runtime.mem.stack.sys
# TYPE ghostunnel_runtime_mem_stack_sys gauge
ghostunnel_runtime_mem_stack_sys 589824
# HELP ghostunnel_runtime_mem_sys runtime.mem.sys
# TYPE ghostunnel_runtime_mem_sys gauge
ghostunnel_runtime_mem_sys 9.37804e+06
# HELP ghostunnel_runtime_mem_total_alloc runtime.mem.total-alloc
# TYPE ghostunnel_runtime_mem_total_alloc gauge
ghostunnel_runtime_mem_total_alloc 3.74868e+06
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# 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 16
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.10.3"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 3.892392e+06
# 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 3.93252e+06
# 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.444053e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 2190
# 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 -7.516861870577893e-09
# 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 409600
# 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 3.892392e+06
# 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 229376
# 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 5.341184e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 68348
# 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 0
# 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 5.57056e+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 1.5346817025567987e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 23
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 70538
# 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 6944
# 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 16384
# 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 85120
# 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 98304
# 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.249315e+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 655360
# 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 655360
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 9.443576e+06
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 13
# 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"} 1
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0

@CLAassistant
Copy link

CLAassistant commented Aug 19, 2018

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

coveralls commented Aug 19, 2018

Coverage Status

Coverage decreased (-0.002%) to 92.437% when pulling eae156c on gouthamve:add-prometheus-support into 9c79388 on square:master.

main.go Outdated
@@ -286,6 +290,10 @@ func run(args []string) error {
if *metricsURL != "" {
logger.Printf("metrics enabled; reporting metrics via POST to %s", *metricsURL)
}
// Always enable prometheus registry. The overhead should be quite minimal as an in-mem map is updated
// with the values.
pClient := prometheusmetrics.NewPrometheusProvider(metrics.DefaultRegistry, "ghostunnel", "", prometheus.DefaultRegisterer, 1*time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the “ghostunnel” string used for here? Depending on how this is used the metrics-prefix (defaults to “ghostunnel”) flag might make more sense here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@csstaub
Copy link
Member

csstaub commented Aug 22, 2018

Thanks @gouthamve! Code looks good to me apart from the comment I left. Also I’m traveling w/o my laptop and so can’t do a release right now, but I’ll make sure to put tag this in the next version when I’m back home.

Signed-off-by: Goutham Veeramachaneni <[email protected]>
@gouthamve gouthamve force-pushed the add-prometheus-support branch from 5d840f8 to eae156c Compare August 22, 2018 15:46
@gouthamve
Copy link
Contributor Author

@csstaub Thanks for the review! I did notice the flag before and it fits perfectly.

I am in no hurry for a release as I'll be building it myself for now. Have fun on your travels :)

@csstaub csstaub merged commit 19b29f0 into ghostunnel:master Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants