Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add google_analytics collector. #1422

Merged
merged 2 commits into from
Oct 27, 2015
Merged

Add google_analytics collector. #1422

merged 2 commits into from
Oct 27, 2015

Conversation

alienth
Copy link
Contributor

@alienth alienth commented Oct 27, 2015

Config looks like the following:

[[GoogleAnalytics]]
  ClientID = "blahblahblah.apps.googleusercontent.com"
  Secret = "foo"
  Token = '''
aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g
'''

  [[GoogleAnalytics.Sites]]
    Name = "stackoverflow.com"
    Profile = "123456a"

  [[GoogleAnalytics.Sites]]
    Name = "stackoverflow-mobile"
    Profile = "2456245"
    Offset = 8

The Token is a long-lived cached oauth token. The string itself is a base64'd gob. Generating it is done by hand at the moment. I'll investigate writing a util to do this so outszzziders can use it.

Profile is a magic GA identifier. Offset is what timeslice of the real-time data we want to grab. Mobile real-time data doesn't fully converge until about 5-6 minutes, so we only want to grab the minute slice from 8 minutes ago. If Offset isn't specified or set to 0, it is set to 1 (the minimum offset which makes sense, given the nature of the data).

Note that this has been running on my VM for several months, although the code was broken in a few places. This is the cleaned up version, finally.

👓 @gbrayut @captncraig

// the row we care about is minute '0' - or the most recently
// gathered datapoint.
for _, v := range data.Rows {
minute, err := strconv.Atoi(v[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the type of v? magic number indexing is a bit scary. Even a comment documenting the expected layout would help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v is a 'row' containing two numbers. Will add a comment.

@alienth
Copy link
Contributor Author

alienth commented Oct 27, 2015

@captncraig Added fixup commits.

@alienth alienth merged commit 2f392e5 into bosun-monitor:master Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants