sonata-nfv / son-gkeeper

SONATA's Service Platform Gatekeeper
http://www.sonata-nfv.eu
Apache License 2.0
2 stars 18 forks source link

New Monitoring related APIs #899

Closed jbonnet closed 7 years ago

jbonnet commented 7 years ago

[...] it would be nice to discuss how to proceed with the implementation of the following two additional apis on the gatekeeper in order to access Monitoring Manager data for entities different than VNFs (that is already implemented in GK API)

1) Get metric list -GET httpL///api/v1/prometheus/metrics/list

2) Get monitoring data filtered by labels -POST http:///api/v1/prometheus/metrics/data { "name": , "start": , "end": , "step": , "labels": [{"labeltag":,'labelid':},{"labeltag":,"labelid":}] }

jbonnet commented 7 years ago

So...

  1. above seems easy;
  2. what's returned here? Erros?
pkarkazis commented 7 years ago

Hi, in both cases, the returned codes are 200, 404 and 400.

jbonnet commented 7 years ago

thanks, @pkarkazis I'll start working on that

jbonnet commented 7 years ago

Sorry, @pkarkazis, just one more thing: 2. above is a POST... what should it return (I'm assuming the list of fields you mention is the body of the POST)?

jbonnet commented 7 years ago

Hey, @trakadasp, @pkarkazis

  1. above is available as .../api/v2/functions/metrics/names, like in
    {
    "metric_names": [
        "ALERTS", 
        "cnt_block_in_MB", 
        "cnt_block_ou_MB", 
        "cnt_cpu_perc", 
        ...
        "vms_state", 
        "vms_sum"
    ]
    }

    Tell me if you need something different. For 2. above, I still need to understand what it returns... (see my comment above)

Note 1: there a specific metric called ALERTS... is this also a real metric? Reads strange, when you compare with the other metrics... Note 2: maybe all the .../functions/metrics/... endpoints should be upgraded to their own endpoint, i.e., .../metrics/... (without being under /functions), since we might generalize this and also have metrics at the service level, no?

pkarkazis commented 7 years ago

Hi @jbonnet ,

  1. The provided path (/api/v2/functions/metrics/name) its fine i will check it asap. Regarding your nodes: Note 1: Under the 'ALERTS' Prometheus server provides the current status of the monitoring rules. So, we must keep it as it is. Note 2: I agree.

  2. Regarding the POST on http:///api/v1/prometheus/metrics/data An example of POST body is: { "end": "2017-09-26T13:15:34.000Z", "start": "2017-09-26T13:14:34.000Z", "name": "vm_cpu_perc", "step": "10s", "labels": [{ "labelid": "vnf", "labeltag": "exported_job" }, { "labelid": "cpu", "labeltag": "core" }] } and here is a response example: { "metrics": { "result": [{ "values": [ [1506431724, "16.75"], [1506431734, "16.75"] ], "metric": { "job": "sonata", "exported_job": "vnf", "instance": "pushgateway:9091", "exported_instance": "TEST-VNF:a44a4d56-9bf4-4e15-aef4-0e5a52d0aec2", "core": "cpu", "name": "vm_cpu_perc", "group": "development", "id": "a44a4d56-9bf4-4e15-aef4-0e5a52d0aec2" } }, { "values": [ [1506431724, "0"], [1506431734, "0"] ], "metric": { "job": "sonata", "exported_job": "vnf", "instance": "pushgateway:9091", "exported_instance": "vtc-nfv-1:nah678l2-4b7a-4771-b760-6484jfhy113", "core": "cpu", "name": "vm_cpu_perc", "group": "development", "id": "fc7fab95-4b7a-4771-b760-f62ec6e5cf09" } }], "resultType": "matrix" } }

jbonnet commented 7 years ago

Perfect, @pkarkazis This is next in my agenda... When you say you agree... with the promoted metrics you mean?

pkarkazis commented 7 years ago

Hi @jbonnet, I am referring to your second note above. I agree with your idea of upgrading the metrics endpoints under one generic metric endpoint it has sense.

jbonnet commented 7 years ago

Ok, @pkarkazis It seems that 2. is already implemented, under the .../api/v2/kpis/collected endpoint. Can you please confirm that? Do you want it provided in another endpoint?

pkarkazis commented 7 years ago

@jbonnet can you send me an example call to check it, because didn't found anything in documentation (https://github.com/sonata-nfv/son-gkeeper/wiki/KPIs-usage)

jbonnet commented 7 years ago

Hey, @pkarkazis You're absolutely right, I missed that endpoint. Now, before answering you, I'm facing a stupid problem I'm taking some time to solve: how to correctly encode that "labels":[{...},{...}] in the curl URL... I'll get back to you soon.

jbonnet commented 7 years ago

Using

require 'queryparams'
j={"end": "2017-09-26T13:15:34.000Z","start": "2017-09-26T13:14:34.000Z","name": "vm_cpu_perc","step": "10s","labels": [{"labelid": "vnf","labeltag": "exported_job"}, {"labelid": "cpu","labeltag": "core"}]}
QueryParams.encode(j)

the POST body you mention above becomes

end=2017-09-26T13%3A15%3A34.000Z&start=2017-09-26T13%3A14%3A34.000Z&name=vm_cpu_perc&step=10s&labels[][labelid]=vnf&labels[][labeltag]=exported_job&labels[][labelid]=cpu&labels[][labeltag]=core

So, now you can do a curl GET:

$ curl -g "http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis/collected?end=2017-09-26T13%3A15%3A34.000Z&start=2017-09-26T13%3A14%3A34.000Z&name=vm_cpu_perc&step=10s&labels[][labelid]=vnf&labels[][labeltag]=exported_job&labels[][labelid]=cpu&labels[][labeltag]=core"

The -g flag avoids curl to interpret the string and give an error for the [{}].

jbonnet commented 7 years ago

I noticed that the labels array is not being correctly translated internaly... therefore the result is []

jbonnet commented 7 years ago

Hi, @pkarkazis, here's the example:

$ curl -g "http://sp.int3.sonata-nfv.eu:32001/api/v2/kpis/collected?end=2017-09-27T13%3A10%3A34.000Z&start=2017-09-26T13%3A14%3A34.000Z&name=vm_cpu_perc&step=10s&labels[][labelid]=vnf&labels[][labeltag]=exported_job&labels[][labelid]=cpu&labels[][labeltag]=core"
[{"metric":{"exported_instance":"TEST-VNF:a44a4d56-9bf4-4e15-aef4-0e5a52d0aec2","core":"cpu","group":"development","exported_job":"vnf","instance":"pushgateway:9091","job":"sonata","__name__":"vm_cpu_perc","id":"a44a4d56-9bf4-4e15-aef4-0e5a52d0aec2"},"values":[[1506504134,"6.63"],[1506504144,"24.1"],[1506504154,"24.1"],[1506504164,"42.21"],[1506504174,"25.51"],[1506504184,"25.51"],[1506504194,"12.56"],[1506504204,"23.86"],[1506504214,"23.86"],[1506504224,"5.61"],[1506504234,"46.23"],[1506504244,"46.23"],[1506504254,"10.1"],[1506504264,"21.76"],[1506504274,"21.76"],[1506504284,"10.31"],[1506504294,"20.81"],[1506504304,"20.81"],[1506504314,"8.59"],[1506504324,"24.37"],[1506504334,"24.37"],[1506504344,"13.07"],[1506504354,"9.64"],[1506504364,"9.64"],[1506504374,"20.73"],[1506504384,"9.45"],[1506504394,"9.45"],[1506504404,"20.83"],[1506504414,"7.25"],[1506504424,"7.25"],[1506504434,"54.23"],[1506504444,"37.24"],[1506504454,"37.24"],[1506504464,"26.6"],[1506504474,"17.68"],[1506504484,"17.68"],[1506504494,"22.4"],[1506504504,"22.4"],[1506504514,"9.18"],[1506504524,"21.13"],[1506504534,"21.13"],[1506504544,"8"],[1506504554,"11.56"],[1506504564,"17.17"],[1506504574,"17.17"],[1506504584,"9.09"],[1506504594,"12.12"],[1506504604,"12.12"],[1506504614,"6.6"],[1506504624,"78.79"],[1506504634,"78.79"],[1506504644,"62.76"],[1506504654,"17.68"],[1506504664,"17.68"],[1506504674,"71.64"],[1506504684,"61.42"],[1506504694,"61.42"],[1506504704,"58.08"],[1506504714,"60.71"],[1506504724,"60.71"],[1506504734,"56.28"],[1506504744,"61.62"],[1506504754,"61.62"],[1506504764,"54.73"],[1506504774,"54.08"],[1506504784,"54.08"],[1506504794,"57.79"],[1506504804,"56.06"],[1506504814,"56.06"],[1506504824,"56"],[1506504834,"56"],[1506504844,"68.34"],[1506504854,"57.29"],[1506504864,"57.29"],[1506504874,"69.04"],[1506504884,"57.21"],[1506504894,"57.21"],[1506504904,"70.71"],[1506504914,"59.79"],[1506504924,"59.79"],[1506504934,"92.08"],[1506504944,"59.9"],[1506504954,"96.97"],[1506504964,"96.97"],[1506504974,"60"],[1506504984,"55.61"],[1506504994,"55.61"],[1506505004,"68.53"],[1506505014,"58.16"],[1506505024,"58.16"],[1506505034,"65.66"],[1506505044,"66.5"],[1506505054,"66.5"],[1506505064,"63.59"],[1506505074,"66.67"],[1506505084,"66.67"],[1506505094,"64.8"],[1506505104,"64.8"],[1506505114,"37.19"],[1506505124,"32.99"],[1506505134,"17.77"],[1506505144,"17.77"],[1506505154,"17.77"],[1506505164,"17.77"],[1506505174,"17.77"],[1506505184,"17.77"],[1506505194,"17.77"],[1506505204,"17.77"],[1506505214,"17.77"],[1506505224,"17.77"],[1506505234,"17.77"],[1506505244,"17.77"],[1506505254,"17.77"],[1506505264,"17.77"],[1506505274,"17.77"],[1506505284,"17.77"],[1506505294,"17.77"],[1506505304,"17.77"],[1506505314,"17.77"],[1506505324,"17.77"],[1506505334,"17.77"],[1506505344,"17.77"],[1506505354,"17.77"],[1506505364,"17.77"],[1506505374,"17.77"],[1506505384,"17.77"],[1506505394,"17.77"],[1506505404,"17.77"],[1506505414,"17.77"],[1506505424,"17.77"]]},{"metric":{"exported_instance":"vtc-nfv-1:fc7fab95-4b7a-4771-b760-f62ec6e5cf09","core":"cpu","group":"development","exported_job":"vnf","instance":"pushgateway:9091","job":"sonata","__name__":"vm_cpu_perc","id":"fc7fab95-4b7a-4771-b760-f62ec6e5cf09"},"values":[[1506504134,"0"],[1506504144,"0.5"],[1506504154,"0.5"],[1506504164,"0"],[1506504174,"0.5"],[1506504184,"0.5"],[1506504194,"0"],[1506504204,"0"],[1506504214,"0.5"],[1506504224,"0"],[1506504234,"0"],[1506504244,"0"],[1506504254,"0"],[1506504264,"1"],[1506504274,"1"],[1506504284,"1"],[1506504294,"0"],[1506504304,"0"],[1506504314,"0.5"],[1506504324,"0"],[1506504334,"0"],[1506504344,"0"],[1506504354,"0"],[1506504364,"0"],[1506504374,"0"],[1506504384,"1"],[1506504394,"1"],[1506504404,"0"],[1506504414,"0.5"],[1506504424,"0.5"],[1506504434,"0"],[1506504444,"0.5"],[1506504454,"0.5"],[1506504464,"0.5"],[1506504474,"0"],[1506504484,"0"],[1506504494,"0"],[1506504504,"1.49"],[1506504514,"1.49"],[1506504524,"0"],[1506504534,"0"],[1506504544,"1"],[1506504554,"0.5"],[1506504564,"0"],[1506504574,"0"],[1506504584,"0.5"],[1506504594,"2.01"],[1506504604,"2.01"],[1506504614,"0"],[1506504624,"1"],[1506504634,"1"],[1506504644,"0"],[1506504654,"0.5"],[1506504664,"0.5"],[1506504674,"0"],[1506504684,"0"],[1506504694,"0"],[1506504704,"1"],[1506504714,"0.5"],[1506504724,"0.5"],[1506504734,"0"],[1506504744,"0.5"],[1506504754,"0.5"],[1506504764,"0.5"],[1506504774,"1"],[1506504784,"1"],[1506504794,"0.5"],[1506504804,"0.5"],[1506504814,"0.5"],[1506504824,"0"],[1506504834,"0.5"],[1506504844,"0.5"],[1506504854,"0"],[1506504864,"0.5"],[1506504874,"0.5"],[1506504884,"0"],[1506504894,"0"],[1506504904,"0"],[1506504914,"0"],[1506504924,"0"],[1506504934,"0"],[1506504944,"0.99"],[1506504954,"0.5"],[1506504964,"0.5"],[1506504974,"0"],[1506504984,"0.5"],[1506504994,"0.5"],[1506505004,"0"],[1506505014,"0.5"],[1506505024,"0.5"],[1506505034,"0"],[1506505044,"0.5"],[1506505054,"0.5"],[1506505064,"0.5"],[1506505074,"0.5"],[1506505084,"0.5"],[1506505094,"0.5"],[1506505104,"0.5"],[1506505114,"0.5"],[1506505124,"0"],[1506505134,"0.5"],[1506505144,"0.5"],[1506505154,"0.5"],[1506505164,"0.5"],[1506505174,"0.5"],[1506505184,"0.5"],[1506505194,"0.5"],[1506505204,"0.5"],[1506505214,"0.5"],[1506505224,"0.5"],[1506505234,"0.5"],[1506505244,"0.5"],[1506505254,"0.5"],[1506505264,"0.5"],[1506505274,"0.5"],[1506505284,"0.5"],[1506505294,"0.5"],[1506505304,"0.5"],[1506505314,"0.5"],[1506505324,"0.5"],[1506505334,"0.5"],[1506505344,"0.5"],[1506505354,"0.5"],[1506505364,"0.5"],[1506505374,"0.5"],[1506505384,"0.5"],[1506505394,"0.5"],[1506505404,"0.5"],[1506505414,"0.5"],[1506505424,"0.5"]]},{"metric":{"exported_instance":"vtu-vnf:0e96e954-93d8-4605-a0d5-4a090b26b10e","core":"cpu","group":"development","exported_job":"vnf","instance":"pushgateway:9091","job":"sonata","__name__":"vm_cpu_perc","id":"0e96e954-93d8-4605-a0d5-4a090b26b10e"},"values":[[1506504134,"0"],[1506504144,"0"],[1506504154,"0.5"],[1506504164,"1"],[1506504174,"0.5"],[1506504184,"0.5"],[1506504194,"0"],[1506504204,"0.5"],[1506504214,"0.5"],[1506504224,"0"],[1506504234,"0.5"],[1506504244,"0.5"],[1506504254,"0.5"],[1506504264,"0.5"],[1506504274,"0.5"],[1506504284,"0"],[1506504294,"0"],[1506504304,"0"],[1506504314,"2.01"],[1506504324,"0"],[1506504334,"0"],[1506504344,"0"],[1506504354,"0"],[1506504364,"0"],[1506504374,"0"],[1506504384,"0"],[1506504394,"0"],[1506504404,"0"],[1506504414,"0.5"],[1506504424,"0.5"],[1506504434,"0.5"],[1506504444,"0.5"],[1506504454,"0.5"],[1506504464,"0.5"],[1506504474,"0.5"],[1506504484,"0.5"],[1506504494,"0"],[1506504504,"0"],[1506504514,"0"],[1506504524,"1.98"],[1506504534,"0"],[1506504544,"0"],[1506504554,"0.5"],[1506504564,"0.5"],[1506504574,"0"],[1506504584,"0.5"],[1506504594,"0.5"],[1506504604,"0.5"],[1506504614,"0"],[1506504624,"0"],[1506504634,"0"],[1506504644,"0.5"],[1506504654,"0.5"],[1506504664,"0"],[1506504674,"1.01"],[1506504684,"0"],[1506504694,"0"],[1506504704,"0"],[1506504714,"0.5"],[1506504724,"0.5"],[1506504734,"0.5"],[1506504744,"0"],[1506504754,"0"],[1506504764,"0"],[1506504774,"0"],[1506504784,"0"],[1506504794,"1.51"],[1506504804,"0"],[1506504814,"0"],[1506504824,"0.5"],[1506504834,"1"],[1506504844,"1"],[1506504854,"0.5"],[1506504864,"0"],[1506504874,"0"],[1506504884,"0"],[1506504894,"0"],[1506504904,"0"],[1506504914,"0.5"],[1506504924,"0.5"],[1506504934,"0"],[1506504944,"0"],[1506504954,"0"],[1506504964,"0"],[1506504974,"0"],[1506504984,"0.5"],[1506504994,"0.5"],[1506505004,"0"],[1506505014,"0"],[1506505024,"0"],[1506505034,"0"],[1506505044,"0.5"],[1506505054,"0.5"],[1506505064,"0"],[1506505074,"0"],[1506505084,"0"],[1506505094,"0"],[1506505104,"0"],[1506505114,"0"],[1506505124,"0"],[1506505134,"0"],[1506505144,"0"],[1506505154,"0"],[1506505164,"0"],[1506505174,"0"],[1506505184,"0"],[1506505194,"0"],[1506505204,"0"],[1506505214,"0"],[1506505224,"0"],[1506505234,"0"],[1506505244,"0"],[1506505254,"0"],[1506505264,"0"],[1506505274,"0"],[1506505284,"0"],[1506505294,"0"],[1506505304,"0"],[1506505314,"0"],[1506505324,"0"],[1506505334,"0"],[1506505344,"0"],[1506505354,"0"],[1506505364,"0"],[1506505374,"0"],[1506505384,"0"],[1506505394,"0"],[1506505404,"0"],[1506505414,"0"],[1506505424,"0"]]}]
pkarkazis commented 7 years ago

Hi, @jbonnet the api call on 'https://sp.int3.sonata-nfv.eu/api/v2/functions/metrics/names' returns: {"error": {"code": 404, "message": "/api/v2/functions/metrics/names not supported"}} could you please check it?

jbonnet commented 7 years ago

Hi, @pkarkazis Can you please retry? I just did:

$ http --follow sp.int3.sonata-nfv.eu/api/v2/functions/metrics/names authorization:"bearer $ACCESS_TOKEN"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1921
Content-Type: application/json
Date: Wed, 27 Sep 2017 10:32:18 GMT
Server: nginx/1.13.3
X-Content-Type-Options: nosniff

{
    "metric_names": [
        "ALERTS", 
        "cnt_block_in_MB", 
        "cnt_block_ou_MB", 
        "cnt_cpu_perc", 
        "cnt_created", 
        "cnt_mem_limit_MB", 
        "cnt_mem_perc", 
        "cnt_mem_usage_MB", 
        "cnt_net_rx_MB", 
        "cnt_net_tx_MB", 
        "cnt_status", 
        "functions_metrics_queries", 
        "go_gc_duration_seconds", 
        "go_gc_duration_seconds_count", 
        "go_gc_duration_seconds_sum", 
        "go_goroutines", 
        "http_request_duration_microseconds", 
        "http_request_duration_microseconds_count", 
        "http_request_duration_microseconds_sum", 
        "http_request_size_bytes", 
        "http_request_size_bytes_count", 
        "http_request_size_bytes_sum", 
        "http_requests_total", 
        "http_response_size_bytes", 
        "http_response_size_bytes_count", 
        "http_response_size_bytes_sum", 
        "mbits_packets_all", 
        "mbits_packets_apple", 
        "mbits_packets_bittorrent", 
        "mbits_packets_dns", 
        "mbits_packets_dropbox", 
        "mbits_packets_google", 
        "mbits_packets_http", 
        "mbits_packets_icloud", 
        "mbits_packets_skype", 
        "mbits_packets_twitter", 
        "mbits_packets_viber", 
        "mbits_packets_youtube", 
        "package_on_boardings", 
        "process_cpu_seconds_total", 
        "process_max_fds", 
        "process_open_fds", 
        "process_resident_memory_bytes", 
        "process_start_time_seconds", 
        "process_virtual_memory_bytes", 
        "scrape_duration_seconds", 
        "up", 
        "user_registrations", 
        "vim_maxImageMeta", 
        "vim_maxPersonality", 
        "vim_maxPersonalitySize", 
        "vim_maxSecurityGroupRules", 
        "vim_maxSecurityGroups", 
        "vim_maxServerGroupMembers", 
        "vim_maxServerGroups", 
        "vim_maxServerMeta", 
        "vim_maxTotalCores", 
        "vim_maxTotalFloatingIps", 
        "vim_maxTotalInstances", 
        "vim_maxTotalKeypairs", 
        "vim_maxTotalRAMSize", 
        "vim_totalCoresUsed", 
        "vim_totalFloatingIpsUsed", 
        "vim_totalInstancesUsed", 
        "vim_totalRAMUsed", 
        "vim_totalSecurityGroupsUsed", 
        "vim_totalServerGroupsUsed", 
        "vm_cpu_perc", 
        "vm_cpu_perc_test", 
        "vm_disk_total_1k_blocks", 
        "vm_disk_usage_perc", 
        "vm_disk_used_1k_blocks", 
        "vm_last_update", 
        "vm_mem_free_MB", 
        "vm_mem_perc", 
        "vm_mem_total_MB", 
        "vm_net_rx_MB", 
        "vm_net_rx_bps", 
        "vm_net_rx_pps", 
        "vm_net_tx_MB", 
        "vm_net_tx_bps", 
        "vm_net_tx_pps", 
        "vm_power_state", 
        "vm_status", 
        "vm_up", 
        "vms_state", 
        "vms_sum"
    ]
}