Git Product home page Git Product logo

googleanalytics_exporter's Introduction

Build Status Go Report Card Docker Repository on Quay

Google Real Time Analytics to Prometheus

Obtains Google Analytics RealTime metrics, and presents them to prometheus for scraping.


Quick start

  1. Ensure Glide is installed.
  2. Copy your Google creds json file to ./config/ga_creds.json. The email from the json must be added to the GA project permissions, more on that bellow.
  3. Create yaml configuration file (./config/config.yaml):.
    promport: 9100
    interval: 60
    viewid: ga:123456789
    metrics:
    - rt:pageviews
    - rt:activeUsers
  4. Install dependencies, compile and run.
    glide install
    go build ganalytics.go
    ./ganalytics

ViewID for the Google Analytics

From your Google Analytics Web UI: Admin (Low left) ==> View Settings (far right tab, named VIEW)'

View ID should be among Basic Settings. Prefix ga: must be added to the ID, e.g. ga:1234556 while adding it to the config.

Google creds

Google API manager allows to create OAuth 2.0 credentials for Google APIs. Use Service account key credentials type, upon creation a json creds file will be provided. Project RO permissions should be sufficient.

The email from GA API creds must be added to analytics project metrics will be obtained from.>

Cross compile on a MAC

  • Alpine docker image is used for delivery.
  • go should be installed with common compilers - brew install go --with-cc-common
  • creds.json and config.yaml expected to be in ./config/
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo ganalytics.go
docker build -t ganalytics .
docker run -it -p 9100:9100 -v $(pwd)/config:/ga/config ganalytics

Author

Pavel Snagovsky, [email protected]

License

Licensed under the terms of MIT license, see LICENSE file

googleanalytics_exporter's People

Contributors

paha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.