cuba-platform / fts

Full-Text Search Addon
https://www.cuba-platform.com/
Apache License 2.0
4 stars 1 forks source link

Expose FTS index statistics through jmx #23

Open haulmont-git opened 6 years ago

haulmont-git commented 6 years ago

Currently as I know there is no out-of-the-box way to determine number of entities indexed.

In Sherlock we have created a JMX bean factory for monitoring purposes. It can be useful for any CUBA application which uses FTS.

FtsEntityTypeStatistics bean factory works on server start. It creates a jmx bean for every indexed entity. Such templated jmx beans can be used e.g. by Zabbix "discovery rules" to dynamically discover attributes by MBean name template.

Jmx bean has two parameters: NumExisting and NumActive.

NumExisting can be simply determined as count(*) from entity_table. For entities with "searchableIf" it will be incorrect, so for accurate estimation here an extension point would be useful.

NumIndexed can easily be determined by this code:

     Directory directory = ftsManager.getDirectory();
     DirectoryReader reader = DirectoryReader.open(directory);
     Term term = new Term(Lucene.FLD_ENTITY, entityName);
     long result = reader.docFreq(term);

!image.png!


Original issue: https://youtrack.haulmont.com/issue/PL-10609

stekolschikov commented 5 years ago

Also it can be very usefull to have an attribute associated with the current length of the sys_fts_queue table