alerty-plugin-stackdriver 0.1.0 → 0.2.0
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/LICENSE +21 -0
- data/README.md +20 -0
- data/alerty-plugin-stackdriver.gemspec +1 -1
- data/lib/alerty/plugin/stackdriver.rb +22 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d3325464e2303f7f9ec6e0e05b6f9922810a76a
|
4
|
+
data.tar.gz: 0060fe275b148594af890d102c6d5cacd0fe5145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b3b20f61b128e0548c34a77d07a19bf8386f6668e32e5123f25ab856e75148ba7f59687946835a81c2293553c754aa8a020c02e69eb52327be19489e93ae26e
|
7
|
+
data.tar.gz: c82203f2b3d37ecca7d580d5cc95af59a3ba6364cc66643a24061d53b886a014830755c50e4da392723f819566f2911ef4af5ec1319220a98bc72fd85841c9ca
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 potato2003
|
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.
|
data/README.md
CHANGED
@@ -26,8 +26,25 @@ Or install it yourself as:
|
|
26
26
|
* **log_name**: Stackdriver log name.
|
27
27
|
* **resource_type**: Stackdriver Logging monitored resource types. https://cloud.google.com/logging/docs/api/v2/resource-list
|
28
28
|
* **resource_labels**: Stackdriver Logging monitored resource labels. https://cloud.google.com/logging/docs/api/v2/resource-list
|
29
|
+
* **app_name**: your application name, the default name is `alerty`.
|
30
|
+
* **app_version**: your application version, the default value is `default`.
|
29
31
|
* **message**: message of alert. `${command}` is replaced with a given command, `${hostname}` is replaced with the hostname ran the command, `${output}` is replaced with the output. The default is `${output}`.
|
30
32
|
|
33
|
+
|
34
|
+
```
|
35
|
+
log_path: STDOUT
|
36
|
+
log_level: debug
|
37
|
+
plugins:
|
38
|
+
- type: stackdriver
|
39
|
+
keyfile: "example_keyfile.json"
|
40
|
+
project_id: "example_project"
|
41
|
+
log_name: "example_alerty_log"
|
42
|
+
resource_type: "gae_app"
|
43
|
+
resource_labels:
|
44
|
+
module_id: "1"
|
45
|
+
version_id: "20150925t173233"
|
46
|
+
```
|
47
|
+
|
31
48
|
## Development
|
32
49
|
|
33
50
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -38,3 +55,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
38
55
|
|
39
56
|
Bug reports and pull requests are welcome on GitHub at https://github.com/potato2003/alerty-plugin-stackdriver.
|
40
57
|
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -11,7 +11,9 @@ class Alerty
|
|
11
11
|
# https://cloud.google.com/logging/docs/api/v2/resource-list
|
12
12
|
@resource_type = config.resource_type
|
13
13
|
@resource_labels = config.resource_labels
|
14
|
-
@
|
14
|
+
@app_name = config.app_name || 'alerty'
|
15
|
+
@app_version = config.app_version || 'default'
|
16
|
+
@log_name = config.log_name || 'alerty'
|
15
17
|
@message = config.message
|
16
18
|
@num_retries = config.num_retries || DEFAULT_NUM_OF_RETIRES
|
17
19
|
|
@@ -55,16 +57,30 @@ class Alerty
|
|
55
57
|
e.resource.labels = @resource_labels if @resource_labels
|
56
58
|
e.log_name = @log_name
|
57
59
|
e.payload = payload(record)
|
60
|
+
e.severity = :ERROR
|
58
61
|
|
59
62
|
e
|
60
63
|
end
|
61
64
|
|
62
65
|
def payload(record)
|
63
|
-
if @message
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
body = if @message
|
67
|
+
expand_placeholder(@message, record)
|
68
|
+
else
|
69
|
+
record[:output]
|
70
|
+
end
|
71
|
+
|
72
|
+
# support Stackdriver Error Reporting. https://cloud.google.com/error-reporting/docs/formatting-error-messages
|
73
|
+
{
|
74
|
+
serviceContext: {
|
75
|
+
service: @app_name,
|
76
|
+
app_version: @app_version
|
77
|
+
},
|
78
|
+
message: body,
|
79
|
+
context: {
|
80
|
+
functionName: record[:command],
|
81
|
+
lineNumber: 0
|
82
|
+
}
|
83
|
+
}
|
68
84
|
end
|
69
85
|
|
70
86
|
def expand_placeholder(str, record)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alerty-plugin-stackdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- potato2003
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alerty
|
@@ -89,6 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- Gemfile
|
92
|
+
- LICENSE
|
92
93
|
- README.md
|
93
94
|
- Rakefile
|
94
95
|
- alerty-plugin-stackdriver.gemspec
|