)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":34653,"name":"Danila Balagansky","email":"dbalagansky@me.com","username":"dbalagansky"},"change_message_id":"dcafdc7d656b4d7950ce74244b8c8a829be9dee9","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":2,"id":"b768d55a_790ecbd4","updated":"2022-08-24 07:28:53.000000000","message":"It seems, that with adding conditional on duration, there are far less cpu_util data points generated. Besides, I haven\u0027t been able to find the usage of duration in other inspectors. Is it really necessary?","commit_id":"0b7b7629e72f69d500b17c9305ee7cff6eb9bb71"},{"author":{"_account_id":4264,"name":"Matthias Runge","email":"mrunge@redhat.com","username":"mrunge"},"change_message_id":"435a836ae3db7d08bfb1e1582ddef8509145d708","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":2,"id":"a2f9b3e7_451c6784","in_reply_to":"108a3b9a_428fe2d0","updated":"2022-10-06 06:34:38.000000000","message":"I\u0027d think the path here to finally fix this is to use the following https://review.opendev.org/c/openstack/aodh/+/829870 which would then allow to get the utilitization calculated in gnocchi as proposed during the rocky development cycle.","commit_id":"0b7b7629e72f69d500b17c9305ee7cff6eb9bb71"},{"author":{"_account_id":34653,"name":"Danila Balagansky","email":"dbalagansky@me.com","username":"dbalagansky"},"change_message_id":"d44229fd9401f2f4f56f6ff0fe8af487b57266c8","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":2,"id":"108a3b9a_428fe2d0","in_reply_to":"a0143990_3fd8c13f","updated":"2022-09-01 17:01:17.000000000","message":"Just to be clear: I\u0027m not the reviewer, I\u0027ve just found this patch, while trying to solve similar need:\nI need to get CPU utilization as percent on a scale from 0 to 100 (independent of vCPU count) from Gnocchi and I\u0027ve found this change (thank you, btw!). \n\nI\u0027ve ended up fixing this a little bit (just removing `duration` at all, as, like I\u0027ve said earlier, I haven\u0027t found any other place in ceilometer where it is getting used (sometimes it gets accepted at some methods, but that\u0027s all) and with it, I\u0027ve got less data points). \n\nHere\u0027s my fix: https://paste.opendev.org/show/buKIdHuHGzSS0EKYcPXH/.\n\nI\u0027m retrieving this data directrly from Gnocchis\u0027 API with this query:\n\n`(/ (resample mean {period} (metric cpu_util rate:mean)) 300)`\n\nI don\u0027t know, if Aodh allows passing more advanced queries to Gnocchi, but this whole thing could\u0027ve been achieved without adding another metric with this query:\n\n`(/ (aggregate mean (/ (metric cpu rate:mean) (metric vcpus mean))) 60000000000))`\n\nBut, there is a missing bit for `fill` behaviour on Gnocchi side: https://github.com/gnocchixyz/gnocchi/issues/1266\n\nI needed to get the same percent utilization for memory, and for that, I\u0027ve found this abandoned patch: https://review.opendev.org/c/openstack/ceilometer/+/597054.","commit_id":"0b7b7629e72f69d500b17c9305ee7cff6eb9bb71"},{"author":{"_account_id":34653,"name":"Danila Balagansky","email":"dbalagansky@me.com","username":"dbalagansky"},"change_message_id":"50143232fb1cd038a9e77d7384832ae765833d68","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":2,"id":"bc0782fc_899d7213","in_reply_to":"a2f9b3e7_451c6784","updated":"2022-10-06 08:28:27.000000000","message":"Yes, calculating this in Gnocchi would be the best approach, but as of now it would result in significantly less data (only one point per hour (depends on `vcpus` metric discretization), as with this query you\u0027ll get points in the resulting set only on intersections of measures, see: https://github.com/gnocchixyz/gnocchi/issues/1266). \n\nSo this whole thing is more like a workaround for current Gnocchi\u0027s behaviour.","commit_id":"0b7b7629e72f69d500b17c9305ee7cff6eb9bb71"},{"author":{"_account_id":9542,"name":"Pavlo Shchelokovskyy","email":"pshchelokovskyy@mirantis.com","username":"pshchelo"},"change_message_id":"9ca5480805618d7db1a68a540f93464d5e662b8e","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":2,"id":"a0143990_3fd8c13f","in_reply_to":"b768d55a_790ecbd4","updated":"2022-09-01 08:49:56.000000000","message":"I\u0027ll look into why \u0027duration\u0027 is not always available..\n\nThe idea is to pre-calculate this metric as much as possible. It is (was) quite common to use cpu_util metric as driver for alarming (Aodh) and autoscaling (Heat), but users can not write complex aggregations in AODH alarm, only \u003cmetric\u003e or rate:\u003cmetric\u003e\n\nThe \u0027cpu\u0027 (ns) is the only metric that libvirt provides. To transform it to cpu utilization in % one has to have a diff between two consecutive \u0027cpu\u0027 metrics and divide by time between them (and some more):\n\n  100* (CPU_n - CPU_n-1) / ( (T_n - T_n-1) * 10**9 * Nvcpus )\n  \nThe plan was to split this into\n\n  CPU_n / (...) - CPU_n-1 / (...)\n  \nwhere each part we can calculate locally in compute agent (relying on duration being more or less constant), and the diff might be provided by rate:... aggregation in Gnocchi.\n\nIf that does not work, quite possibly we\u0027d need a local cache to store the previous value of \u0027cpu\u0027 metric and time it was collected at, so we can generate final cpu_util all by ourselves. This is essentially how virt-manager does this:\n\nhttps://github.com/virt-manager/virt-manager/blob/1d64a678d31829051444e1bf29d86f800e13de39/virtManager/lib/statsmanager.py#L178-L180","commit_id":"0b7b7629e72f69d500b17c9305ee7cff6eb9bb71"}],"ceilometer/compute/virt/libvirt/inspector.py":[{"author":{"_account_id":4264,"name":"Matthias Runge","email":"mrunge@redhat.com","username":"mrunge"},"change_message_id":"e118c393e3275dd8993cff52fe6e27afc1e84b7b","unresolved":true,"context_lines":[{"line_number":243,"context_line":""},{"line_number":244,"context_line":"        # NOTE(pas-ha) this is pre-calculated for actual cpu_util,"},{"line_number":245,"context_line":"        # must be consumed with gnocchi\u0027s rate:xxx aggregation"},{"line_number":246,"context_line":"        cpu_util \u003d ("},{"line_number":247,"context_line":"            cpu_time * 100.0 / (duration * 1000.0 * 1000.0 * 1000.0)"},{"line_number":248,"context_line":"        ) / stats.get(\u0027vcpu.current\u0027)"},{"line_number":249,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"7948a594_1b570ce5","line":246,"updated":"2021-07-15 08:10:53.000000000","message":"apparently needs:\nif duration:\n   cpu_util \u003d ......","commit_id":"61a53c0f27458924edbf535e8bc059d9cba74c34"},{"author":{"_account_id":9542,"name":"Pavlo Shchelokovskyy","email":"pshchelokovskyy@mirantis.com","username":"pshchelo"},"change_message_id":"a094d15621388ef0162cde545b685741c15bcadf","unresolved":false,"context_lines":[{"line_number":243,"context_line":""},{"line_number":244,"context_line":"        # NOTE(pas-ha) this is pre-calculated for actual cpu_util,"},{"line_number":245,"context_line":"        # must be consumed with gnocchi\u0027s rate:xxx aggregation"},{"line_number":246,"context_line":"        cpu_util \u003d ("},{"line_number":247,"context_line":"            cpu_time * 100.0 / (duration * 1000.0 * 1000.0 * 1000.0)"},{"line_number":248,"context_line":"        ) / stats.get(\u0027vcpu.current\u0027)"},{"line_number":249,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"bdd8499e_d2bdc6d6","line":246,"in_reply_to":"7948a594_1b570ce5","updated":"2022-08-15 16:51:26.000000000","message":"Done","commit_id":"61a53c0f27458924edbf535e8bc059d9cba74c34"}]}
