)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":28748,"name":"chenker","email":"chen.ke14@zte.com.cn","username":"chenke"},"change_message_id":"246f4f54fa794cab2dada97bdb2185555217db5d","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":2,"id":"abaa8af1_52c02bc7","updated":"2023-10-24 10:39:15.000000000","message":"recheck","commit_id":"a6b7232f9be77e045ecbfbaf50c18b450f224af7"},{"author":{"_account_id":28748,"name":"chenker","email":"chen.ke14@zte.com.cn","username":"chenke"},"change_message_id":"91bfea2630bf0927fee273023b85bf599d8d9507","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"14b65fdc_fd4ac85d","updated":"2023-10-25 09:08:52.000000000","message":"Sorry, I don\u0027t understand the logic of cpu_util conversion. Please give me an example to show that the current conversion is OK. Thank you.","commit_id":"00fea975e2b9c8f225645fbc255a6e5af478e496"},{"author":{"_account_id":8543,"name":"Lucian Petrut","email":"lpetrut@cloudbasesolutions.com","username":"plucian"},"change_message_id":"f8074aac78ab5990a0ec060122fb984415c9aeb4","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"c618eed2_d6ef765c","updated":"2023-10-25 09:44:27.000000000","message":"Sure, so the idea is that \"cpu_util\" was providing the cpu usage percentage, while \"cpu\" gives us the cumulative cpu time in nanoseconds.\n\n```\n$ gnocchi measure show \\\n    b8259b3b-9cfe-499a-a1d5-07bf6a68eef0 \\\n    --start 2023-10-25T09:00:00+00:00\n+---------------------------+-------------+------------------+\n| timestamp                 | granularity |            value |\n+---------------------------+-------------+------------------+\n| 2023-10-25T09:00:00+00:00 |       300.0 | 33771620000000.0 |\n| 2023-10-25T09:05:00+00:00 |       300.0 | 33772500000000.0 |\n| 2023-10-25T09:10:00+00:00 |       300.0 | 33773360000000.0 |\n| 2023-10-25T09:15:00+00:00 |       300.0 | 33774240000000.0 |\n+---------------------------+-------------+------------------+\n```\n\nThe cumulative cpu time isn\u0027t very useful for us, so we\u0027ll use the \"rate:mean\" aggregation to obtain the rate of change, which tells us how much cpu time the VM consumed in a given interval, specifically the \"granularity\" interval.\n\n```\n$ gnocchi measure show \\\n    b8259b3b-9cfe-499a-a1d5-07bf6a68eef0 \\\n    --start 2023-10-25T09:00:00+00:00 \\\n    --aggregation \"rate:mean\"\n+---------------------------+-------------+-------------+\n| timestamp                 | granularity |       value |\n+---------------------------+-------------+-------------+\n| 2023-10-25T09:00:00+00:00 |       300.0 | 890000000.0 |\n| 2023-10-25T09:05:00+00:00 |       300.0 | 880000000.0 |\n| 2023-10-25T09:10:00+00:00 |       300.0 | 860000000.0 |\n| 2023-10-25T09:15:00+00:00 |       300.0 | 880000000.0 |\n+---------------------------+-------------+-------------+\n```\n\nRemember that those are nanoseconds, so let\u0027s convert this value to seconds. We get 880000000.0 / 10e+8, which is 0.88s. So basically in a 300s interval, our vm only had 0.88s cpu time. We can convert it to a percentage, doing 0.88 * 100 / 300, so our vm had 0.293 % cpu usage. But we also need to take into account the vm had 2 vcpus, so we\u0027ll divide that value by two and obtain 0.146%.\n\nSo basically we had:\n\n```\nrate \u003d 880000000.0\ngranularity \u003d 300\nvcpus \u003d 2\ncpu_percentage \u003d rate * 100 / (granularity * 10e+8) / vcpus\nprint(cpu_percentage)\n0.14666666666666667\n```\n\nOk, let\u0027s generate some cpu load by using ``stress --cpu 2``.\n\nWe now get:\n\n```\n$ gnocchi measure show \\\n    b8259b3b-9cfe-499a-a1d5-07bf6a68eef0 \\\n    --start 2023-10-25T09:00:00+00:00\n+---------------------------+-------------+------------------+\n| timestamp                 | granularity |            value |\n+---------------------------+-------------+------------------+\n| 2023-10-25T09:00:00+00:00 |       300.0 | 33771620000000.0 |\n| 2023-10-25T09:05:00+00:00 |       300.0 | 33772500000000.0 |\n| 2023-10-25T09:10:00+00:00 |       300.0 | 33773360000000.0 |\n| 2023-10-25T09:15:00+00:00 |       300.0 | 33774240000000.0 |\n| 2023-10-25T09:20:00+00:00 |       300.0 | 33775190000000.0 |\n| 2023-10-25T09:25:00+00:00 |       300.0 | 33776060000000.0 |\n| 2023-10-25T09:30:00+00:00 |       300.0 | 33922150000000.0 |\n| 2023-10-25T09:35:00+00:00 |       300.0 | 34522100000000.0 |\n+---------------------------+-------------+------------------+\n\n$ gnocchi measure show \\\n    b8259b3b-9cfe-499a-a1d5-07bf6a68eef0 \\\n    --start 2023-10-25T09:00:00+00:00 \\\n    --aggregation \"rate:mean\"\n+---------------------------+-------------+----------------+\n| timestamp                 | granularity |          value |\n+---------------------------+-------------+----------------+\n| 2023-10-25T09:00:00+00:00 |       300.0 |    890000000.0 |\n| 2023-10-25T09:05:00+00:00 |       300.0 |    880000000.0 |\n| 2023-10-25T09:10:00+00:00 |       300.0 |    860000000.0 |\n| 2023-10-25T09:15:00+00:00 |       300.0 |    880000000.0 |\n| 2023-10-25T09:20:00+00:00 |       300.0 |    950000000.0 |\n| 2023-10-25T09:25:00+00:00 |       300.0 |    870000000.0 |\n| 2023-10-25T09:30:00+00:00 |       300.0 | 146090000000.0 |\n| 2023-10-25T09:35:00+00:00 |       300.0 | 599950000000.0 |\n+---------------------------+-------------+----------------+\n```\n\nLet\u0027s convert it to a percentage:\n\n```\nrate \u003d 599950000000.0\ngranularity \u003d 300\nvcpus \u003d 2\ncpu_percentage \u003d rate * 100 / (granularity * 10e+8) / vcpus\nprint(cpu_percentage)\n99.99166666666666\n```","commit_id":"00fea975e2b9c8f225645fbc255a6e5af478e496"},{"author":{"_account_id":8543,"name":"Lucian Petrut","email":"lpetrut@cloudbasesolutions.com","username":"plucian"},"change_message_id":"1adac391491ad2320f174afe137ae443bdba5b7c","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"f76a0fad_37d39786","in_reply_to":"211cee3e_878ad399","updated":"2023-10-26 13:19:25.000000000","message":"The Ceilometer pollster reports the cumulative cpu time through the \"cpu\" metric: https://docs.openstack.org/ceilometer/latest/admin/telemetry-measurements.html#openstack-compute.\n\nHowever, Gnocchi doesn\u0027t store data points but aggregates: https://gnocchi.osci.io/rest.html#archive-policy. It aggregates the received metrics based on the configured aggregation method (usually mean) and granularity. \n\nFor example, let\u0027s say there\u0027s an archive policy that has a 5 minute granularity. If it receives multiple measurements in a 5 minute interval, it\u0027s going to merge those values by performing a mean.\n\nSo this is basically the mean aggregate (means of cumulative cpu times):\n\n```\n$ gnocchi measure show \\\n    b8259b3b-9cfe-499a-a1d5-07bf6a68eef0 \\\n    --start 2023-10-25T09:00:00+00:00 \\\n    --aggregation mean\n+---------------------------+-------------+------------------+\n| timestamp                 | granularity |            value |\n+---------------------------+-------------+------------------+\n| 2023-10-25T09:00:00+00:00 |       300.0 | 33771620000000.0 |\n| 2023-10-25T09:05:00+00:00 |       300.0 | 33772500000000.0 |\n| 2023-10-25T09:10:00+00:00 |       300.0 | 33773360000000.0 |\n| 2023-10-25T09:15:00+00:00 |       300.0 | 33774240000000.0 |\n| 2023-10-25T09:20:00+00:00 |       300.0 | 33775190000000.0 |\n| 2023-10-25T09:25:00+00:00 |       300.0 | 33776060000000.0 |\n| 2023-10-25T09:30:00+00:00 |       300.0 | 33922150000000.0 |\n| 2023-10-25T09:35:00+00:00 |       300.0 | 34522100000000.0 |\n+---------------------------+-------------+------------------+\n```\n\nTo obtain the rate of change, we need to request \"rate:mean\":\n\n```\n$ gnocchi measure show \\\n    b8259b3b-9cfe-499a-a1d5-07bf6a68eef0 \\\n    --start 2023-10-25T09:00:00+00:00 \\\n    --aggregation \"rate:mean\"\n+---------------------------+-------------+----------------+\n| timestamp                 | granularity |          value |\n+---------------------------+-------------+----------------+\n| 2023-10-25T09:00:00+00:00 |       300.0 |    890000000.0 |\n| 2023-10-25T09:05:00+00:00 |       300.0 |    880000000.0 |\n| 2023-10-25T09:10:00+00:00 |       300.0 |    860000000.0 |\n| 2023-10-25T09:15:00+00:00 |       300.0 |    880000000.0 |\n| 2023-10-25T09:20:00+00:00 |       300.0 |    950000000.0 |\n| 2023-10-25T09:25:00+00:00 |       300.0 |    870000000.0 |\n| 2023-10-25T09:30:00+00:00 |       300.0 | 146090000000.0 |\n| 2023-10-25T09:35:00+00:00 |       300.0 | 599950000000.0 |\n+---------------------------+-------------+----------------+\n```\n\nWhen the aggregation granularity matches the ceilometer polling interval, it won\u0027t actually have to merge the measurements, we\u0027ll get the actual reported values. That\u0027s not really necessary though, aggregate values are ok as well.\n\nFurther info:\n* https://stfc-cloud-docs.readthedocs.io/en/latest/Aodh-and-Gnocchi/MonitoringVMsAodhGnocchi.html#cpu-utilization\n* https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/16.0/html-single/auto_scaling_for_instances/index#example_auto_scaling_based_on_cpu_use\n* https://github.com/gnocchixyz/gnocchi/issues/1044\n* https://lists.openstack.org/pipermail/openstack-discuss/2019-August/008171.html","commit_id":"00fea975e2b9c8f225645fbc255a6e5af478e496"},{"author":{"_account_id":28748,"name":"chenker","email":"chen.ke14@zte.com.cn","username":"chenke"},"change_message_id":"436c0523067c03587bb8fd79b0c4d928f43bc0a5","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"211cee3e_878ad399","in_reply_to":"c618eed2_d6ef765c","updated":"2023-10-26 08:37:10.000000000","message":"Thank you very much for your example. One thing I still have questions about is this sentence \"so we\u0027ll use the \"rate:mean\" aggregation to obtain the rate of change, which tells us how much cpu time the VM consumed in a given interval, specifically the \" granularity\" interval.\"\n\nIn my understanding, mean is the mean of this time period, not the total. But from your description and examples, it\u0027s closer to what you\u0027re saying is right, which I\u0027m confused about.\n\nAlso, what is the difference between mean and rate:mean? I see that you mentioned both in your code, but in the end, rate:mean was used by default.","commit_id":"00fea975e2b9c8f225645fbc255a6e5af478e496"},{"author":{"_account_id":28748,"name":"chenker","email":"chen.ke14@zte.com.cn","username":"chenke"},"change_message_id":"2f07e032bd5c6ceafccfc55b6196d42e7e8b864a","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":3,"id":"04173c35_b7c6463c","in_reply_to":"f76a0fad_37d39786","updated":"2023-10-27 08:51:18.000000000","message":"thanks, let\u0027s merge it first.","commit_id":"00fea975e2b9c8f225645fbc255a6e5af478e496"}],"watcher/decision_engine/datasources/gnocchi.py":[{"author":{"_account_id":28748,"name":"chenker","email":"chen.ke14@zte.com.cn","username":"chenke"},"change_message_id":"3e6f0f1430322f4e13ddef1945f9a51143f3d79a","unresolved":true,"context_lines":[{"line_number":109,"context_line":"                            aggregate)"},{"line_number":110,"context_line":"                return"},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"            # TODO: consider supporting other aggregates."},{"line_number":113,"context_line":"            aggregate \u003d \"rate:mean\""},{"line_number":114,"context_line":"            meter \u003d \"cpu\""},{"line_number":115,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"db45399d_681b4321","line":112,"range":{"start_line":112,"start_character":14,"end_line":112,"end_character":18},"updated":"2023-10-20 07:09:04.000000000","message":"TODO(your name)","commit_id":"c594fd31962a0d3b3e848193e83e40ac684ddb9a"}]}
