Elasticsearch - Indices stats 获取索引级别的统计信息之六 【segments】段的内存使用情况

(45) 2024-05-05 09:01:01

文章目录

      • 一、获取segments内存使用信息
        • 1、获取所有索引的segments信息
        • 2、获取指定索引的segments信息
        • 3、获取同类索引的segments信息
      • 二、输出结果
      • 三、可选参数:include_segment_file_size
        • 请求url
        • 输出结果为
      • 四、结果详情
        • 1、_shards
        • 2、_all
        • 3、indices

转载请标明出处:
http://blog.csdn.net/qq_27818541/article/details/113135809
本文出自:【BigManing的博客】

一、获取segments内存使用信息

segments的内存使用情况。查询时,可以不指定索引 、也可以指定具体索引、也可以指定模糊索引。

1、获取所有索引的segments信息
http://local.elasticsearch:9200/_stats/segments
2、获取指定索引的segments信息
http://local.elasticsearch:9200/book/_stats/segments
3、获取同类索引的segments信息

log索引是按天滚动新增的,这样可以定义log-*来查询所有log索引的统计信息

http://local.elasticsearch:9200/log-*/_stats/segments

二、输出结果

{ 
   
  "_shards": { 
   
    "total": 32,
    "successful": 32,
    "failed": 0
  },
  "_all": { 
   
    "primaries": { 
   
      "segments": { 
   
        // 该索引目前拥有的总段数
        "count": 169,
        // 该索引缓存在内存中字节数
        "memory_in_bytes": 4404644,
        // 倒排索引(term)缓存在内中所占字节数
        "terms_memory_in_bytes": 3723502,
        // 该索引定义为stored_fields字段在内存中缓存的字节数
        "stored_fields_memory_in_bytes": 574016,
        // 该索引term_vectors(词向量)在内存中所占字节数量
        "term_vectors_memory_in_bytes": 0,
        // 该索引存储对应norms=true的字段当前在内存中缓存字节数
        "norms_memory_in_bytes": 10816,
        // 与地理位置相关的缓存数据
        "points_memory_in_bytes": 67946,
        // 设置为doc_values缓存在内存中的字节数(doc_values,列式存储)
        "doc_values_memory_in_bytes": 28364,
        // 用于优化索引写的缓存(减少写磁盘的频率
        "index_writer_memory_in_bytes": 768320,
        // 关于文档的版本映射所占内存大小
        "version_map_memory_in_bytes": 0,
        // fixed_bit_set内存,专门用来做nested查询的
        "fixed_bit_set_memory_in_bytes": 0,
        // es内部当前的自增ID
        "max_unsafe_auto_id_timestamp": -1,
        "file_sizes": { 
   
        }
      }
    },
    "total": { 
   
      "segments": { 
   
        "count": 330,
        "memory_in_bytes": 8775500,
        "terms_memory_in_bytes": 7417480,
        "stored_fields_memory_in_bytes": 1147528,
        "term_vectors_memory_in_bytes": 0,
        "norms_memory_in_bytes": 21120,
        "points_memory_in_bytes": 136188,
        "doc_values_memory_in_bytes": 53184,
        "index_writer_memory_in_bytes": 768320,
        "version_map_memory_in_bytes": 0,
        "fixed_bit_set_memory_in_bytes": 0,
        "max_unsafe_auto_id_timestamp": -1,
        "file_sizes": { 
   
        }
      }
    }
  },
  "indices": { 
   
    "book-20210120": { 
   
      "uuid": "k43l2I4T2hCVYxgmvFb2Dy",
      "primaries": { 
   
        "segments": { 
   
          "count": 8,
          "memory_in_bytes": 247039,
          "terms_memory_in_bytes": 209657,
          "stored_fields_memory_in_bytes": 32272,
          "term_vectors_memory_in_bytes": 0,
          "norms_memory_in_bytes": 512,
          "points_memory_in_bytes": 3998,
          "doc_values_memory_in_bytes": 600,
          "index_writer_memory_in_bytes": 0,
          "version_map_memory_in_bytes": 0,
          "fixed_bit_set_memory_in_bytes": 0,
          "max_unsafe_auto_id_timestamp": -1,
          "file_sizes": { 
   
          }
        }
      },
      "total": { 
   
        "segments": { 
   
          "count": 17,
          "memory_in_bytes": 499726,
          "terms_memory_in_bytes": 422271,
          "stored_fields_memory_in_bytes": 65088,
          "term_vectors_memory_in_bytes": 0,
          "norms_memory_in_bytes": 1088,
          "points_memory_in_bytes": 8011,
          "doc_values_memory_in_bytes": 3268,
          "index_writer_memory_in_bytes": 0,
          "version_map_memory_in_bytes": 0,
          "fixed_bit_set_memory_in_bytes": 0,
          "max_unsafe_auto_id_timestamp": -1,
          "file_sizes": { 
   
          }
        }
      }
    },
    ...
  }
}

