Versions Compared

Key

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

...

Page properties


Discussion threadhere (<- link to https://lists.apache.org/list.html?dev@flink.apache.org)/thread/tt0hf6kf5lcxd7g62v9dhpn3z978pxw0
Vote threadhere (<- link to https://lists.apache.org/list.html?dev@flink.apache.org)/thread/whrng29fnrpzmyjwr882jl9cqjz8ykh8
JIRA

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyFLINK-34064

Release<Flink Version>


...

These APIs allow external services to fetch, for example, subtask metrics to do analysis. The coordinator metrics are also an essential set of metrics for jobs that expose how a job is behaving. Currently, the main clients of these REST APIs are the Web UI and the Kubernetes Operator.

Public Interfaces

The REST API needs to change to support thisadd an endpoint and adds a new config 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.

Response

Code Block
[
	{
		"id": "<source_name>.<metric_name1>"
 	},
	{
		"id": "<source_name>.<metric_name2>"
	},
	...
	
]

This response is consistent with other APIs and extends from the same utility classes (AbstractMetricsHandler).

`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-scope

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 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. There 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 idNone.