Sha256: 7f5952fb16f1f13ac557f8cd1c3fe8a19ae5c063d5cab2c9f94802c13621c881

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require_relative 'base_data'

module Fluent
  module Plugin
    module ElasticsearchStats
      class NodesStatsData < BaseData
        NAME = 'nodes_stats'

        def extract_metrics
          metrics = []
          nodes.each_value do |node_stats|
            metadata.dup
                    .set(label: 'hostname', value: node_stats['name'])
                    .set(label: 'host', value: node_stats['host'])

            node_stats.each do |stat_family, stats|
              next unless stats.is_a?(Hash)

              stats.delete('timestamp')
              stats.delete('indices') if stat_family == 'indices'
              # FIXME: indices stats to extract ?

              flattened_stats = Utils.hash_flatten_keys(stats, separator: metric.name_separator)
              flattened_stats.each do |k, v|
                metrics << metric.format(name: ['node', stat_family, k], value: v, family: family, metadata: metadata)
              end
            end
          end
          metrics.compact
        end

        private

        def nodes
          data['nodes']
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fluent-plugin-elasticsearch-stats-0.6.0 lib/fluent/plugin/elasticsearch_stats/nodes_stats_data.rb
fluent-plugin-elasticsearch-stats-0.5.0 lib/fluent/plugin/elasticsearch_stats/nodes_stats_data.rb
fluent-plugin-elasticsearch-stats-0.4.0 lib/fluent/plugin/elasticsearch_stats/nodes_stats_data.rb
fluent-plugin-elasticsearch-stats-0.3.0 lib/fluent/plugin/elasticsearch_stats/nodes_stats_data.rb
fluent-plugin-elasticsearch-stats-0.2.0 lib/fluent/plugin/elasticsearch_stats/nodes_stats_data.rb
fluent-plugin-elasticsearch-stats-0.1.0 lib/fluent/plugin/elasticsearch_stats/nodes_stats_data.rb