三、可选参数:include_segment_file_size

设置include_segment_file_size=true(默认为false),将输出每个Lucene索引文件的聚合磁盘使用情况 。

请求url

http://local.elasticsearch:9200/log-*/_stats/segments?include_segment_file_sizes

输出结果为

多出来了file_sizes 这个字段:

{ 
   
  "_shards": { 
   
    "total": 32,
    "successful": 32,
    "failed": 0
  },
  "_all": { 
   
    "primaries": { 
   
      "segments": { 
   
        "count": 164,
        "memory_in_bytes": 4387944,
        "terms_memory_in_bytes": 3711085,
        "stored_fields_memory_in_bytes": 572608,
        "term_vectors_memory_in_bytes": 0,
        "norms_memory_in_bytes": 10496,
        "points_memory_in_bytes": 67939,
        "doc_values_memory_in_bytes": 25816,
        "index_writer_memory_in_bytes": 826908,
        "version_map_memory_in_bytes": 756,
        "fixed_bit_set_memory_in_bytes": 0,
        "max_unsafe_auto_id_timestamp": -1,
        "file_sizes": { 
   
          "si": { 
   
            "size_in_bytes": 33165,
            "description": "Segment Info"
          },
          "fdx": { 
   
            "size_in_bytes": 523949,
            "description": "Field Index"
          },
          "tip": { 
   
            "size_in_bytes": 3315096,
            "description": "Term Index"
          },
          "tim": { 
   
            "size_in_bytes": 452588688,
            "description": "Term Dictionary"
          },
          "doc": { 
   
            "size_in_bytes": 149518168,
            "description": "Frequencies"
          },
          "fnm": { 
   
            "size_in_bytes": 415461,
            "description": "Fields"
          },
          "fdt": { 
   
            "size_in_bytes": 448491261,
            "description": "Field Data"
          },
          "dii": { 
   
            "size_in_bytes": 12674,
            "description": "Points"
          },
          "nvd": { 
   
            "size_in_bytes": 4001117,
            "description": "Norms"
          },
          "pos": { 
   
            "size_in_bytes": 99208713,
            "description": "Positions"
          },
          "dvm": { 
   
            "size_in_bytes": 352311,
            "description": "DocValues"
          },
          "dim": { 
   
            "size_in_bytes": 56562386,
            "description": "Points"
          },
          "dvd": { 
   
            "size_in_bytes": 368310527,
            "description": "DocValues"
          },
          "nvm": { 
   
            "size_in_bytes": 16400,
            "description": "Norms"
          }
        }
      }
    },
    "total": { 
   
      "segments": { 
   
        "count": 326,
        "memory_in_bytes": 8764533,
        "terms_memory_in_bytes": 7408968,
        "stored_fields_memory_in_bytes": 1146592,
        "term_vectors_memory_in_bytes": 0,
        "norms_memory_in_bytes": 20864,
        "points_memory_in_bytes": 136237,
        "doc_values_memory_in_bytes": 51872,
        "index_writer_memory_in_bytes": 1653816,
        "version_map_memory_in_bytes": 1512,
        "fixed_bit_set_memory_in_bytes": 0,
        "max_unsafe_auto_id_timestamp": -1,
        "file_sizes": { 
   
          "tim": { 
   
            "size_in_bytes": 905515161,
            "description": "Term Dictionary"
          },
          "si": { 
   
            "size_in_bytes": 64521,
            "description": "Segment Info"
          },
          "doc": { 
   
            "size_in_bytes": 299085852,
            "description": "Frequencies"
          },
          "fnm": { 
   
            "size_in_bytes": 826587,
            "description": "Fields"
          },
          "fdx": { 
   
            "size_in_bytes": 1048907,
            "description": "Field Index"
          },
          "dvm": { 
   
            "size_in_bytes": 701445,
            "description": "DocValues"
          },
          "dii": { 
   
            "size_in_bytes": 25194,
            "description": "Points"
          },
          "nvd": { 
   
            "size_in_bytes": 8002112,
            "description": "Norms"
          },
          "fdt": { 
   
            "size_in_bytes": 897083939,
            "description": "Field Data"
          },
          "nvm": { 
   
            "size_in_bytes": 32600,
            "description": "Norms"
          },
          "dim": { 
   
            "size_in_bytes": 113140814,
            "description": "Points"
          },
          "dvd": { 
   
            "size_in_bytes": 736628331,
            "description": "DocValues"
          },
          "tip": { 
   
            "size_in_bytes": 6630239,
            "description": "Term Index"
          },
          "pos": { 
   
            "size_in_bytes": 198247799,
            "description": "Positions"
          }
        }
      }
    }
  },
  ...
}

四、结果详情

1、_shards

分片信息:总数、成功返回数、失败返回数

2、_all

全局维度统计详情

  • primaries :主分片上的统计信息

  • total : 所有分片(主分片+副本分片)上的统计信息

3、indices

索引维度统计详情

THE END

发表回复