mdl29 / scratchy

Scratchy, application de tchat projet LPH
GNU General Public License v3.0
2 stars 8 forks source link

125 [back] [metrics] add metrics to scratchy. #245

Closed landerneRPi closed 3 years ago

landerneRPi commented 3 years ago

installation: $ pip install prometheus-flask-exporter or $ pip install -r requirements.txt

get metrics:

Should output something like that:

# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 445.0
python_gc_objects_collected_total{generation="1"} 466.0
python_gc_objects_collected_total{generation="2"} 0.0
# HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 86.0
python_gc_collections_total{generation="1"} 7.0
python_gc_collections_total{generation="2"} 0.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="8",patchlevel="10",version="3.8.10"} 1.0
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.22003456e+08
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 3.1944704e+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.62713218493e+09
# 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.19
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 6.0
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1024.0
# HELP flask_exporter_info Information about the Prometheus Flask exporter
# TYPE flask_exporter_info gauge
flask_exporter_info{version="0.18.2"} 1.0
...

But it does not work as expected !

Benvii commented 3 years ago

I've got a 404 on /metrics :

INFO:werkzeug:127.0.0.1 - - [15/Aug/2021 19:26:01] "GET /metrics HTTP/1.1" 404 

Can someone else test it ? are you sure it work on this branch ?

I've entirely recreated my python virtualenv and I still get a 404.

Thanks in advance.

Draeggon commented 3 years ago

I also got 404 error when i tried this implementation myself

Benvii commented 3 years ago

It seems that export DEBUG_METRICS=True is needed for metric to work in developpement / debugger mode. We need to update scratchy-server CLI to add this.

Benvii commented 3 years ago

@landerneRPi can you make this update : 5f27dc538c1c580f56b966644af542ea8c528a5b it solved the issue