zalando-zmon / zmon-worker

ZMON Python Worker
https://zmon.io/
Other
19 stars 41 forks source link

prometheus flat #356

Closed danielrohe closed 5 years ago

danielrohe commented 6 years ago

In order to better work with metrics in prometheus format I want to introduce another flat format that also works together with grafana

# HELP http_server_requests_seconds  
# TYPE http_server_requests_seconds summary
http_server_requests_seconds{exception="None",method="GET",status="200",uri="/api/hello",quantile="0.95",} 0.003080192
http_server_requests_seconds{exception="None",method="GET",status="200",uri="/api/hello",quantile="0.99",} 0.071237632
http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/api/hello",} 20.0
http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/api/hello",} 0.103182669
# HELP http_server_requests_seconds_max  
# TYPE http_server_requests_seconds_max gauge
http_server_requests_seconds_max{exception="None",method="GET",status="200",uri="/api/hello",} 0.067652582
# HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for  the Java virtual machine to use
# TYPE jvm_memory_committed_bytes gauge
jvm_memory_committed_bytes{area="nonheap",id="Code Cache",} 1.9070976E7
jvm_memory_committed_bytes{area="nonheap",id="Metaspace",} 5.5574528E7
jvm_memory_committed_bytes{area="nonheap",id="Compressed Class Space",} 7340032.0
jvm_memory_committed_bytes{area="heap",id="PS Eden Space",} 2.84688384E8
jvm_memory_committed_bytes{area="heap",id="PS Survivor Space",} 1.6252928E7
jvm_memory_committed_bytes{area="heap",id="PS Old Gen",} 2.3855104E8
# HELP httpsessions_max httpsessions_max
# TYPE httpsessions_max gauge
httpsessions_max -1.0
# HELP httpsessions_active httpsessions_active
# TYPE httpsessions_active gauge
httpsessions_active 0.0
# HELP mem mem
# TYPE mem gauge
mem 370583.0
# HELP mem_free mem_free
# TYPE mem_free gauge
mem_free 176263.0
# HELP processors processors
# TYPE processors gauge
processors 8.0

gets converted to

{
        "jvm_memory_committed_bytes": {
            "area.nonheap.id.Code Cache": 1.9070976E7,
            "area.nonheap.id.Metaspace": 5.5574528E7,
            "area.nonheap.id.Compressed Class Space": 7340032.0,
            "area.heap.id.PS Eden Space": 2.84688384E8,
            "area.heap.id.PS Survivor Space": 1.6252928E7,
            "area.heap.id.PS Old Gen": 2.3855104E8
        },
        "httpsessions_max": -1.0,
        "httpsessions_active": 0.0,
        "mem": 370583.0,
        "mem_free": 176263.0,
        "processors": 8.0,
        "http_server_requests_seconds": {
            "exception.None.method.GET.quantile.0.95.status.200.uri./api/hello": 0.003080192,
            "exception.None.method.GET.quantile.0.99.status.200.uri./api/hello": 0.071237632,
        },
        "http_server_requests_seconds_count": {
            "exception.None.method.GET.status.200.uri./api/hello": 20.0
        },
        "http_server_requests_seconds_max": {
            "exception.None.method.GET.status.200.uri./api/hello": 0.067652582
        },
        "http_server_requests_seconds_sum": {
            "exception.None.method.GET.status.200.uri./api/hello": 0.103182669
        }
    }
codecov[bot] commented 6 years ago

Codecov Report

Merging #356 into master will increase coverage by 0.06%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #356      +/-   ##
==========================================
+ Coverage   75.32%   75.38%   +0.06%     
==========================================
  Files          80       80              
  Lines        5819     5839      +20     
==========================================
+ Hits         4383     4402      +19     
- Misses       1436     1437       +1
Impacted Files Coverage Δ
zmon_worker_monitor/builtins/plugins/http.py 97.7% <100%> (-0.28%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4bf08b6...4f624ae. Read the comment docs.

danielrohe commented 6 years ago

should add an optional metrics filter, so users can call http().prometheus_flat(['key1', 'key2']) to grab only the keys key1 and key2

vetinari commented 6 years ago

@danielrohe please fix the pep8 issues:

py27 runtests: commands[1] | flake8 .
./zmon_worker_monitor/builtins/plugins/http.py:300:43: E251 unexpected spaces around keyword / parameter equals
./zmon_worker_monitor/builtins/plugins/http.py:300:45: E251 unexpected spaces around keyword / parameter equals
./tests/test_http.py:462:65: E231 missing whitespace after ','
./tests/test_http.py:462:121: E501 line too long (154 > 120 characters)
danielrohe commented 6 years ago

:+1:

mohabusama commented 5 years ago

👍

mohabusama commented 5 years ago

@danielrohe Thanks! Could you please update zmon-docs as well.