`histogram(date_expression,date_interval)`
TIMESTAMP
format. You can use the cast function to convert a time string in the ISO 8601 or UNIX datetime format to TIMESTAMP
.date_interval | Sample Value |
MINUTE | histogram( cast(__TIMESTAMP__ as timestamp),INTERVAL 1 MINUTE) |
HOUR | histogram( cast(__TIMESTAMP__ as timestamp),INTERVAL 1 HOUR) |
DAY | histogram( cast(__TIMESTAMP__ as timestamp),INTERVAL 1 DAY) |
MONTH | histogram( cast(__TIMESTAMP__ as timestamp),INTERVAL 1 MONTH) |
YEAR | histogram( cast(__TIMESTAMP__ as timestamp),INTERVAL 1 YEAR) |
* | select histogram( cast(__TIMESTAMP__ as timestamp),INTERVAL 5 MINUTE) AS dt, count(*) as PV group by dt order by dt
* | select cast((__TIMESTAMP__-__TIMESTAMP__%60000) as timestamp) as dt, count(1) as PV,count (distinct(remote_addr)) as UV group by dt order by dt
%60000
in the above formula refers to the aggregation by 60 seconds.
Was this page helpful?