In prometheus I can write it like this
rate(cpu.usage_user{}[1m])
But I don't know how to write it in CnosDB I would appreciate if you could provide an alternative function
Use function DATE_BIN
to create an interval and then you can group by that interval.
https://docs.cnosdb.com/en/latest/reference/sql.html#date-bin
SELECT DATE_BIN(INTERVAL '1 minute', time, TIMESTAMP '1970-01-01T00:00:00Z') AS t_1m, avg("usage_user")
FROM "cpu"
GROUP BY t_1m
ORDER BY t_1m ASC;
+---------------------+---------------------+
| t_1m | AVG(cpu.usage_user) |
+---------------------+---------------------+
| 2023-06-11T10:04:00 | 0.19059536973108368 |
| 2023-06-11T10:05:00 | 0.1374441062695361 |
| 2023-06-11T10:06:00 | 0.06667789198568308 |
| 2023-06-11T10:07:00 | 0.06461543031809086 |
| 2023-06-11T10:08:00 | 0.07290816106814985 |
| 2023-06-11T10:09:00 | 0.06876814392313359 |
| 2023-06-11T10:10:00 | 0.04584523881897398 |
| 2023-06-11T10:11:00 | 0.06458844691039858 |
| 2023-06-11T10:12:00 | 0.07501220786254227 |
| 2023-06-11T10:13:00 | 0.064619260802076 |
+---------------------+---------------------+