sensu-plugin-app-insights 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b287dcda6555ade196e110e9505b94268091f52
4
- data.tar.gz: 0053bdd0babc7c3ac50a15a06490fe9ef2344439
3
+ metadata.gz: 384a5764ec4812361ba20b57241640b2b90533f1
4
+ data.tar.gz: f6ca7359e5486672645b458dcc63f03d88735a61
5
5
  SHA512:
6
- metadata.gz: 2d6b65a7bb821e0ce867601c201f6f4c417de1e47e994ac62837e2db37ecb3e6d87ecbfbefe86dc713926172ca53a01043393416f8721a54e2f3c34db1695cb4
7
- data.tar.gz: 4e96eb6cb9444f51081d2c620a02e5e79b857e1aaa326de49f646428a6ad0435347c8f4b7607f448ba75936cc9ee4ab05434621c37042bc41333384eeccc0d89
6
+ metadata.gz: cd438c1d890199070c6fe53194e468bb6eb3b0727fe418c75154349c933e0cbf24dad97911d48ae7f0ff2ee6effcd3724b857a521e5fefedf2acc854acfd962e
7
+ data.tar.gz: a64c7acdab2be0575a9ccf38ddd5c6340f93b07eb39916a0bd10aa3ea809d05302d52c875a13ad60675a75871f7920ce397875f9c7a6ab8d5202a3a492cfc8e0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
-
2
- # 0.2.0
3
- Included support for inline queries.
1
+ # 0.2.1
2
+ - Correcting the parameters to acccept `--timeout`.
3
+ - Printing the query on the results.
4
+
5
+ # 0.2.0
6
+ - Included support for inline queries.
data/LICENSE CHANGED
@@ -1,201 +1,201 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "{}"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright {yyyy} {name of copyright owner}
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md CHANGED
@@ -1,50 +1,116 @@
1
- [![Build Status](https://travis-ci.org/ve-interactive/sensu-plugin-app-insights.svg?branch=master)](https://travis-ci.org/ve-interactive/sensu-plugin-app-insights)
2
- [![Gem Version](https://badge.fury.io/rb/sensu-plugin-app-insights.svg)](https://badge.fury.io/rb/sensu-plugin-app-insights)
3
-
4
- # Sensu plugin for application insights
5
- This is a pugin for application insights it add capabilities for sensu to use the application insights api in order to create alerts.
6
-
7
- # Installation Instructions
8
- ## Gems
9
-
10
- Installing via gem is the preferred method if one exists.
11
-
12
- ### Standard Installation
13
-
14
- `gem install sensu-plugin-app-insights`
15
-
16
- Note: If the gem has an alpha tag then you will need to use the –prerelease flag or the gem will not be found.
17
-
18
- ### Bundle
19
-
20
- Add _sensu-plugin-app-insights_ to your Gemfile and run `bundle install` or `bundle update`
21
-
22
- ### Chef
23
-
24
- #### Using the Sensu sensu_gem LWRP
25
- ```
26
- sensu_gem 'sensu-plugin-app-insights' do
27
- version '0.1.0'
28
- end
29
- ```
30
- #### Using the Chef package resource
31
- ```
32
- gem_package 'sensu-plugin-app-insights' do
33
- version '0.1.0'
34
- end
35
- ```
36
- ### Puppet
37
-
38
- #### Using the Puppet sensu_gem package provider
39
- ```
40
- package { 'sensu-plugin-app-insights':
41
- ensure => '0.1.0',
42
- provider => sensu_gem,
43
- }
44
- ```
45
- ### Ansible
46
-
47
- ```
48
- - gem: name=sensu-plugin-app-insights version=0.1.0 state=present executable=/opt/sensu/embedded/bin/gem
49
- ```
50
-
1
+ [![Build Status](https://travis-ci.org/ve-interactive/sensu-plugin-app-insights.svg?branch=master)](https://travis-ci.org/ve-interactive/sensu-plugin-app-insights)
2
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugin-app-insights.svg)](https://badge.fury.io/rb/sensu-plugin-app-insights)
3
+
4
+ # Sensu plugin for application insights
5
+ This is a pugin for application insights it add capabilities for sensu to use the application insights api in order to create alerts.
6
+
7
+ # Functionality
8
+
9
+ ## Files
10
+ * bin/query-check.rb
11
+
12
+ ## Usage
13
+
14
+ ### query-check.rb
15
+ ```
16
+ query-check.rb
17
+ -a, --apiURL URL
18
+ -V, --apiVersion beta
19
+ -i, --appId GUID
20
+ -p, --appKey VALUE
21
+ -q, --query /file/with/query or https://fileUrl,
22
+ -r, --resultColumn COLUMN_NAME,
23
+ -w, --warning WARNING_EXPRESSION value > 20,
24
+ -c, --critical CRITICAL_EXPRESSION value > 20,
25
+ -m, --message MESSAGE,
26
+ -t, --timeout SECS
27
+
28
+ ```
29
+
30
+ Parameters that should be used
31
+
32
+ - -a, --apiURL
33
+ - This is the base api url used to connect with application insights you should not change this unless you really know what you are doing. the **default** value for this is **https://api.applicationinsights.io/beta**
34
+ - -V, --apiVersion
35
+ - This is the api version that you are using on application insights as the url you should only change that if you really know what you are doing.
36
+ - -i, --appId **required**
37
+ - This is the application id of your application insights used to send the telemetry (also known as telemetry key) you can find instruction [here](https://dev.applicationinsights.io/documentation/Authorization/API-key-and-App-ID)
38
+ - -p, --appKey **required**
39
+ - This is the appKey that are going to be using to connect to your application insights you can get information on how to obtain this api key [here](https://dev.applicationinsights.io/documentation/Authorization/API-key-and-App-ID)
40
+ - -q, --query **required**
41
+ - Here it is where you should put the application insights query that you pretend to execute. there are 3 supported ways to include the query you can pass a path to a file that has the query `./file/name.ext` the file can have any extension but need to be composed only from the query. Another option it is to have a url `https://file.location.com/file.txt` a get request will be made for this url and the content will be executed as a query. The other option it is to use directly the query inline `requests | limit 10` remembering that breaking lines are not allowed in case you are using the inline query.
42
+ - -r, --resultColumn
43
+ - This is one optional argument that specify the column that will have their value passed to the variable `value` when evaluating the rows. If this is not specified the value will be equal the value of the first numerical column on the result, if there is no numerical value it will be the value of the first column.
44
+ - -w, --warning
45
+ - This is the expression that will be used to evaluate
46
+
47
+ #### Evaluatin Expressions
48
+ The _warning_ and _critical_ expressions are actually evaluated ruby expresions. so any ruby expression can be used here. it is interesting to notice however that there are come variables available for you to use on this that might help you on evaluating the query. this fields are `value` and `values` where value it is the result accoding to what it is specified on the `resultColumn` parameter
49
+
50
+ Exemple:
51
+
52
+ I want to evaluate the following query. that get the amount of times that a product was viewed and the amount of times that a product was bought per each one of the customers and the percentage of sales per view.
53
+
54
+ ```
55
+ customEvents
56
+ | where timestamp >= ago(7d)
57
+ | where name in (‘A’ , ‘B’)
58
+ | extend vendor = tostring(customDimensions.vendor)
59
+ | summarize productViewed = countif(name == ‘A’), productBought = countif(name==’B) by vendor, bin(timestamp, 1d)
60
+ | extend pct = productBought*100.0 / productViewed
61
+ ```
62
+
63
+ My alert would be warning when there are less than 100 product being viewed or when the percentage of sales goes under 2% and critical if I have 0 sales in one day.
64
+
65
+ If I specify the `resultColumn` beeing `productViewed` with `-r productViewed` on the command line.
66
+
67
+ Them I can specify the warning expression `-w "value < 100 || values['pct'] < 2"`
68
+
69
+
70
+
71
+ ---
72
+
73
+ # Installation Instructions
74
+ ## Gems
75
+
76
+ Installing via gem is the preferred method if one exists.
77
+
78
+ ### Standard Installation
79
+
80
+ `gem install sensu-plugin-app-insights`
81
+
82
+ Note: If the gem has an alpha tag then you will need to use the –prerelease flag or the gem will not be found.
83
+
84
+ ### Bundle
85
+
86
+ Add _sensu-plugin-app-insights_ to your Gemfile and run `bundle install` or `bundle update`
87
+
88
+ ### Chef
89
+
90
+ #### Using the Sensu sensu_gem LWRP
91
+ ```
92
+ sensu_gem 'sensu-plugin-app-insights' do
93
+ version '0.2.0'
94
+ end
95
+ ```
96
+ #### Using the Chef package resource
97
+ ```
98
+ gem_package 'sensu-plugin-app-insights' do
99
+ version '0.2.0'
100
+ end
101
+ ```
102
+ ### Puppet
103
+
104
+ #### Using the Puppet sensu_gem package provider
105
+ ```
106
+ package { 'sensu-plugin-app-insights':
107
+ ensure => '0.2.0',
108
+ provider => sensu_gem,
109
+ }
110
+ ```
111
+ ### Ansible
112
+
113
+ ```
114
+ - gem: name=sensu-plugin-app-insights version=0.2.0 state=present executable=/opt/sensu/embedded/bin/gem
115
+ ```
116
+
data/bin/query-check.rb CHANGED
@@ -1,215 +1,217 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # check-query-json
4
- #
5
- # DESCRIPTION:
6
- # Based on the query that you are trying to execute this verify
7
- # if the query satisfy the requirements on the thresholds
8
- # You can specify a column and warning and error expressions
9
- #
10
- # OUTPUT:
11
- # plain text
12
- #
13
- # PLATFORMS:
14
- # Linux
15
- #
16
- # DEPENDENCIES:
17
- # gem: sensu-plugin
18
- # gem: json
19
- #
20
- # USAGE:
21
- # #YELLOW
22
- #
23
- # NOTES:
24
- # Based on Check HTTP.
25
- #
26
- # LICENSE:
27
- # Copyright 2017 Ve Interactive <velabs@veinteractive.com>
28
- # Released under the Apache 2.0 license; see LICENSE
29
- # for details.
30
- #
31
-
32
- require 'sensu-plugin/check/cli'
33
- require 'json'
34
- require 'net/http'
35
- require 'net/https'
36
- require 'open-uri'
37
-
38
- #
39
- # Check query
40
- #
41
- class QueryCheck < Sensu::Plugin::Check::CLI
42
- option :apiUrl,
43
- short: '-a URL',
44
- long: '--apiURL URL',
45
- default: 'https://api.applicationinsights.io/beta'
46
- option :apiVersion,
47
- short: '-V beta',
48
- long: '--apiVersion beta',
49
- default: 'beta'
50
- option :appId,
51
- short: '-i GUID',
52
- long: '--appId GUID',
53
- required: true
54
- option :appKey,
55
- short: '-p VALUE',
56
- long: '--appKey VALUE',
57
- required: true
58
- option :query,
59
- short: '-q /file/with/query or https://fileUrl',
60
- long: '--query /file/with/query or https://fileUrl',
61
- description: 'Query can be expressed as a path to a file a url that will return the raw query or directly inline.',
62
- required: true
63
- option :resultColumn,
64
- short: '-r COLUMN_NAME',
65
- long: '--resultColumn COLUMN_NAME'
66
- option :warningExpression,
67
- short: '-w WARNING_EXPRESSION value > 20',
68
- long: '--warning WARNING_EXPRESSION value > 20'
69
- option :criticalExpression,
70
- short: '-c CRITICAL_EXPRESSION value > 20',
71
- long: '--critical CRITICAL_EXPRESSION value > 20'
72
- option :message,
73
- short: '-m MESSAGE',
74
- long: '--message MESSAGE'
75
- option :timeout,
76
- short: '-t SECS',
77
- proc: proc(&:to_i),
78
- default: 60
79
-
80
- def run
81
- uri = URI.parse(config[:apiUrl])
82
- config[:host] = uri.host
83
- config[:path] = uri.path
84
- config[:port] = uri.port
85
- config[:ssl] = uri.scheme == 'https'
86
- config[:port] ||= config[:ssl] ? 443 : 80
87
- begin
88
- Timeout.timeout(config[:timeout]) do
89
- validate_query
90
- end
91
- rescue Timeout::Error
92
- critical 'Connection timed out'
93
- rescue => e
94
- critical "Connection error: #{e.message}"
95
- end
96
- end
97
-
98
- def json_valid?(str)
99
- JSON.parse(str)
100
- return true
101
- rescue JSON::ParserError
102
- return false
103
- end
104
-
105
- def validate_query
106
- http = Net::HTTP.new(config[:host], config[:port])
107
-
108
- if config[:ssl]
109
- http.use_ssl = true
110
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
111
- end
112
- encoded = get_query(config[:query])
113
- query_url = [[config[:path], 'apps', config[:appId], 'query?query='].compact.join('/'), encoded].compact.join
114
- req = Net::HTTP::Get.new(query_url)
115
- req['x-api-key'] = config[:appKey]
116
- res = http.request(req)
117
- unless res.code =~ /^2/
118
- critical "http code: #{res.code}: body: #{res.body}"
119
- end
120
- critical 'invalid JSON from request' unless json_valid?(res.body)
121
- begin
122
- json = JSON.parse(res.body)
123
- rescue JSON::ParserError
124
- critical 'Not able to parse response from api'
125
- end
126
- validate_result(json)
127
- end
128
-
129
- def get_query(query)
130
- post_body = ''
131
- if query =~ /\A#{URI.regexp(%w(https http))}\z/
132
- uri = URI.parse(query)
133
- http_query = Net::HTTP.new(uri.host, uri.port)
134
- if uri.scheme == 'https'
135
- http_query.use_ssl = true
136
- http_query.verify_mode = OpenSSL::SSL::VERIFY_NONE
137
- end
138
- req_query = Net::HTTP::Get.new(uri.path)
139
- output "request query starting #{req_query}, #{query}"
140
- res_query = http_query.get(req_query)
141
- output 'request query'
142
- unless res_query.code =~ /^2/
143
- critical "http code: #{res_query.code}: body: #{res_query.body}"
144
- end
145
- post_body = res_query.body
146
- elsif File.exist?(query)
147
- post_body = IO.readlines(query).join
148
- else
149
- post_body = query
150
- end
151
- URI.encode(post_body)
152
- end
153
-
154
- def validate_result(json)
155
- columns = json['Tables'][0]['Columns']
156
- rows = json['Tables'][0]['Rows']
157
- column_index = get_column_index(columns)
158
- critical_messages = []
159
- warning_message = []
160
- rows.each_with_index do |row, _index|
161
- values = extract_value(row, columns)
162
- value = row[column_index]
163
- if values.nil? || value.nil?
164
- critical 'unable to extract values'
165
- end
166
-
167
- if config[:warningExpression]
168
- if instance_eval config[:warningExpression]
169
- if config[:message]
170
- warning_message.push instance_eval config[:message]
171
- else
172
- warning_message.push "#{row[column_index]} it is #{config[:warningExpression]}"
173
- end
174
- end
175
- end
176
- if config[:criticalExpression]
177
- if instance_eval config[:criticalExpression]
178
- if config[:message]
179
- critical_messages.push instance_eval config[:message]
180
- else
181
- critical_messages.push "#{row[column_index]} it is #{config[:criticalExpression]}"
182
- end
183
- end
184
- end
185
- end
186
- message "\n Criticals: #{critical_messages} \n Warnings: #{warning_message}"
187
- critical unless critical_messages.empty?
188
- warning unless warning_message.empty?
189
- ok
190
- end
191
-
192
- def get_column_index(columns)
193
- column_index = -1
194
- columns.each_with_index do |value, index|
195
- if value['ColumnName'] == config[:resultColumn]
196
- column_index = index
197
- elsif column_index == -1 && %w(real long).include?(value['ColumnType'])
198
- column_index = index
199
- end
200
- end
201
- if column_index == -1
202
- column_index = 0
203
- end
204
- column_index
205
- end
206
-
207
- def extract_value(row, columns)
208
- result = {}
209
- columns.each_with_index do |value, index|
210
- name = value['ColumnName']
211
- result[name] = row[index]
212
- end
213
- result
214
- end
215
- end
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # check-query-json
4
+ #
5
+ # DESCRIPTION:
6
+ # Based on the query that you are trying to execute this verify
7
+ # if the query satisfy the requirements on the thresholds
8
+ # You can specify a column and warning and error expressions
9
+ #
10
+ # OUTPUT:
11
+ # plain text
12
+ #
13
+ # PLATFORMS:
14
+ # Linux
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ # gem: json
19
+ #
20
+ # USAGE:
21
+ # #YELLOW
22
+ #
23
+ # NOTES:
24
+ # Based on Check HTTP.
25
+ #
26
+ # LICENSE:
27
+ # Copyright 2017 Ve Interactive <velabs@veinteractive.com>
28
+ # Released under the Apache 2.0 license; see LICENSE
29
+ # for details.
30
+ #
31
+
32
+ require 'sensu-plugin/check/cli'
33
+ require 'json'
34
+ require 'net/http'
35
+ require 'net/https'
36
+ require 'open-uri'
37
+
38
+ #
39
+ # Check query
40
+ #
41
+ class QueryCheck < Sensu::Plugin::Check::CLI
42
+ option :apiUrl,
43
+ short: '-a URL',
44
+ long: '--apiURL URL',
45
+ default: 'https://api.applicationinsights.io/beta'
46
+ option :apiVersion,
47
+ short: '-V beta',
48
+ long: '--apiVersion beta',
49
+ default: 'beta'
50
+ option :appId,
51
+ short: '-i GUID',
52
+ long: '--appId GUID',
53
+ required: true
54
+ option :appKey,
55
+ short: '-p VALUE',
56
+ long: '--appKey VALUE',
57
+ required: true
58
+ option :query,
59
+ short: '-q /file/with/query or https://fileUrl',
60
+ long: '--query /file/with/query or https://fileUrl',
61
+ description: 'Query can be expressed as a path to a file a url that will return the raw query or directly inline.',
62
+ required: true
63
+ option :resultColumn,
64
+ short: '-r COLUMN_NAME',
65
+ long: '--resultColumn COLUMN_NAME'
66
+ option :warningExpression,
67
+ short: '-w WARNING_EXPRESSION value > 20',
68
+ long: '--warning WARNING_EXPRESSION value > 20'
69
+ option :criticalExpression,
70
+ short: '-c CRITICAL_EXPRESSION value > 20',
71
+ long: '--critical CRITICAL_EXPRESSION value > 20'
72
+ option :message,
73
+ short: '-m MESSAGE',
74
+ long: '--message MESSAGE'
75
+ option :timeout,
76
+ short: '-t SECS',
77
+ long: '--timeout SECS',
78
+ proc: proc(&:to_i),
79
+ default: 60
80
+
81
+ def run
82
+ uri = URI.parse(config[:apiUrl])
83
+ config[:host] = uri.host
84
+ config[:path] = uri.path
85
+ config[:port] = uri.port
86
+ config[:ssl] = uri.scheme == 'https'
87
+ config[:port] ||= config[:ssl] ? 443 : 80
88
+ begin
89
+ Timeout.timeout(config[:timeout]) do
90
+ validate_query
91
+ end
92
+ rescue Timeout::Error
93
+ critical 'Query timed out'
94
+ rescue => e
95
+ critical "Error:executing #{e.message}"
96
+ end
97
+ end
98
+
99
+ def json_valid?(str)
100
+ JSON.parse(str)
101
+ return true
102
+ rescue JSON::ParserError
103
+ return false
104
+ end
105
+
106
+ def validate_query
107
+ http = Net::HTTP.new(config[:host], config[:port])
108
+
109
+ if config[:ssl]
110
+ http.use_ssl = true
111
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
112
+ end
113
+ query = get_query(config[:query])
114
+ encoded = URI.encode(query)
115
+ query_url = [[config[:path], 'apps', config[:appId], 'query?query='].compact.join('/'), encoded].compact.join
116
+ req = Net::HTTP::Get.new(query_url)
117
+ req['x-api-key'] = config[:appKey]
118
+ res = http.request(req)
119
+ unless res.code =~ /^2/
120
+ critical "http code: #{res.code}: body: #{res.body}"
121
+ end
122
+ critical 'invalid JSON from request' unless json_valid?(res.body)
123
+ begin
124
+ json = JSON.parse(res.body)
125
+ rescue JSON::ParserError
126
+ critical 'Not able to parse response from api'
127
+ end
128
+ validate_result(json, query)
129
+ end
130
+
131
+ def get_query(query)
132
+ post_body = ''
133
+ if query =~ /\A#{URI.regexp(%w(https http))}\z/
134
+ uri = URI.parse(query)
135
+ http_query = Net::HTTP.new(uri.host, uri.port)
136
+ if uri.scheme == 'https'
137
+ http_query.use_ssl = true
138
+ http_query.verify_mode = OpenSSL::SSL::VERIFY_NONE
139
+ end
140
+ req_query = Net::HTTP::Get.new(uri.path)
141
+ output "request query starting #{req_query}, #{query}"
142
+ res_query = http_query.get(req_query)
143
+ output 'request query'
144
+ unless res_query.code =~ /^2/
145
+ critical "http code: #{res_query.code}: body: #{res_query.body}"
146
+ end
147
+ post_body = res_query.body
148
+ elsif File.exist?(query)
149
+ post_body = IO.readlines(query).join
150
+ else
151
+ post_body = query
152
+ end
153
+ post_body
154
+ end
155
+
156
+ def validate_result(json, query)
157
+ columns = json['Tables'][0]['Columns']
158
+ rows = json['Tables'][0]['Rows']
159
+ column_index = get_column_index(columns)
160
+ critical_messages = []
161
+ warning_message = []
162
+ rows.each_with_index do |row, _index|
163
+ values = extract_value(row, columns)
164
+ value = row[column_index]
165
+ if values.nil? || value.nil?
166
+ critical 'unable to extract values'
167
+ end
168
+
169
+ if config[:warningExpression]
170
+ if instance_eval config[:warningExpression]
171
+ if config[:message]
172
+ warning_message.push instance_eval config[:message]
173
+ else
174
+ warning_message.push "#{row[column_index]} it is #{config[:warningExpression]}"
175
+ end
176
+ end
177
+ end
178
+ if config[:criticalExpression]
179
+ if instance_eval config[:criticalExpression]
180
+ if config[:message]
181
+ critical_messages.push instance_eval config[:message]
182
+ else
183
+ critical_messages.push "#{row[column_index]} it is #{config[:criticalExpression]}"
184
+ end
185
+ end
186
+ end
187
+ end
188
+ message "\nQuery:#{query} \n Criticals: #{critical_messages} \n Warnings: #{warning_message}"
189
+ critical unless critical_messages.empty?
190
+ warning unless warning_message.empty?
191
+ ok
192
+ end
193
+
194
+ def get_column_index(columns)
195
+ column_index = -1
196
+ columns.each_with_index do |value, index|
197
+ if value['ColumnName'] == config[:resultColumn]
198
+ column_index = index
199
+ elsif column_index == -1 && %w(real long).include?(value['ColumnType'])
200
+ column_index = index
201
+ end
202
+ end
203
+ if column_index == -1
204
+ column_index = 0
205
+ end
206
+ column_index
207
+ end
208
+
209
+ def extract_value(row, columns)
210
+ result = {}
211
+ columns.each_with_index do |value, index|
212
+ name = value['ColumnName']
213
+ result[name] = row[index]
214
+ end
215
+ result
216
+ end
217
+ end
@@ -1 +1 @@
1
- require 'sensu-plugin-app-insights/version'
1
+ require 'sensu-plugin-app-insights/version'
@@ -2,7 +2,7 @@ module SensuPluginAppInsights
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugin-app-insights
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ve Interactive and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -262,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  version: '0'
263
263
  requirements: []
264
264
  rubyforge_project:
265
- rubygems_version: 2.6.11
265
+ rubygems_version: 2.4.5
266
266
  signing_key:
267
267
  specification_version: 4
268
268
  summary: Sensu plugins for various http monitors and metrics