Пример #1
0
def get_indices_stats(es_client, parse_indices):
    try:
        response = es_client.indices.stats()

        metrics = indices_stats_parser.parse_response(response, parse_indices, ['es', 'indices_stats'])
    except Exception:
        logging.exception('Error while fetching indices stats.')
    else:
        update_gauges(metrics)
Пример #2
0
    def collect(self):
        try:
            response = self.es_client.indices.stats(metric=self.metrics, fields=self.fields, request_timeout=self.timeout)

            metrics = indices_stats_parser.parse_response(response, self.parse_indices, self.metric_name_list)
        except ConnectionTimeout:
            logging.warn('Timeout while fetching %s (timeout %ss).', self.description, self.timeout)
            yield collector_up_gauge(self.metric_name_list, self.description, succeeded=False)
        except Exception:
            logging.exception('Error while fetching %s.', self.description)
            yield collector_up_gauge(self.metric_name_list, self.description, succeeded=False)
        else:
            yield from gauge_generator(metrics)
            yield collector_up_gauge(self.metric_name_list, self.description)
Пример #3
0
    def test_endpoint_indices(self):

        expected = {
            'primaries_docs_count{index="foo"}':
            3,
            'primaries_docs_deleted{index="foo"}':
            0,
            'primaries_store_size_in_bytes{index="foo"}':
            12690,
            'primaries_store_throttle_time_in_millis{index="foo"}':
            0,
            'primaries_indexing_index_total{index="foo"}':
            3,
            'primaries_indexing_index_time_in_millis{index="foo"}':
            45,
            'primaries_indexing_index_current{index="foo"}':
            0,
            'primaries_indexing_index_failed{index="foo"}':
            0,
            'primaries_indexing_delete_total{index="foo"}':
            0,
            'primaries_indexing_delete_time_in_millis{index="foo"}':
            0,
            'primaries_indexing_delete_current{index="foo"}':
            0,
            'primaries_indexing_noop_update_total{index="foo"}':
            0,
            'primaries_indexing_is_throttled{index="foo"}':
            0,
            'primaries_indexing_throttle_time_in_millis{index="foo"}':
            0,
            'primaries_get_total{index="foo"}':
            0,
            'primaries_get_time_in_millis{index="foo"}':
            0,
            'primaries_get_exists_total{index="foo"}':
            0,
            'primaries_get_exists_time_in_millis{index="foo"}':
            0,
            'primaries_get_missing_total{index="foo"}':
            0,
            'primaries_get_missing_time_in_millis{index="foo"}':
            0,
            'primaries_get_current{index="foo"}':
            0,
            'primaries_search_open_contexts{index="foo"}':
            0,
            'primaries_search_query_total{index="foo"}':
            0,
            'primaries_search_query_time_in_millis{index="foo"}':
            0,
            'primaries_search_query_current{index="foo"}':
            0,
            'primaries_search_fetch_total{index="foo"}':
            0,
            'primaries_search_fetch_time_in_millis{index="foo"}':
            0,
            'primaries_search_fetch_current{index="foo"}':
            0,
            'primaries_search_scroll_total{index="foo"}':
            0,
            'primaries_search_scroll_time_in_millis{index="foo"}':
            0,
            'primaries_search_scroll_current{index="foo"}':
            0,
            'primaries_search_suggest_total{index="foo"}':
            0,
            'primaries_search_suggest_time_in_millis{index="foo"}':
            0,
            'primaries_search_suggest_current{index="foo"}':
            0,
            'primaries_merges_current{index="foo"}':
            0,
            'primaries_merges_current_docs{index="foo"}':
            0,
            'primaries_merges_current_size_in_bytes{index="foo"}':
            0,
            'primaries_merges_total{index="foo"}':
            0,
            'primaries_merges_total_time_in_millis{index="foo"}':
            0,
            'primaries_merges_total_docs{index="foo"}':
            0,
            'primaries_merges_total_size_in_bytes{index="foo"}':
            0,
            'primaries_merges_total_stopped_time_in_millis{index="foo"}':
            0,
            'primaries_merges_total_throttled_time_in_millis{index="foo"}':
            0,
            'primaries_merges_total_auto_throttle_in_bytes{index="foo"}':
            104857600,
            'primaries_refresh_total{index="foo"}':
            3,
            'primaries_refresh_total_time_in_millis{index="foo"}':
            107,
            'primaries_flush_total{index="foo"}':
            0,
            'primaries_flush_total_time_in_millis{index="foo"}':
            0,
            'primaries_warmer_current{index="foo"}':
            0,
            'primaries_warmer_total{index="foo"}':
            8,
            'primaries_warmer_total_time_in_millis{index="foo"}':
            6,
            'primaries_query_cache_memory_size_in_bytes{index="foo"}':
            0,
            'primaries_query_cache_total_count{index="foo"}':
            0,
            'primaries_query_cache_hit_count{index="foo"}':
            0,
            'primaries_query_cache_miss_count{index="foo"}':
            0,
            'primaries_query_cache_cache_size{index="foo"}':
            0,
            'primaries_query_cache_cache_count{index="foo"}':
            0,
            'primaries_query_cache_evictions{index="foo"}':
            0,
            'primaries_fielddata_memory_size_in_bytes{index="foo"}':
            0,
            'primaries_fielddata_evictions{index="foo"}':
            0,
            'primaries_fielddata_fields_memory_size_in_bytes{index="foo",field="group1"}':
            1024,
            'primaries_fielddata_fields_memory_size_in_bytes{index="foo",field="group2"}':
            2048,
            'primaries_completion_size_in_bytes{index="foo"}':
            0,
            'primaries_segments_count{index="foo"}':
            3,
            'primaries_segments_memory_in_bytes{index="foo"}':
            7908,
            'primaries_segments_terms_memory_in_bytes{index="foo"}':
            5976,
            'primaries_segments_stored_fields_memory_in_bytes{index="foo"}':
            936,
            'primaries_segments_term_vectors_memory_in_bytes{index="foo"}':
            0,
            'primaries_segments_norms_memory_in_bytes{index="foo"}':
            576,
            'primaries_segments_points_memory_in_bytes{index="foo"}':
            144,
            'primaries_segments_doc_values_memory_in_bytes{index="foo"}':
            276,
            'primaries_segments_index_writer_memory_in_bytes{index="foo"}':
            0,
            'primaries_segments_version_map_memory_in_bytes{index="foo"}':
            0,
            'primaries_segments_fixed_bit_set_memory_in_bytes{index="foo"}':
            0,
            'primaries_segments_max_unsafe_auto_id_timestamp{index="foo"}':
            -1,
            'primaries_translog_operations{index="foo"}':
            3,
            'primaries_translog_size_in_bytes{index="foo"}':
            491,
            'primaries_request_cache_memory_size_in_bytes{index="foo"}':
            0,
            'primaries_request_cache_evictions{index="foo"}':
            0,
            'primaries_request_cache_hit_count{index="foo"}':
            0,
            'primaries_request_cache_miss_count{index="foo"}':
            0,
            'primaries_recovery_current_as_source{index="foo"}':
            0,
            'primaries_recovery_current_as_target{index="foo"}':
            0,
            'primaries_recovery_throttle_time_in_millis{index="foo"}':
            0,
            'total_docs_count{index="foo"}':
            3,
            'total_docs_deleted{index="foo"}':
            0,
            'total_store_size_in_bytes{index="foo"}':
            12690,
            'total_store_throttle_time_in_millis{index="foo"}':
            0,
            'total_indexing_index_total{index="foo"}':
            3,
            'total_indexing_index_time_in_millis{index="foo"}':
            45,
            'total_indexing_index_current{index="foo"}':
            0,
            'total_indexing_index_failed{index="foo"}':
            0,
            'total_indexing_delete_total{index="foo"}':
            0,
            'total_indexing_delete_time_in_millis{index="foo"}':
            0,
            'total_indexing_delete_current{index="foo"}':
            0,
            'total_indexing_noop_update_total{index="foo"}':
            0,
            'total_indexing_is_throttled{index="foo"}':
            0,
            'total_indexing_throttle_time_in_millis{index="foo"}':
            0,
            'total_get_total{index="foo"}':
            0,
            'total_get_time_in_millis{index="foo"}':
            0,
            'total_get_exists_total{index="foo"}':
            0,
            'total_get_exists_time_in_millis{index="foo"}':
            0,
            'total_get_missing_total{index="foo"}':
            0,
            'total_get_missing_time_in_millis{index="foo"}':
            0,
            'total_get_current{index="foo"}':
            0,
            'total_search_open_contexts{index="foo"}':
            0,
            'total_search_query_total{index="foo"}':
            0,
            'total_search_query_time_in_millis{index="foo"}':
            0,
            'total_search_query_current{index="foo"}':
            0,
            'total_search_fetch_total{index="foo"}':
            0,
            'total_search_fetch_time_in_millis{index="foo"}':
            0,
            'total_search_fetch_current{index="foo"}':
            0,
            'total_search_scroll_total{index="foo"}':
            0,
            'total_search_scroll_time_in_millis{index="foo"}':
            0,
            'total_search_scroll_current{index="foo"}':
            0,
            'total_search_suggest_total{index="foo"}':
            0,
            'total_search_suggest_time_in_millis{index="foo"}':
            0,
            'total_search_suggest_current{index="foo"}':
            0,
            'total_merges_current{index="foo"}':
            0,
            'total_merges_current_docs{index="foo"}':
            0,
            'total_merges_current_size_in_bytes{index="foo"}':
            0,
            'total_merges_total{index="foo"}':
            0,
            'total_merges_total_time_in_millis{index="foo"}':
            0,
            'total_merges_total_docs{index="foo"}':
            0,
            'total_merges_total_size_in_bytes{index="foo"}':
            0,
            'total_merges_total_stopped_time_in_millis{index="foo"}':
            0,
            'total_merges_total_throttled_time_in_millis{index="foo"}':
            0,
            'total_merges_total_auto_throttle_in_bytes{index="foo"}':
            104857600,
            'total_refresh_total{index="foo"}':
            3,
            'total_refresh_total_time_in_millis{index="foo"}':
            107,
            'total_flush_total{index="foo"}':
            0,
            'total_flush_total_time_in_millis{index="foo"}':
            0,
            'total_warmer_current{index="foo"}':
            0,
            'total_warmer_total{index="foo"}':
            8,
            'total_warmer_total_time_in_millis{index="foo"}':
            6,
            'total_query_cache_memory_size_in_bytes{index="foo"}':
            0,
            'total_query_cache_total_count{index="foo"}':
            0,
            'total_query_cache_hit_count{index="foo"}':
            0,
            'total_query_cache_miss_count{index="foo"}':
            0,
            'total_query_cache_cache_size{index="foo"}':
            0,
            'total_query_cache_cache_count{index="foo"}':
            0,
            'total_query_cache_evictions{index="foo"}':
            0,
            'total_fielddata_memory_size_in_bytes{index="foo"}':
            0,
            'total_fielddata_evictions{index="foo"}':
            0,
            'total_fielddata_fields_memory_size_in_bytes{index="foo",field="group1"}':
            1024,
            'total_fielddata_fields_memory_size_in_bytes{index="foo",field="group2"}':
            2048,
            'total_completion_size_in_bytes{index="foo"}':
            0,
            'total_segments_count{index="foo"}':
            3,
            'total_segments_memory_in_bytes{index="foo"}':
            7908,
            'total_segments_terms_memory_in_bytes{index="foo"}':
            5976,
            'total_segments_stored_fields_memory_in_bytes{index="foo"}':
            936,
            'total_segments_term_vectors_memory_in_bytes{index="foo"}':
            0,
            'total_segments_norms_memory_in_bytes{index="foo"}':
            576,
            'total_segments_points_memory_in_bytes{index="foo"}':
            144,
            'total_segments_doc_values_memory_in_bytes{index="foo"}':
            276,
            'total_segments_index_writer_memory_in_bytes{index="foo"}':
            0,
            'total_segments_version_map_memory_in_bytes{index="foo"}':
            0,
            'total_segments_fixed_bit_set_memory_in_bytes{index="foo"}':
            0,
            'total_segments_max_unsafe_auto_id_timestamp{index="foo"}':
            -1,
            'total_translog_operations{index="foo"}':
            3,
            'total_translog_size_in_bytes{index="foo"}':
            491,
            'total_request_cache_memory_size_in_bytes{index="foo"}':
            0,
            'total_request_cache_evictions{index="foo"}':
            0,
            'total_request_cache_hit_count{index="foo"}':
            0,
            'total_request_cache_miss_count{index="foo"}':
            0,
            'total_recovery_current_as_source{index="foo"}':
            0,
            'total_recovery_current_as_target{index="foo"}':
            0,
            'total_recovery_throttle_time_in_millis{index="foo"}':
            0,
        }
        result = convert_result(
            parse_response(self.response, parse_indices=True))
        self.assertEqual(expected, result)