|
24 | 24 | # |
25 | 25 | # LICENSE: |
26 | 26 | # Copyright 2011 Sonian, Inc <chefs@sonian.net> |
27 | | -# Copyright 2016 Philipp Hellmich <phil@hellmi.de> |
| 27 | +# Copyright 2018 Philipp Hellmich <phil@hellmi.de> |
28 | 28 | # Released under the same terms as Sensu (the MIT license); see LICENSE |
29 | 29 | # for details. |
30 | 30 | # |
@@ -113,31 +113,65 @@ def run # rubocop:disable Metrics/AbcSize |
113 | 113 | metrics['process.peak_open_file_descriptors'] = node['process']['peak_open_file_descriptors'] |
114 | 114 | metrics['process.max_file_descriptors'] = node['process']['max_file_descriptors'] |
115 | 115 |
|
116 | | - node['pipeline']['events'].each do |key, value| |
117 | | - metrics["pipeline.events.#{key}"] = value |
118 | | - end |
119 | | - |
120 | | - node['pipeline']['plugins']['inputs'].each do |item| |
121 | | - item['events'] = {} unless item.key?('events') |
122 | | - metrics["pipeline.plugins.inputs.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
123 | | - metrics["pipeline.plugins.inputs.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
124 | | - metrics["pipeline.plugins.inputs.#{item['name']}.#{item['id']}.events.queue_push_duration_in_millis"] = \ |
125 | | - item['events']['queue_push_duration_in_millis'].to_i || 0 |
126 | | - end |
127 | | - |
128 | | - node['pipeline']['plugins']['filters'].each do |item| |
129 | | - item['events'] = {} unless item.key?('events') |
130 | | - metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
131 | | - metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
132 | | - metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0 |
133 | | - metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.matches"] = item['matches'].to_i if item.key?('matches') |
134 | | - end |
135 | | - |
136 | | - node['pipeline']['plugins']['outputs'].each do |item| |
137 | | - item['events'] = {} unless item.key?('events') |
138 | | - metrics["pipeline.plugins.outputs.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
139 | | - metrics["pipeline.plugins.outputs.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
140 | | - metrics["pipeline.plugins.outputs.#{item['name']}.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0 |
| 116 | + # logstash < 6.0 |
| 117 | + if node.key?('pipeline') |
| 118 | + node['pipeline']['events'].each do |key, value| |
| 119 | + metrics["pipeline.events.#{key}"] = value |
| 120 | + end |
| 121 | + |
| 122 | + node['pipeline']['plugins']['inputs'].each do |item| |
| 123 | + item['events'] = {} unless item.key?('events') |
| 124 | + metrics["pipeline.plugins.inputs.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
| 125 | + metrics["pipeline.plugins.inputs.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
| 126 | + metrics["pipeline.plugins.inputs.#{item['name']}.#{item['id']}.events.queue_push_duration_in_millis"] = \ |
| 127 | + item['events']['queue_push_duration_in_millis'].to_i || 0 |
| 128 | + end |
| 129 | + |
| 130 | + node['pipeline']['plugins']['filters'].each do |item| |
| 131 | + metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
| 132 | + metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0 |
| 133 | + metrics["pipeline.plugins.filters.#{item['name']}.#{item['id']}.matches"] = item['matches'].to_i if item.key?('matches') |
| 134 | + end |
| 135 | + |
| 136 | + node['pipeline']['plugins']['outputs'].each do |item| |
| 137 | + item['events'] = {} unless item.key?('events') |
| 138 | + metrics["pipeline.plugins.outputs.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
| 139 | + metrics["pipeline.plugins.outputs.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
| 140 | + metrics["pipeline.plugins.outputs.#{item['name']}.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0 |
| 141 | + end |
| 142 | + # logstash >= 6.0 |
| 143 | + elsif node.key?('pipelines') |
| 144 | + node['pipelines'].each_key do |pipeline| |
| 145 | + if node['pipelines'][pipeline]['events'].nil? || node['pipelines'][pipeline]['events'] == 'null' |
| 146 | + # Skip |
| 147 | + else |
| 148 | + node['pipelines'][pipeline]['events'].each do |key, value| |
| 149 | + metrics["pipelines.#{pipeline}.events.#{key}"] = value |
| 150 | + end |
| 151 | + end |
| 152 | + |
| 153 | + node['pipelines'][pipeline]['plugins']['inputs'].each do |item| |
| 154 | + item['events'] = {} unless item.key?('events') |
| 155 | + metrics["pipelines.#{pipeline}.plugins.inputs.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
| 156 | + metrics["pipelines.#{pipeline}.plugins.inputs.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
| 157 | + metrics["pipelines.#{pipeline}.plugins.inputs.#{item['name']}.#{item['id']}.events.queue_push_duration_in_millis"] = item['events']['queue_push_duration_in_millis'].to_i || 0 # rubocop:disable Metrics/LineLength |
| 158 | + end |
| 159 | + |
| 160 | + node['pipelines'][pipeline]['plugins']['filters'].each do |item| |
| 161 | + item['events'] = {} unless item.key?('events') |
| 162 | + metrics["pipelines.#{pipeline}.plugins.filters.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
| 163 | + metrics["pipelines.#{pipeline}.plugins.filters.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
| 164 | + metrics["pipelines.#{pipeline}.plugins.filters.#{item['name']}.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0 # rubocop:disable Metrics/LineLength |
| 165 | + metrics["pipelines.#{pipeline}.plugins.filters.#{item['name']}.#{item['id']}.matches"] = item['matches'].to_i if item.key?('matches') |
| 166 | + end |
| 167 | + |
| 168 | + node['pipelines'][pipeline]['plugins']['outputs'].each do |item| |
| 169 | + item['events'] = {} unless item.key?('events') |
| 170 | + metrics["pipelines.#{pipeline}.plugins.outputs.#{item['name']}.#{item['id']}.events.in"] = item['events']['in'].to_i || 0 |
| 171 | + metrics["pipelines.#{pipeline}.plugins.outputs.#{item['name']}.#{item['id']}.events.out"] = item['events']['out'].to_i || 0 |
| 172 | + metrics["pipelines.#{pipeline}.plugins.outputs.#{item['name']}.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0 # rubocop:disable Metrics/LineLength |
| 173 | + end |
| 174 | + end |
141 | 175 | end |
142 | 176 |
|
143 | 177 | metrics.each do |k, v| |
|
0 commit comments