Weave statistic can be sent to a database for further analyses. The bundle can be downloaded from here (2017-02-15)
Configuration
<?xml version="1.0" encoding="UTF-8"?> <config xmlns="urn:com.cohga.server.config#1.0" xmlns:statistics="urn:com.cohga.server.statistics.db#1.0"> <statistics:config> <!-- datasource is required --> <!-- The name of the data source that the records will be written to --> <datasource>storage</datasource> <!-- table is optional and will default to wv_statistics --> <!-- This is the table where the records will be written --> <!-- Weave will attempt to create the table if it doesn't exist --> <table>wv_statistics</table> <!-- maximumDelayInSeconds is optional and will default to 60 seconds --> <!-- The maximum time to wait before writing any pending records --> <maximumDelayInSeconds>60</maximumDelayInSeconds> <!-- count is optional and will default to 30 --> <!-- The minimum number of records that need to be available before they are written --> <count>30</count> </statistics:config> </config>
Configuration for ikartan.se
The table is managed together with the ikartan admin database in schema 'weave'
create schema weave; -- Table: weave.wv_statistics -- DROP TABLE weave.wv_statistics; CREATE TABLE weave.wv_statistics ( id serial primary key, submitted timestamp without time zone NOT NULL, duration integer NOT NULL, userid character varying(50) NOT NULL, ip character varying(50) NOT NULL, request character varying(200) NOT NULL );
Configuration is located in config_ikartan/config_ikartan_common.xml
<?xml version="1.0" encoding="UTF-8"?> <config xmlns="urn:com.cohga.server.config#1.0" xmlns:statistics="urn:com.cohga.server.statistics.db#1.0"> .... <statistics:config> <!-- datasource is required --> <!-- The name of the data source that the records will be written to --> <datasource>ds.users</datasource> <!-- table is optional and will default to wv_statistics --> <!-- This is the table where the records will be written --> <!-- Weave will attempt to create the table if it doesn't exist --> <table>weave.wv_statistics</table> <!-- maximumDelayInSeconds is optional and will default to 60 seconds --> <!-- The maximum time to wait before writing any pending records --> <maximumDelayInSeconds>60</maximumDelayInSeconds> <!-- count is optional and will default to 30 --> <!-- The minimum number of records that need to be available before they are written --> <count>30</count> </statistics:config> ... </config>
Example of outputs
All
SELECT * FROM weave.wv_statistics;
Totals
SELECT sum((duration+500)/1000) as seconds, count(*) FROM weave.wv_statistics;
Totals this week
SELECT sum((duration+500)/1000) as seconds, count(*) FROM weave.wv_statistics
where submitted > date_trunc('week', current_date);
Totals per user
SELECT userid, sum((duration+500)/1000) as seconds, count(*) FROM weave.wv_statistics group by 1;
Statistics per weekday
SELECT
CASE date_part('isodow',submitted) WHEN 1 THEN 'Måndag' WHEN 2 THEN 'Tisdag' WHEN 3 THEN 'Onsdag' WHEN 4 THEN 'Torsdag' WHEN 5 THEN 'Fredag' WHEN 6 THEN 'Lördag' WHEN 7 THEN 'Söndag' END as weekday,
count(distinct userid) as users,
sum((duration+500)/1000) as seconds,
count(*) as requests
FROM weave.wv_statistics
group by date_part('isodow',submitted)::int, 1
order by date_part('isodow',submitted)::int;
Statistics per hour
SELECT
h.a as hour,
count(distinct userid) as users,
sum((duration+500)/1000) as seconds,
count(*)-1 as requests
FROM weave.wv_statistics
FULL JOIN (select unnest((array[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])) as a) h ON h.a = date_part('hour',submitted)
group by 1
order by 1