Public | Automated Build

Last pushed: 2 years ago
Short Description
This docker container collects google analytics data and ships it to graphite (carbon)
Full Description

Google Analytics to Graphite

Fetch Google Analytics metrics, and send them to a given Graphite host.

Setup Google Analytics authorizations

Make sure to enable the Analytics API via the GCloud interface.
Download your GCloud service account .p12 file and generate a .pem file:

openssl pkcs12 -in google-service-account.p12 -nocerts -passin pass:YOUR_PASSWORD -nodes -out google-service-account.pem

In Google Analytics, add a new user with read permission using the service account email address.

Run the container

# Retreive data from yesterday
docker run -t -i \
  -e "GA_EMAIL=my-name@my-project.iam.gserviceaccount.com" \
  -e "GA_MAX_RESULTS=1000" \
  -e "GA_METRICS=ga:pageviews,ga:sessions,ga:avgTimeOnSite" \
  -e "GA_MINUTES=false" \
  -e "GA_PEM_PATH=/home/root/google-service-account.pem" \
  -e "GA_VIEW_ID=123456" \
  -e "GRAPHITE_HOST=localhost" \
  -e "GRAPHITE_NAMESPACE=google-analytics" \
  -e "GRAPHITE_PORT=2003" \
  -v "$(pwd)/google-service-account.pem":/home/root/google-service-account.pem \
  analytics

# Retreive data from specific date
docker run -t -i \
  -e "GA_EMAIL=my-name@my-project.iam.gserviceaccount.com" \
  -e "GA_MAX_RESULTS=1000" \
  -e "GA_METRICS=ga:pageviews,ga:sessions,ga:avgTimeOnSite" \
  -e "GA_MINUTES=false" \
  -e "GA_PEM_PATH=/home/root/google-service-account.pem" \
  -e "GA_VIEW_ID=123456" \
  -e "GRAPHITE_HOST=localhost" \
  -e "GRAPHITE_NAMESPACE=google-analytics" \
  -e "GRAPHITE_PORT=2003" \
  -v "$(pwd)/google-service-account.pem":/home/root/google-service-account.pem \
  analytics \
  gatographite 2015-12-25
Docker Pull Command
Owner
travix