logstash-input-google-analytics-daily 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/logstash/inputs/google_analytics_daily.rb +42 -28
- data/logstash-input-google-analytics-daily.gemspec +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65e1356004d4e415992c64aa350b9e8f9a32b9cc2caa16ffe8a5cc008e443ce8
|
4
|
+
data.tar.gz: 7f4b32c19012b211a713fe35f0df59a0fad1661dcc90b1c68d8b0bd229afdcbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d79a8193223ef48ccd7c2666a7b23e8bb3237dc71b74e9f4fe5fbaab56a07f30ad3a7292ef82a4bc5cdc51faf20aa8525bb7d3a6ea84a39a4af1adcc9452cc9
|
7
|
+
data.tar.gz: e4bc122fceb88d8c852cc15043f6ca6bb709099a2b4dcc448749215348f668e37f93ace08d4fd42dee092b55dabb9f1f3794f77fe94fd68962e2ffd26239688b
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Forked from https://github.com/russorat/logstash-input-googleanalytics.git.
|
|
6
6
|
|
7
7
|
## Documentation
|
8
8
|
|
9
|
-
Documentation
|
9
|
+
Documentation can be seen in [the docs folder](https://github.com/DeimosCloud/logstash-input-google-analytics-daily/blob/master/docs/index.asciidoc).
|
10
10
|
|
11
11
|
## Developing
|
12
12
|
|
@@ -111,30 +111,7 @@ class LogStash::Inputs::GoogleAnalyticsDaily < LogStash::Inputs::Base
|
|
111
111
|
sort: options[:sort],
|
112
112
|
)
|
113
113
|
|
114
|
-
|
115
|
-
profile_info = results.profile_info.to_h
|
116
|
-
column_headers = results.column_headers.map { |c| c.name }
|
117
|
-
|
118
|
-
event = LogStash::Event.new
|
119
|
-
decorate(event)
|
120
|
-
# Populate Logstash event fields
|
121
|
-
event.set('ga.contains_sampled_data', results.contains_sampled_data?)
|
122
|
-
event.set('ga.query', query) if @store_query
|
123
|
-
event.set('ga.profile_info', profile_info) if @store_profile
|
124
|
-
|
125
|
-
if date == 'today'
|
126
|
-
event.set('ga.date', Time.now.strftime("%F"))
|
127
|
-
elsif date == 'yesterday'
|
128
|
-
event.set('ga.date', Time.at(Time.now.to_i - 86400).strftime("%F"))
|
129
|
-
elsif date.include?('daysAgo')
|
130
|
-
days_ago = date.sub('daysAgo', '').to_i
|
131
|
-
event.set('ga.date', Time.at(Time.now.to_i - (days_ago * 86400)).strftime("%F"))
|
132
|
-
else
|
133
|
-
event.set('ga.date', date)
|
134
|
-
end
|
135
|
-
|
136
|
-
# Use date and metrics as ID to prevent duplicate entries in Elasticsearch
|
137
|
-
event.set('_id', event.get('ga.date') + options[:metrics])
|
114
|
+
column_headers = results.column_headers.map &:name
|
138
115
|
|
139
116
|
rows = []
|
140
117
|
|
@@ -175,10 +152,47 @@ class LogStash::Inputs::GoogleAnalyticsDaily < LogStash::Inputs::Base
|
|
175
152
|
rows << {metrics: metrics, dimensions: dimensions}
|
176
153
|
end
|
177
154
|
|
178
|
-
|
179
|
-
|
155
|
+
query = results.query.to_h
|
156
|
+
profile_info = results.profile_info.to_h
|
157
|
+
|
158
|
+
# One event per metric
|
159
|
+
@metrics.each do |metric|
|
160
|
+
rows_for_this_metric = rows.clone.map do |row|
|
161
|
+
# Remove any rows that don't include this metric
|
162
|
+
new_row = row.clone
|
163
|
+
new_row[:metric] = row[:metrics].find { |m| m[:name] == metric }
|
164
|
+
new_row.delete(:metrics)
|
165
|
+
new_row
|
166
|
+
end
|
180
167
|
|
181
|
-
|
168
|
+
event = LogStash::Event.new
|
169
|
+
decorate(event)
|
170
|
+
# Populate Logstash event fields
|
171
|
+
event.set('ga.contains_sampled_data', results.contains_sampled_data?)
|
172
|
+
event.set('ga.query', query) if @store_query
|
173
|
+
# We need to convert the date fields here to string because sometimes it's a relative date, so will cause mapping issues
|
174
|
+
event.set('ga.query.start_date', query["start_date"].to_s) if @store_query
|
175
|
+
event.set('ga.query.end_date', query["end_date"].to_s) if @store_query
|
176
|
+
|
177
|
+
event.set('ga.profile_info', profile_info) if @store_profile
|
178
|
+
|
179
|
+
if date == 'today'
|
180
|
+
event.set('ga.date', Time.now.strftime("%F"))
|
181
|
+
elsif date == 'yesterday'
|
182
|
+
event.set('ga.date', Time.at(Time.now.to_i - 86400).strftime("%F"))
|
183
|
+
elsif date.include?('daysAgo')
|
184
|
+
days_ago = date.sub('daysAgo', '').to_i
|
185
|
+
event.set('ga.date', Time.at(Time.now.to_i - (days_ago * 86400)).strftime("%F"))
|
186
|
+
else
|
187
|
+
event.set('ga.date', date)
|
188
|
+
end
|
189
|
+
|
190
|
+
event.set("ga.rows", rows_for_this_metric)
|
191
|
+
# Use date and metrics as ID to prevent duplicate entries in Elasticsearch
|
192
|
+
event.set('[@metadata][id]', event.get('ga.date') + metric)
|
193
|
+
queue << event
|
194
|
+
end
|
195
|
+
end
|
182
196
|
end
|
183
197
|
|
184
198
|
# If no interval was set, we're done
|
@@ -210,7 +224,7 @@ class LogStash::Inputs::GoogleAnalyticsDaily < LogStash::Inputs::Base
|
|
210
224
|
:view_id => @view_id,
|
211
225
|
:start_date => date,
|
212
226
|
:end_date => date,
|
213
|
-
:metrics => @metrics.
|
227
|
+
:metrics => @metrics.join(','),
|
214
228
|
:output => 'json',
|
215
229
|
}
|
216
230
|
options.merge!({:dimensions => @dimensions.join(',')}) if (@dimensions and @dimensions.size)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-google-analytics-daily'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.2.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Logstash plugin to pull daily reports from Google Analytics."
|
6
6
|
s.description = "Logstash plugin to pull daily reports from the Google Analytics v3 Core Reporting API. Install into Logstash using $LS_HOME/bin/logstash-plugin install logstash-input-google-analytics-daily."
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
# Gem dependencies
|
21
21
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 2.0.0", "< 3.0.0"
|
22
22
|
s.add_runtime_dependency 'stud', '>= 0.0.22'
|
23
|
-
s.add_runtime_dependency 'google-api-client', "0.37"
|
24
|
-
s.add_runtime_dependency 'googleauth'
|
23
|
+
s.add_runtime_dependency 'google-api-client', "~> 0.37"
|
24
|
+
s.add_runtime_dependency 'googleauth', ">= 0.10.0"
|
25
25
|
s.add_development_dependency 'vcr'
|
26
26
|
s.add_development_dependency 'webmock'
|
27
27
|
s.add_development_dependency 'json'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-google-analytics-daily
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shalvah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- -
|
50
|
+
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0.37'
|
53
53
|
name: google-api-client
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0.37'
|
61
61
|
- !ruby/object:Gem::Dependency
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
requirements:
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 0.10.0
|
67
67
|
name: googleauth
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 0.10.0
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|