5. Piwik Tracker Piwik
host IP user agent referer
Piwik Tracker
idsite Piwik Web
action name Web
id ID
res PC
pdf Web pdf ?
java java ?
fla flash ?
cookie cookie ?
viewts
Supported Query Parameters1
1
http://developer.piwik.org/api-reference/tracking-api
5 of 46
30. td-agent ∼ Piwik 2
Piwik
Piwik
tag piwiktracker.apache.access
source
type tail
format apache
time_format %d/%b/%Y:%H:%M:%S %z
pos_file /var/log/td-agent/access_log.pos
path /var/log/httpd/access_log
tag piwiktracker.apache.access
/source
28 of 46
31. td-agent ∼ Piwik 3
Piwik
host
match piwiktracker.apache.access
type forward
send_timeout 60s
recover_wait 300s
heartbeat_interval 1s
phi_threshold 16
hard_timeout 60s
server
name fruentd
host your_elsticsearch_server i.e. 10.x.x.x
port 24224
weight 100
/server
/match
29 of 46
32. td-agent ∼ Piwik 4
elasticsearch
Tracker
1. Piwik
2. Piwik API
3. filter match piwiktracker.apache.access
filter piwiktracker.apache.access
type grep
regexp1 path /piwik.php?action name=.*idsite=d+
/filter
match piwiktracker.apache.access
type record_reformer
tag piwiktracker.apache.access.urldecode
30 of 46
33. td-agent ∼ Piwik 5
elasticsearch
fluentd
“Supported Query Parameters11
”
“ ” “id”
piwiktracker.apache.access.urldecode
match piwiktracker.apache.access
type record_reformer
tag piwiktracker.apache.access.urldecode
29 3
idsite ${path[/piwik.php?
action name=.*idsite=(d+)/,1]} ID
piwikid ${path[/piwik.php?action name=
.* id=([a-zd]+)/,1]} ID
fla ${path[/piwik.php?action name= flash ?
.*fla=(d+)/,1] == 1 ? true : false }
/match
11
http://developer.piwik.org/api-reference/tracking-api
31 of 46
34. td-agent ∼ Piwik 6
elasticsearch
fluentd url encode
piwiktracker.apache.access.store
match piwiktracker.apache.access.urldecode
type uri_decode
tag piwiktracker.apache.access.store
key_names action_name,ref,url,urlref
/match
32 of 46
35. td-agent ∼ Piwik 7:
elasticsearch
store elasticsearch
match piwiktracker.apache.access.store
type copy
store
type elasticsearch
type_name access_log
host 127.0.0.1
port 9200
logstash_format true
logstash_prefix apache-log
logstash_dateformat %Y%m%d
include_tag_key true
tag_key @log_name
flush_interval 10s
/store
/match
33 of 46
37. td-agent ∼ Piwik 2:
Piwik elasticsearch
“ ”
“ ” Piwik forward
source
tag piwiktracker.apache.access
/source
match piwiktracker.apache.access
tag piwiktracker.apache.access.urldecode
/match
match piwiktracker.apache.access.urldecode
tag piwiktracker.apache.access.store
/match
match piwiktracker.apache.access.store
/match
35 of 46