diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5f9417130cc..b3ce30cbf08 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -183,6 +183,8 @@ New Features * SOLR-10076: Hide keystore and truststore passwords from /admin/info/* outputs. (Mano Kovacs via Mark Miller) +* SOLR-10224: Add disk total and disk free metrics. (ab) + Bug Fixes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index 2da48b828e3..9e22f91b49c 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -530,7 +530,8 @@ public class CoreContainer { containerProperties.putAll(cfg.getSolrProperties()); - // initialize gauges for reporting the number of cores + // initialize gauges for reporting the number of cores and disk total/free + String registryName = SolrMetricManager.getRegistryName(SolrInfoMBean.Group.node); metricManager.registerGauge(registryName, () -> solrCores.getCores().size(), true, "loaded", SolrInfoMBean.Category.CONTAINER.toString(), "cores"); @@ -538,6 +539,10 @@ public class CoreContainer { true, "lazy",SolrInfoMBean.Category.CONTAINER.toString(), "cores"); metricManager.registerGauge(registryName, () -> solrCores.getAllCoreNames().size() - solrCores.getCoreNames().size(), true, "unloaded",SolrInfoMBean.Category.CONTAINER.toString(), "cores"); + metricManager.registerGauge(registryName, () -> cfg.getCoreRootDirectory().toFile().getTotalSpace(), + true, "totalSpace", SolrInfoMBean.Category.CONTAINER.toString(), "fs"); + metricManager.registerGauge(registryName, () -> cfg.getCoreRootDirectory().toFile().getUsableSpace(), + true, "usableSpace", SolrInfoMBean.Category.CONTAINER.toString(), "fs"); if (isZooKeeperAware()) { metricManager.loadClusterReporters(cfg.getMetricReporterPlugins(), this); diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index bc41b1900f0..6e25280c653 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -30,6 +30,8 @@ import java.lang.reflect.Constructor; import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -1137,6 +1139,11 @@ public final class SolrCore implements SolrInfoMBean, SolrMetricProducer, Closea manager.registerGauge(registry, () -> getIndexSize(), true, "sizeInBytes", Category.INDEX.toString()); manager.registerGauge(registry, () -> NumberUtils.readableSize(getIndexSize()), true, "size", Category.INDEX.toString()); manager.registerGauge(registry, () -> coreDescriptor.getCoreContainer().getCoreNames(this), true, "aliases", Category.CORE.toString()); + // initialize disk total / free metrics + Path dataDirPath = Paths.get(dataDir); + File dataDirFile = dataDirPath.toFile(); + manager.registerGauge(registry, () -> dataDirFile.getTotalSpace(), true, "totalSpace", Category.CORE.toString(), "fs"); + manager.registerGauge(registry, () -> dataDirFile.getUsableSpace(), true, "usableSpace", Category.CORE.toString(), "fs"); } private Map initInfoRegistry(String name, SolrConfig config) { diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java index 846e805cf68..0c3b651a573 100644 --- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java +++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrClusterReporter.java @@ -106,10 +106,12 @@ public class SolrClusterReporter extends SolrMetricReporter { add("os\\.FreeSwapSpaceSize"); add("os\\.OpenFileDescriptorCount"); add("threads\\.count"); - }})); // all metrics - // XXX anything interesting here? - //add(new SolrReporter.Specification(OVERSEER_GROUP, "node", SolrMetricManager.overridableRegistryName(SolrInfoMBean.Group.node.toString()), - // Collections.emptySet())); // all metrics + }})); + add(new SolrReporter.Report(CLUSTER_GROUP, "node", SolrMetricManager.overridableRegistryName(SolrInfoMBean.Group.node.toString()), + new HashSet() {{ + add("CONTAINER\\.cores\\..*"); + add("CONTAINER\\.fs\\..*"); + }})); add(new SolrReporter.Report(CLUSTER_GROUP, "leader.$1", "solr\\.collection\\.(.*)\\.leader", new HashSet(){{ add("UPDATE\\./update/.*"); diff --git a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java index 2b202749504..8b36d3e0c96 100644 --- a/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java +++ b/solr/core/src/java/org/apache/solr/metrics/reporters/solr/SolrShardReporter.java @@ -61,9 +61,10 @@ public class SolrShardReporter extends SolrMetricReporter { public static final List DEFAULT_FILTERS = new ArrayList(){{ add("TLOG.*"); + add("CORE\\.fs.*"); add("REPLICATION.*"); - add("INDEX.flush.*"); - add("INDEX.merge.major.*"); + add("INDEX\\.flush.*"); + add("INDEX\\.merge\\.major.*"); add("UPDATE\\./update/.*requests"); add("QUERY\\./select.*requests"); }};