Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The REST API needs to add an endpoint and add adds a new field to an existing response bodyconfig option, metrics.scope.coordinator.

Proposed Changes

Thus, I propose a new REST API

Code Block
/jobs/<jobid>/vertices/<vertexid>/operators/<operatorid>/coordinator-metrics

with the query parameter get  that accepts comma separated metric names, like the other APIs. This path is based on https://github.com/apache/flink/blob/7bebd2d9fac517c28afc24c0c034d77cfe2b43a6/flink-runtime/src/main/java/org/apache/flink/runtime/metrics/dump/QueryScopeInfo.java#L234.

In addition, this needs to expose way for users to discover all the operator ids for the path parameter. Following the convention of vertex id and subtask index, the way to discover such information is the job graph that is returned by `/jobs/<jobid>/plan`.

Thus, I propose to add a new field in the response of the form

Code Block
/jobs/<jobid>/plan Response
{
	...
	"operators": [
		{
			"id": "1"
		},
		{
			"id": "2"
		},
		...
	]
}

`coordinator-metrics` makes it obvious that the metrics are from the OperatorCoordinator, not to be confused with something like `operator-metrics` (which operator is it?). This endpoint should also be integrated with the Flink UI.

In addition, I also propose to fix the metric scope [1]: 

  • metrics.scope.operator
    • Default: <host>.taskmanager.<tm_id>.<job_name>.<operator_name>.<subtask_index>
    • Applied to all metrics that were scoped to an operator.

The default should not contain the subtask index, since the coordinator does not correspond to a subtask index. In addition, this configuration could be renamed to `metrics.scope.coordinator` since `operator` is vague. While we will point to the new config in the docs, backward compatibility will be provided for the old config key.

[1] https://nightlies.apache.org/flink/flink-docs-master/docs/ops/metrics/#system-scopeIn addition, the internal JobManagerOperatorQueryScopeInfo  will need to support indexing by operator id, instead of operator name. The operator id uniquely identifies an operator and on the contrary, the operator name does not (it may be empty or repeated between operators by the user).

Compatibility, Deprecation, and Migration Plan

No compatibility concerns as this is introducing a new API without modifying older APIs. The code modifications are otherwise to internal code.

The change changes to the QueryScopeInfo is internal and is not expected to be breaking because we don't expose a method to query these metrics yet. The corresponding metric group for job manager operator metrics will not change either because it already attaches both operator name and operator id labelsThere is no backward incompatibility for the metric scope config.

Test Plan

Unit tests.

Rejected Alternatives

...

1. Exposing the operator id in the API. e.g. /jobs/<jobid>/vertices/<vertexid>/operators/<operatorid>/metrics.

2 considerations: 

1. Integrate Flink UI to show source coordinator metrics

The Flink UI currently doesn't expose per operator metrics, only task metrics. For operator metrics, metric reporters provide that extensibility to expose operator granularity metrics. So, the operator id is unnecessary for this case.

2. Integrate Flink Kubernetes Operator to read autoscaling metrics from source enumerator

The K8s operator currently reads vertex metrics from the Flink Metric REST API to perform autoscaling. In this situation, the operator id is unnecessary as well and in fact, a vertex can only contain 1 source. Therefore, we don't need a parameter for the operator id.