Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats: Make "groups" and "types" accept wildcards #6360

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.metrics.CounterMetric;
import org.elasticsearch.common.metrics.MeanMetric;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.indexing.slowlog.ShardSlowLogIndexingService;
Expand Down Expand Up @@ -63,17 +64,17 @@ public IndexingStats stats(String... types) {
IndexingStats.Stats total = totalStats.stats();
Map<String, IndexingStats.Stats> typesSt = null;
if (types != null && types.length > 0) {
typesSt = new HashMap<>(typesStats.size());
if (types.length == 1 && types[0].equals("_all")) {
typesSt = new HashMap<>(typesStats.size());
for (Map.Entry<String, StatsHolder> entry : typesStats.entrySet()) {
typesSt.put(entry.getKey(), entry.getValue().stats());
}
} else {
typesSt = new HashMap<>(types.length);
for (String type : types) {
StatsHolder statsHolder = typesStats.get(type);
if (statsHolder != null) {
typesSt.put(type, statsHolder.stats());
for (Map.Entry<String, StatsHolder> entry : typesStats.entrySet()) {
for (String type : types) {
if (Regex.simpleMatch(type, entry.getKey())) {
typesSt.put(entry.getKey(), entry.getValue().stats());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.metrics.CounterMetric;
import org.elasticsearch.common.metrics.MeanMetric;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.search.slowlog.ShardSlowLogSearchService;
import org.elasticsearch.index.settings.IndexSettings;
Expand Down Expand Up @@ -61,17 +62,17 @@ public SearchStats stats(String... groups) {
SearchStats.Stats total = totalStats.stats();
Map<String, SearchStats.Stats> groupsSt = null;
if (groups != null && groups.length > 0) {
groupsSt = new HashMap<>(groupsStats.size());
if (groups.length == 1 && groups[0].equals("_all")) {
groupsSt = new HashMap<>(groupsStats.size());
for (Map.Entry<String, StatsHolder> entry : groupsStats.entrySet()) {
groupsSt.put(entry.getKey(), entry.getValue().stats());
}
} else {
groupsSt = new HashMap<>(groups.length);
for (String group : groups) {
StatsHolder statsHolder = groupsStats.get(group);
if (statsHolder != null) {
groupsSt.put(group, statsHolder.stats());
for (Map.Entry<String, StatsHolder> entry : groupsStats.entrySet()) {
for (String group : groups) {
if (Regex.simpleMatch(group, entry.getKey())) {
groupsSt.put(entry.getKey(), entry.getValue().stats());
}
}
}
}
Expand Down