Akumuli
Akumuli copied to clipboard
new metric
hi. i have the following requirement.. i have a metric that has a currency value (always euros) and i also have a daily currency value from euros to other currencies.. is possible to make a query where i define the currency that i want and return the value in that currency, therefore making/returning a new metric? from what i saw in the docs i would need to do a group-aggregate query by hour or day, and afterward apply the currency conversion.
Not sure if I understand correctly, please correct me if I'm wrong. You have a time-series which you need to multiply by another time-series (exchange rate)? It could be done simply by fetching data first and then multiplying it by the exchange rate for the corresponding day. 'Group-aggregate' will combine all values for the period and produce single value per hour/day and 'select' will fetch everything as is.
you are correct in your assumption.. i want to multiply the time serie value by some value that have a time correlation.. it could be passed as argument or it could be another time serie.. i would that all the values in a day to be multiply by the exchange rate of that day.. using select would be bad because i would get all the values that can be of great magnitude.. millions.. i will go by the aggregate method, by hour or day and then after getting the aggregates values multiply it by the exchange rate.. however if i go for the implementation to support this where it would be a good spot for adding such operation? i like the project very much.. waiting for replication... thanks.
This is easy to do then. There is an 'apply' query field (not documented yet). It can be used to transform the output series. The query will look like this:
{
"group-aggregate": {
"metric": "cpu.user",
"step" : "1h",
"func" : "max"
},
"range": {
"from" : "20190507T000000",
"to" : "20190508T000000"
},
"apply": [{ "name": "scale", "weights": [0.01]}]
}
This will fetch all series with 'cpu.user' metric name. 'group-aggregate' field control the aggregation process. Each series will have 24 values with 1h step. Each value will contain max value for that hour. 'apply' field have only one operation that will multiply every value by 0.01.
If you want to contribute there are many possibilities. If you interested in replication and HA you can help to add it. Or you can add new operations for 'apply' query field (you can take a look at libakumuli/query_processing/scale.h|cpp to see how it works). I'm planning to integrate Lua-interpreter here.