appsignal-exporter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +21 -0
- data/appsignal-exporter.gemspec +17 -0
- data/bin/appsignal-exporter +15 -0
- data/lib/appsignal-exporter.rb +47 -0
- data/lib/appsignal_exporter/version.rb +3 -0
- data/readme.md +25 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 975d34ffd418c4a330a6ed70397f3adfc260bdde
|
4
|
+
data.tar.gz: 77f6b126b69508755b0e2c1ab8360f4e0eebaaba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ace7bbd84a4cc1b3710f6a193fc04d42addd91f325505409308eec64263693e66001c5d77c679cf35eef3ec131b72e72d93d476e461f6083490322394ace210
|
7
|
+
data.tar.gz: 97978b1360564e01eb4b65813b1452cb9a4068df91b106f861503e0db8c593dd19b6be1973b03711142ec700ac81b5fd26bbc61e662a8dee7d5958bb02b0ea15
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 physiovia GmbH
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'lib/appsignal_exporter/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'appsignal-exporter'
|
5
|
+
s.version = AppsignalExporter::VERSION
|
6
|
+
s.date = '2017-06-22'
|
7
|
+
s.summary = "Exporter for the AppSignal platform"
|
8
|
+
s.description = "Exporter for the AppSignal platform"
|
9
|
+
s.authors = ["Clemens Kofler"]
|
10
|
+
s.email = 'clemens.kofler@physiovia.com'
|
11
|
+
s.executables = ['appsignal-exporter']
|
12
|
+
s.files = `git ls-files -z`.split("\0")
|
13
|
+
s.homepage = 'https://github.com/physiovia/appsignal-exporter'
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.add_dependency 'rest-client'
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'appsignal-exporter'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
params = Hash[ARGV.map do |arg|
|
10
|
+
split = arg.split('=')
|
11
|
+
[split[0].to_sym, split[1]]
|
12
|
+
end]
|
13
|
+
|
14
|
+
exporter = AppsignalExporter.new(ENV['APPSIGNAL_API_KEY'], ENV['APPSIGNAL_APP_ID'])
|
15
|
+
exporter.export_errors(params)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'pathname'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
class AppsignalExporter
|
7
|
+
def initialize(api_key, app_id)
|
8
|
+
@api_key = api_key
|
9
|
+
@app_id = app_id
|
10
|
+
@output_path = Pathname.new("appsignal-export-#{Date.today.strftime('%Y-%m-%d')}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def export_errors(params = {})
|
14
|
+
params = parse_params(params)
|
15
|
+
@output_path.mkpath
|
16
|
+
|
17
|
+
output_file = @output_path.join('errors.json')
|
18
|
+
return if output_file.exist?
|
19
|
+
|
20
|
+
error_samples_response = get('samples/errors', params)
|
21
|
+
|
22
|
+
output_file.write(error_samples_response)
|
23
|
+
|
24
|
+
error_samples_response['log_entries'].each do |entry|
|
25
|
+
next if (output_file = @output_path.join("#{entry['id']}.json")).exist?
|
26
|
+
|
27
|
+
error_sample_response = get("samples/#{entry['id']}")
|
28
|
+
output_file.write(error_sample_response)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def get(path, params = {})
|
35
|
+
query_string = params.merge(token: @api_key).map { |key, value| "#{key}=#{value}" }.join('&')
|
36
|
+
JSON.parse(RestClient.get("https://appsignal.com/api/#{@app_id}/#{path}.json?#{query_string}"))
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_params(params)
|
40
|
+
params[:since] = Time.utc(*params[:since].split(/\D/).map(&:to_i)).to_i if params.key?(:since)
|
41
|
+
params[:before] = Time.utc(*params[:before].split(/\D/).map(&:to_i)).to_i if params.key?(:before)
|
42
|
+
params
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
require_relative 'appsignal_exporter/version'
|
data/readme.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Appsignal Exporter
|
2
|
+
|
3
|
+
A little tool we wrote to export errors from our [AppSignal](https://appsignal.com) apps for record keeping. It reads and dumps errors as JSON files – no more, no less. We might add additional exports and options if we need them (or if you're a great person and provide pull requests that we can use).
|
4
|
+
|
5
|
+
Note that the gem doesn't have tests or any particular error handling. Use it at your own risk. ;-)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add the gem to your Gemfile (`gem 'appsignal-exporter'`) and run `bundle install`.
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The AppSignal API key (`APPSIGNAL_API_KEY` – found in [your personal settings](https://appsignal.com/users/edit)) and app ID (`APPSIGNAL_APP_ID` – found in the app's URL on the AppSignal dashboard) need to be passed as environment variables. You can use the [dotenv gem](https://github.com/bkeepers/dotenv) if you like.
|
14
|
+
|
15
|
+
Then run it:
|
16
|
+
|
17
|
+
`bundle exec appsignal-exporter`
|
18
|
+
|
19
|
+
Optionally pass parameters as defined in the [API docs](https://docs.appsignal.com/api/samples.html):
|
20
|
+
|
21
|
+
`bundle exec appsignal-exporter since=2017-06-01 before=2017-07-01`
|
22
|
+
|
23
|
+
## Credits
|
24
|
+
|
25
|
+
(c) 2017 physiovia GmbH
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appsignal-exporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Clemens Kofler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Exporter for the AppSignal platform
|
28
|
+
email: clemens.kofler@physiovia.com
|
29
|
+
executables:
|
30
|
+
- appsignal-exporter
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- MIT-LICENSE
|
37
|
+
- appsignal-exporter.gemspec
|
38
|
+
- bin/appsignal-exporter
|
39
|
+
- lib/appsignal-exporter.rb
|
40
|
+
- lib/appsignal_exporter/version.rb
|
41
|
+
- readme.md
|
42
|
+
homepage: https://github.com/physiovia/appsignal-exporter
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.6.11
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Exporter for the AppSignal platform
|
66
|
+
test_files: []
|