{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/7445","repository_url":"https://api.github.com/repos/influxdata/influxdb","labels_url":"https://api.github.com/repos/influxdata/influxdb/issues/7445/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/7445/comments","events_url":"https://api.github.com/repos/influxdata/influxdb/issues/7445/events","html_url":"https://github.com/influxdata/influxdb/issues/7445","id":182234020,"number":7445,"title":"Time weighted average/mean","user":{"login":"deandob","id":6071423,"avatar_url":"https://avatars.githubusercontent.com/u/6071423?v=3","gravatar_id":"","url":"https://api.github.com/users/deandob","html_url":"https://github.com/deandob","followers_url":"https://api.github.com/users/deandob/followers","following_url":"https://api.github.com/users/deandob/following{/other_user}","gists_url":"https://api.github.com/users/deandob/gists{/gist_id}","starred_url":"https://api.github.com/users/deandob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deandob/subscriptions","organizations_url":"https://api.github.com/users/deandob/orgs","repos_url":"https://api.github.com/users/deandob/repos","events_url":"https://api.github.com/users/deandob/events{/privacy}","received_events_url":"https://api.github.com/users/deandob/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/influxdata/influxdb/labels/area/functions","name":"area/functions","color":"fbca04"},{"url":"https://api.github.com/repos/influxdata/influxdb/labels/kind/feature%20request","name":"kind/feature request","color":"006b75"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-11T10:55:41Z","updated_at":"2016-10-12T20:58:37Z","closed_at":"2016-10-12T20:58:36Z","body":"Proposal:\r\nProvide an aggregate function that provides a time weighted mean. Similar to the interpolation function in OpenTSB [http://opentsdb.net/docs/build/html/user_guide/query/aggregators.html](url)\r\n\r\nI am new to influxdb and possibly I have not understood how this can be done, but from spending an hour researching this it looks like it is not natively possible in Influxdb and without the possibility of doing user defined functions this type of calculation has to be done in the host application, negating some of the benefits and performance of influxdb.\r\n\r\nUse Case:\r\nFor IoT there are a lot of sensor scenarios where data isn't sent on a regular time basis, mostly where the sensors are reacting to changes (which saves battery and network bandwidth compared to sending the same unchanging data value in regular intervals). For example, temperature measurements won't change while a freezer door is closed (which is most of the time) sending no data, but will send many data points when the door is opened for a short while (getting warmer) then closed (getting colder again). A conventional mean will not represent the average temperature in the freezer as most of the sensor data ingested is from the short time the door was open so needs to be weighted by the time interval between sensor readings.\r\n\r\nApologies if there is already a feature request for this but I couldn't find anything similar in the GH issues log. I like the philosophy behind influxdb and the active development - so hoping this is a feature that could be added. Also surprised that this isn't a more requested feature as it should be a common use case. I don't want to use Kapacitor as my servers are Windows not Linux.\r\n\r\nThanks for listening.\r\n"},"comment":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/comments/253337216","html_url":"https://github.com/influxdata/influxdb/issues/7445#issuecomment-253337216","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/7445","id":253337216,"user":{"login":"deandob","id":6071423,"avatar_url":"https://avatars.githubusercontent.com/u/6071423?v=3","gravatar_id":"","url":"https://api.github.com/users/deandob","html_url":"https://github.com/deandob","followers_url":"https://api.github.com/users/deandob/followers","following_url":"https://api.github.com/users/deandob/following{/other_user}","gists_url":"https://api.github.com/users/deandob/gists{/gist_id}","starred_url":"https://api.github.com/users/deandob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deandob/subscriptions","organizations_url":"https://api.github.com/users/deandob/orgs","repos_url":"https://api.github.com/users/deandob/repos","events_url":"https://api.github.com/users/deandob/events{/privacy}","received_events_url":"https://api.github.com/users/deandob/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T20:58:36Z","updated_at":"2016-10-12T20:58:36Z","body":"Hi,\r\n\r\nFill doesn't really help as it interpolates to produce a linear time series (values at regular time intervals based on interpolated values) from a delta time series which would give incorrect readings if the changes are step changes. See the examples below.\r\n\r\nSensors sends the following in response to an environment changes at 10:23 and 4 am:\r\n10:20am value = 3\r\n10:23am value = 10\r\n10:24am value = 8\r\nIf we were to get a time weighted average between 10:20am and 10:25am the calculation is:\r\n(3 x 3min + 10 x 1min + 8 * 1min)  /  5min =  5.4\r\n\r\nIf we were to use FILL then a mean we would get:\r\n10:20am value = 3\r\n10:21am value = 5.33 (interpolated)\r\n10:22am value = 7.66 (interpolated)\r\n10:23am value = 10\r\n10:24am value = 8\r\nMEAN would give you the value of (3 + 5.33 + 7.66 + 10 + 8) / 5 = 6.8. Quite different.\r\n\r\nWhy is this a common use case for IoT? Because having sensors send data at regular intervals wastes network bandwidth, battery life, CPU time and storage when most of the time we are only interested to capture the changes that the sensor is monitoring. Interpolation is useful when there is linear change and a sensor resolution is poor (ie. it can't capture smaller changes) or intermittent but where there is step change involved (eg. common when calculating safety exposure in an industrial situation) only a time weighted average will give the correct answer.\r\n\r\nIs this something that you would consider for a future release? The math isn't too hard but would require a new aggregate function to be added (I could help with a pull but I'm no Go expert.....)\r\n"}}
{"actor":{"display_login":"deandob"}}