#NEWLINE# def test_shard_level_metrics_and_service_checks( self ) : #NEWLINE# #INDENT# ' Tests that when the option is set to true, the shard-level metrics\n        are sent as well as the service checks  ' #NEWLINE# config = { #NEWLINE# #INDENT# 'instances' : [ { #NEWLINE# #INDENT# 'url' : 'http://localhost:9200' , #NEWLINE# 'shard_level_metrics' : True , #NEWLINE# 'hostname' : 'foo' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# requests . delete ( 'http://localhost:9200/_all/' ) #NEWLINE# requests . put ( 'http://localhost:9200/testindex/' , data = '{"settings": {"index": {"number_of_replicas": 0,"number_of_shards":3}}}' ) #NEWLINE# requests . put ( 'http://localhost:9200/testindex/testtype/2' , data = '{"name": "Jane Doe", "age": 27}' ) #NEWLINE# requests . post ( 'http://localhost:9200/_flush?wait_for_ongoing' ) #NEWLINE# self . run_check ( config ) #NEWLINE# for ( k , v ) in SHARD_LEVEL_METRICS_SUFFIX . iteritems ( ) : #NEWLINE# #INDENT# SHARD_LEVEL_METRICS [ 'elasticsearch.shard{0}' . format ( k ) ] = v #NEWLINE# #UNINDENT# for ( k , v ) in SHARD_LEVEL_METRICS_POST_1_0_SUFFIX . iteritems ( ) : #NEWLINE# #INDENT# SHARD_LEVEL_METRICS_POST_1_0 [ 'elasticsearch.shard{0}' . format ( k ) ] = v #NEWLINE# #UNINDENT# shard_level_metrics = dict ( SHARD_LEVEL_METRICS ) #NEWLINE# if ( get_es_version ( ) >= [ 1 , 0 , 0 ] ) : #NEWLINE# #INDENT# shard_level_metrics . update ( SHARD_LEVEL_METRICS_POST_1_0 ) #NEWLINE# #UNINDENT# for ( m_name , desc ) in shard_level_metrics . iteritems ( ) : #NEWLINE# #INDENT# if ( desc [ 0 ] == 'gauge' ) : #NEWLINE# #INDENT# self . assertMetric ( m_name , count = 3 ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertServiceCheckOK ( 'elasticsearch.shard.state' , count = 3 ) #NEWLINE# self . assert_default_metrics ( config ) #NEWLINE# self . coverage_report ( )