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

WIP: feat(prometheus): add prometheus endpoint providing basic request met… #404

Merged
merged 4 commits into from
May 7, 2020

Conversation

ecktom
Copy link
Contributor

@ecktom ecktom commented Apr 6, 2020

Proposed changes

This will add an basic prometheus endpoint providing request metrics to get some application insights

Checklist

  • I have read the contributing guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability. If this pull request addresses a security.
    vulnerability, I confirm that I got green light (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added or changed the documentation.

Further comments

@ecktom ecktom force-pushed the feat/add_prometheus branch from b92a8ed to b3c5b21 Compare April 6, 2020 22:04
}

// TODO: Make prom settings (port/path) configurable
promAddr := ":9124"
Copy link
Member

Choose a reason for hiding this comment

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

I think we can simply export this at the admin api endpoint :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ehm, what admin api endpoint? :D

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant API endpoint!

@aeneasr
Copy link
Member

aeneasr commented Apr 10, 2020

Sorry, I forgot to press on "submit review" :)

@ecktom
Copy link
Contributor Author

ecktom commented Apr 25, 2020

So I'm not sure what you mean regarding the config but I've build the version from the PR locally and tested it by curling the scraping endpoint which looks good:

/ # curl localhost:9124
# 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"} 6.787e-06
go_gc_duration_seconds{quantile="0.25"} 2.4558e-05
go_gc_duration_seconds{quantile="0.5"} 4.1088e-05
go_gc_duration_seconds{quantile="0.75"} 0.000107255
go_gc_duration_seconds{quantile="1"} 0.003268809
go_gc_duration_seconds_sum 0.006710868
go_gc_duration_seconds_count 37
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 27
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.14"} 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.355816e+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 1.16957672e+08
# 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.466244e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 480030
# 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 0.00019696603142984264
# 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 3.582216e+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 4.355816e+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 5.8769408e+07
# 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 7.421952e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 29154
# 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 5.685248e+07
# 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 6.619136e+07
# 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.5878100098625474e+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 509184
# 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 3472
# 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 116960
# 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 147456
# 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.990544e+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 637044
# 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 917504
# 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 917504
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 7.2958208e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 10
# HELP ory_oathkeeper_request_duration_in_seconds Time spent serving requests.
# TYPE ory_oathkeeper_request_duration_in_seconds histogram
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.005"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.01"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.025"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.05"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.1"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.25"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="0.5"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="1"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="2.5"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="5"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="10"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200",le="+Inf"} 7
ory_oathkeeper_request_duration_in_seconds_sum{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200"} 0.0013910569999999998
ory_oathkeeper_request_duration_in_seconds_count{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200"} 7
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.005"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.01"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.025"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.05"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.1"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.25"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="0.5"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="1"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="2.5"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="5"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="10"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200",le="+Inf"} 56
ory_oathkeeper_request_duration_in_seconds_sum{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200"} 0.009497334000000001
ory_oathkeeper_request_duration_in_seconds_count{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200"} 56
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.005"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.01"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.025"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.05"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.1"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.25"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="0.5"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="1"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="2.5"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="5"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="10"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200",le="+Inf"} 2
ory_oathkeeper_request_duration_in_seconds_sum{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200"} 0.000384277
ory_oathkeeper_request_duration_in_seconds_count{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200"} 2
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.005"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.01"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.025"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.05"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.1"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.25"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="0.5"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="1"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="2.5"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="5"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="10"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200",le="+Inf"} 168
ory_oathkeeper_request_duration_in_seconds_sum{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200"} 0.027453962999999994
ory_oathkeeper_request_duration_in_seconds_count{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200"} 168
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.005"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.01"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.025"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.05"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.1"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.25"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="0.5"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="1"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="2.5"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="5"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="10"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200",le="+Inf"} 1
ory_oathkeeper_request_duration_in_seconds_sum{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200"} 0.000716618
ory_oathkeeper_request_duration_in_seconds_count{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200"} 1
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.005"} 3
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.01"} 3
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.025"} 3
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.05"} 3
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.1"} 3
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.25"} 4
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="0.5"} 4
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="1"} 4
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="2.5"} 4
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="5"} 4
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="10"} 4
ory_oathkeeper_request_duration_in_seconds_bucket{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200",le="+Inf"} 4
ory_oathkeeper_request_duration_in_seconds_sum{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200"} 0.16967901900000001
ory_oathkeeper_request_duration_in_seconds_count{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200"} 4
# HELP ory_oathkeeper_request_total Total number of requests
# TYPE ory_oathkeeper_request_total counter
ory_oathkeeper_request_total{method="GET",request="/decisions/",service="oathkeeper-api",status_code="200"} 7
ory_oathkeeper_request_total{method="GET",request="/decisions/api/endpoint-A/",service="oathkeeper-api",status_code="200"} 56
ory_oathkeeper_request_total{method="GET",request="/decisions/api/endpoint-A/resource-D",service="oathkeeper-api",status_code="200"} 2
ory_oathkeeper_request_total{method="GET",request="/decisions/api/endpoint-A/resource-A",service="oathkeeper-api",status_code="200"} 168
ory_oathkeeper_request_total{method="GET",request="/decisions/api/endpoint-B/resource-B",service="oathkeeper-api",status_code="200"} 1
ory_oathkeeper_request_total{method="GET",request="/decisions/api/endpoint-B/resource-C",service="oathkeeper-api",status_code="200"} 4
# 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.59
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 65536
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 21
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 2.727936e+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.58780960309e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.3895936e+08
# 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

@ecktom ecktom requested a review from aeneasr April 25, 2020 10:32
@aeneasr
Copy link
Member

aeneasr commented Apr 25, 2020

So I'm not sure what you mean regarding the config but I've build the version from the PR locally and tested it by curling the scraping endpoint which looks good:

Yes, but you can't configure the host or the port on which this listens on. This can't be hardcoded!

Now that I see your TODO I don't understand you comment :D

@ecktom ecktom force-pushed the feat/add_prometheus branch from b3c5b21 to 58a499e Compare April 29, 2020 09:46
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

This looks pretty good to me! I've found a couple of things that could be improved. Also, would you be able to add a small section at the bottom of https://github.com/ory/oathkeeper/blob/master/docs/docs/configure-deploy.md#authorizing-requests on setting up ORY Oathkeeper with prometheus (optionally grafana if it's easy to do).

metrics/middleware.go Show resolved Hide resolved
}

// NewPrometheusRepository creates a new prometheus repository with the given settings
func NewPrometheusRepository(logger log.FieldLogger) (*PrometheusRepository, error) {
Copy link
Member

Choose a reason for hiding this comment

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

No error is returned so is the error return value required?

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

metrics/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus.go Show resolved Hide resolved
promAddr := d.Configuration().PrometheusServeAddress()
go func() {
// Expose the registered metrics via HTTP.
httpServer := &http.Server{Handler: promhttp.HandlerFor(prometheusRepo.Registry, promhttp.HandlerOpts{}), Addr: promAddr}
Copy link
Member

Choose a reason for hiding this comment

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

prometheusRepo.Registry will panic when prometheusRepo, err := metrics.NewPrometheusRepository(logger) returns an error!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah right, I removed the returning error is it did not make sense anyways...


promPath := d.Configuration().PrometheusMetricsPath()
promAddr := d.Configuration().PrometheusServeAddress()
go func() {
Copy link
Member

Choose a reason for hiding this comment

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

You could add this to the tasks listed below: https://github.com/ory/oathkeeper/pull/404/files#diff-4c51d95b26718af4a2ac3bec33e54e49R220

Because it makes sense to use a waitgroup for shutdown here right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done ;)

httpServer := &http.Server{Handler: promhttp.HandlerFor(prometheusRepo.Registry, promhttp.HandlerOpts{}), Addr: promAddr}
http.Handle(promPath, promhttp.Handler())
logger.Infof("Proemtheus listening on %s...", promAddr)
if err := httpServer.ListenAndServe(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done ;)

@ecktom ecktom requested a review from aeneasr May 1, 2020 13:16
@aeneasr
Copy link
Member

aeneasr commented May 1, 2020

If you merge with master, the weird failing test cases (flaky) will stop to happen :)

@ecktom ecktom force-pushed the feat/add_prometheus branch from 8ede182 to 9b77989 Compare May 1, 2020 13:19
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Not sure if you've missed this comment:

This looks pretty good to me! I've found a couple of things that could be improved. Also, would you be able to add a small section at the bottom of https://github.com/ory/oathkeeper/blob/master/docs/docs/configure-deploy.md#authorizing-requests on setting up ORY Oathkeeper with prometheus (optionally grafana if it's easy to do).

Let me know :)

metrics/prometheus.go Outdated Show resolved Hide resolved
metrics/prometheus.go Show resolved Hide resolved
@ecktom
Copy link
Contributor Author

ecktom commented May 1, 2020

Oh yeah, I've missed that comment :D Will add some words about this once it's running as I would also setup a Grafana board for us internally which I surely can share afterwards.
Should we test it e2e with the changes from today?

@aeneasr
Copy link
Member

aeneasr commented May 1, 2020

If you have ideas how to e2e test it that would be awesome!

@ecktom
Copy link
Contributor Author

ecktom commented May 1, 2020

A dirty one... ;) Put it on our staging ENV, didn't crash or log any error and provided metrics on :9000/metrics as expected. So I guess it's good to go ;)

@aeneasr
Copy link
Member

aeneasr commented May 1, 2020

Ok nice, I thought you meant automated e2e test :D

Do you need help with the docs?

@ecktom
Copy link
Contributor Author

ecktom commented May 1, 2020

Will come up with something next week, should be OK.

@aeneasr
Copy link
Member

aeneasr commented May 2, 2020

Awesome, thanks!

@ecktom ecktom mentioned this pull request May 6, 2020
5 tasks
@aeneasr
Copy link
Member

aeneasr commented May 7, 2020

Thank you for your hard work!

@aeneasr aeneasr merged commit fdaed46 into ory:master May 7, 2020
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.

2 participants