abhishekrb19 commented on code in PR #19114:
URL: https://github.com/apache/druid/pull/19114#discussion_r2914403425
##########
indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManager.java:
##########
@@ -88,6 +90,37 @@ public Set<String> getSupervisorIds()
return supervisors.keySet();
}
+ @Override
+ public Collection<SupervisorStatsProvider.SupervisorStats>
getSupervisorStats()
+ {
+ List<SupervisorStatsProvider.SupervisorStats> stats = new ArrayList<>();
+ for (Map.Entry<String, Pair<Supervisor, SupervisorSpec>> entry :
supervisors.entrySet()) {
+ final String supervisorId = entry.getKey();
+ final Supervisor supervisor = entry.getValue().lhs;
+ final SupervisorSpec spec = entry.getValue().rhs;
+
+ SupervisorStateManager.State state = supervisor.getState();
+ String stateStr = state != null && state.getBasicState() != null
+ ? state.getBasicState().toString()
+ : "UNKNOWN";
+ String dataSource = DefaultQueryMetrics.getTableNamesAsString(
+ new HashSet<>(spec.getDataSources() != null ? spec.getDataSources()
: Collections.emptyList())
+ );
+ String stream = spec.getSource();
+ String detailedState = state != null ? state.toString() : null;
+
+ stats.add(new SupervisorStatsProvider.SupervisorStats(
+ supervisorId,
+ spec.getType(),
+ stateStr,
+ dataSource,
+ stream,
+ detailedState
+ ));
+ }
Review Comment:
nit:
1. we can inline these and cleanup the variables above since they're not
reused
2. `SupervisorSpec.getDatasources()` doesn't return
[null](https://github.com/apache/druid/blob/master/server/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorSpec.java#L55)
(validations exist at the time of create/update of supervisors)
```suggestion
stats.add(new SupervisorStatsProvider.SupervisorStats(
spec.getId(),
spec.getType(),
state == null ? "UNKOWN" : state.getBasicState().toString(),
DefaultQueryMetrics.getTableNamesAsString(spec.getDataSources()),
spec.getStream(),
state == null ? "UNKNOWN" : state.toString()
));
```
##########
extensions-contrib/prometheus-emitter/src/main/resources/defaultMetrics.json:
##########
@@ -149,6 +149,7 @@
"task/running/count" : { "dimensions" : ["dataSource"], "type" : "count",
"help": "Number of current running tasks."},
"task/pending/count" : { "dimensions" : ["dataSource"], "type" : "count",
"help": "Number of current pending tasks."},
"task/waiting/count" : { "dimensions" : ["dataSource"], "type" : "count",
"help": "Number of current waiting tasks."},
+ "supervisor/count" : { "dimensions" : ["supervisorId", "type", "state"],
"type" : "gauge", "help": "Count of active supervisors. Each supervisor emits
1, tagged with its state. Available only if the SupervisorStatsMonitor module
is included."},
Review Comment:
Perhaps it's useful to add `detailedState` by default:
```suggestion
"supervisor/count" : { "dimensions" : ["supervisorId", "type", "state",
"detailedState"], "type" : "gauge", "help": "Count of active supervisors. Each
supervisor emits 1, tagged with its state. Available only if the
SupervisorStatsMonitor module is included."},
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]