Status

Discussion Thread

https://lists.apache.org/thread/vsnhhoyxw8x2r8bwvdsyq4l1vxhry154

Vote Threadhttps://lists.apache.org/thread/pwfql3c8r5ljwd8j88yxw5gchcb6kmgq
JIRA

FLINK-39546 - Getting issue details... STATUS  

Target Release

FLINK - 2.4

Current State

Accepted


Motivation

"It's 2 AM. The on-call engineer wakes up to a pager. A streaming job that has been quietly running for six months suddenly stretches its checkpoint duration from 30 seconds to 12 minutes. Backpressure climbs. Watermarks lag. The dashboards show "checkpoint duration up", "checkpoint size unchanged", and nothing else. Was it the network? RocksDB? S3? They reach for tcpdump. They reach for AWS CloudTrail. They reach, eventually, for guesswork."

This FLIP is about that moment.


Apache Flink's filesystem layer is one of the most heavily used components. Every checkpoint, savepoint, file sink operator, and state download passes through it. The most predominantly used filesystem is S3 FS. And yet, when something goes wrong inside that layer, Flink tells the operator almost nothing. The metric surface today is dominated by aggregate file IO counters and after-the-fact checkpoint durations. There is no observability for:

  • whether S3 is throttling our job (HTTP 503 SlowDown).

  • whether our retries are masking real problems.

  • Which S3 operation is slow (PUT? CompleteMultipartUpload? GET range read?)

  • whether our entropy prefix is actually spreading the load.

  • whether we are leaking incomplete multipart uploads (a real, recurring cost issue).

  • whether NativeS3InputStream silently reopening because of intermittent EOFs.

  • Which P99 latency moved when our checkpoints regressed?

Every one of these has been the root cause of a real production incident. Today, finding any of them requires correlating Flink logs with CloudTrail, capturing TCP packets, or most often guessing. Operators of production Flink+S3 systems consistently report this as one of their top operational pain points. It is the gap between "Flink works" and "Flink is operable."

Goal

  1. Make S3 traffic from flink-s3-fs-native directly observable through Flink's existing metric system, with no additional dashboards or alerting pipelines.

  2. Surface a small, high-signal set of metrics that answers the operational questions above.

  3. Do this in a way that other filesystem plugins can adopt with the same plumbing so that other filesystems can also use it.

  4. Avoid two recurring failure modes in observability work: cardinality explosion and metric overhead that erodes the very performance we are trying to measure.

Non-Goal

  1. Replacing AWS CloudWatch or OpenTelemetry-based pipelines for users who already operate them.

  2. Rewriting the AWS SDK's instrumentation. 

  3. Per-checkpoint-correlated metrics ("which PUT belonged to checkpoint 42?"). Possible, but deferred to a follow-up FLIP — see the Open Questions section.

  4. flink-s3-fs-presto or flink-s3-fs-hadoop is out of scope. But the API change is designed to allow them to adopt it cleanly.

What's Required for Debugging (the working set of questions)

The metrics shipped by this FLIP must answer the following, in production, in real time:

Operational question

Metric this FLIP introduces

Label (default)

Are we being throttled by S3 right now?

throttle_count

s3n

Which operation is slow?

api_call_duration_ms{op} (P50/P95/P99)

s3n

Is our retry rate masking errors?

retry_count{reason}

s3n

Are we leaking incomplete MPUs?

mpu_aborted_total and mpu_in_flight

s3n

Is NativeS3InputStream Reopening a lot?

stream_reopen_count{reason}

s3n

Is our connection pool saturated?

connection_acquire_duration_ms

s3n

What's our actual S3 throughput?

bytes_{read,written}

s3n

Is the entropy prefix spreading the load?

entropy_bucket_count{prefix_hash} (opt-in)

s3n

Is the request getting throttled (503)?

iops

s3n

We deliberately do not attempt to answer everything possible. The chosen set is the smallest one that turns "the dashboard is not useful" into "the dashboard is enough."

Approaches considered

There is more than one defensible place to put this work. The decision matters because the code's home dictates its lifecycle, distribution, and the user experience for an operator who picks up the plugin tomorrow morning.

Approach A: Outside Flink, via AWS SDK v2 → CloudWatch (or OpenTelemetry)

AWS SDK v2 already ships a MetricPublisher SPI that emits structured metrics for every API call: operation name, duration, retries, HTTP status, and throughput. There are off-the-shelf publishers for CloudWatch and for OpenTelemetry exporters.

A user can wire S3AsyncClient.builder().overrideConfiguration(o -> o.addMetricPublisher(...)) and start collecting today, no Flink change needed.

Pros

Cons

Zero new code in Flink.

Operators run two parallel observability systems (Flink Prometheus + AWS CloudWatch).

Captures retries the application can't see.

No correlation with Flink concepts (jobID, checkpointID, subtask).

Vendor-neutral via OTel.

Plugin classloader does not control which MetricPublisher user wire for the out-of-the-box experience varies.

Maintained by AWS / OTel.

Adds operational complexity for users who don't already run a separate AWS pipeline.

This is a fine option for sophisticated AWS-native shops. It is a poor option for the average Flink user who has a Flink reporter wired into Prometheus and wants the data to land there, alongside watermarks and backpressure.

Wrap every FSDataInputStream and FSDataOutputStream returned from FileSystem in an instrumented decorator that times, reads, writes and reports through a standard MetricGroup.

Pros

Cons

Covers every filesystem plugin uniformly.

Captures only the stream surface — bytes, latency. Loses every S3-specific signal.

No public API change.

Adds overhead to the per-record path for all file systems, even local.

Operators get something for HDFS, Azure, GCS, and others, for free.

Cannot see retries, throttling, or multipart lifecycle. Exactly the high-value bits we set out to expose.

This approach answers a different question than the one operators are asking. It is the right answer to "how much do I read and write through Flink's FS layer?" It is not the right answer to "Why is my S3 traffic slow?"

Instrument the plugin manually: count every s3Client.putObject(...) call, time it, classify exceptions, expose counters and histograms.

Pros

Cons

Full control over metric semantics.

Reinvents what AWS SDK already publishes natively.

Plugin-local and no public-API change.

Misses retries done inside the SDK that never surface in our code.

Easy first version.

Code drift over time as the SDK adds new operations.

AWS SDK v2 makes most of it obsolete: the SDK already emits the right things, in the right shape, at the right granularity. We should consume that signal, not duplicate it.

Approach D: Bridge AWS SDK v2 MetricPublisher into Flink MetricGroup, with plugin-specific extensions on top

A two-layer design:

  1. Tier 1: Bridge. Implement an AwsSdkMetricBridge (a MetricPublisher) inside flink-s3-fs-native that consumes the SDK's MetricCollection and emits Flink Counter / Histogram / Gauge against a plugin-scoped MetricGroup.

  2. Tier 2: Flink-specific events. Instrument the things AWS SDK cannot see, because they are above the SDK layer: NativeS3InputStream reopens, the recoverable writer's multipart lifecycle, and (optionally) the entropy-prefix bucket distribution.

Pros

Cons

Reuses the SDK's existing instrumentation. No duplicated logic.

Requires a small additive change FileSystemFactory so plugins receive  MetricGroup at init time.

Metrics land in Flink's existing stack → same Grafana, same alerts.

Coupled to AWS SDK v2 metric keys (mitigated by an internal abstraction).

Plugin classloader keeps Flink's metric interfaces parent-loaded; isolation is preserved.

Slightly more design surface than (C).


[RECOMMENDED] Approach E: Bridge AWS SDK v2 MetricPublisher into Flink MetricGroup, via opt-in MetricsAware capability marker

suggested by Gabor Somogyi 

Approach E uses the same Tier 1 / Tier 2 bridge design as Approach D. An AwsSdkMetricBridge (MetricPublisher) inside flink-s3-fs-native translating SDK metric records into Flink Counter / Histogram / Gauge instances, plus plugin-local instrumentation for events the SDK cannot see. What differs is the SPI surface and the startup wiring.

Rather than extending the FileSystemFactory contract with a second configure(Configuration, MetricGroup) overload, we introduce a separate opt-in capability marker in org.apache.flink.core.plugin:


public interface MetricsAware {
    /**
     * Invoked at most once per instance, after Plugin.configure(Configuration)
     * and before any operation that would emit a metric. If never called, the
     * plugin must operate normally and emit no metrics.
     */
    void setMetricGroup(MetricGroup metricGroup);
}



FileSystemFactory itself does not change. Plugins that want metrics declare implements FileSystemFactory, MetricsAware. Plugins that don't are byte-for-byte unchanged.

A new idempotent static,FileSystem.attachMetrics(MetricGroup processMetricGroup), is invoked from each runtime entrypoint after MetricRegistry is constructed. It iterates registered factories and calls setMetricGroup on the MetricsAware ones. Entrypoints without a process-level MetricGroup (CliFrontend, HistoryServer, YARN client, SQL gateway) simply never call attachMetrics. Their plugins continue to operate without metrics, which is the correct behaviour for those contexts.

ProsCons
Matches Flink's actual startup ordering — MetricRegistry is constructed inside runTaskManager / initializeServices, after FileSystem.initialize has already run. A two-phase init is mandatory regardless; MetricsAware makes that explicit instead of hiding it.Two-phase init is a real contract that must be documented carefully on the marker Javadoc.
Existing third-party FileSystemFactory implementations need zero changes and don't need to recompile against a new default method.Discoverability is weaker than a method on FileSystemFactory; new plugin authors won't see the metric hook directly in the SPI. Mitigated by cross-references in the Javadoc and the plugin developer guide.
The marker is reusable: StateChangelogStorage, DelegationTokenProvider, RpcSystem have the same gap today and can adopt MetricsAware later without per-SPI churn.One instanceof check at registration time is mildly unaesthetic (one line in flink-core).
FileSystem.initialize remains a single-argument synchronous startup-time call; runtimes that don't have metrics don't pretend to.Naming/placement debate: MetricsAware is generic, must live in o.a.f.core.plugin to read naturally next to Plugin.

Approach E is the shape this FLIP proposes.

Recommended design WalkThrough

We will introduce three things:

  1. A small, additive change to the public FileSystemFactory interface so plugins can receive a MetricGroup at init time.

  2. An AwsSdkMetricBridge inside flink-s3-fs-native that registers as the SDK's MetricPublisher and translates SDK metric records into Flink metrics.

  3. A focused, cardinality-disciplined metric taxonomy.

Public interface change

We introduce a single opt in marker interface in org.apache.flink.core.plugin

package org.apache.flink.core.plugin;

import org.apache.flink.annotation.PublicEvolving;
import org.apache.flink.metrics.MetricGroup;

/**
 * Capability marker for plugins that want to register Flink metrics.
 *
 * <p>The runtime invokes {@link #setMetricGroup(MetricGroup)} at most once
 * per instance, after {@link Plugin#configure} and before any operation
 * that would emit a metric. Plugins that never receive this call must
 * continue to operate normally and emit no metrics.
 *
 * <p>The {@code MetricGroup} is owned by the runtime; plugins must not
 * close it. They may call {@code addGroup} on it freely to build nested
 * label scopes.
 */
@PublicEvolving
public interface MetricsAware {
    void setMetricGroup(MetricGroup metricGroup);
}

FileSystemFactory is unchanged. Plugins that want metrics declare:


public final class NativeS3FileSystemFactory
        implements FileSystemFactory, MetricsAware {
    @Override public void configure(Configuration config) { /* unchanged */ }
    @Override public void setMetricGroup(MetricGroup mg) { /* see "The bridge" */ }
    @Override public FileSystem create(URI uri) { /* unchanged */ }
}




A new static on FileSystem invokes the marker once MetricRegistry exists:


public static void attachMetrics(MetricGroup processMetricGroup);




Contract:

  • Idempotent. Invoking twice with the same MetricGroup is a no-op; invoking with a different group rebuilds the per-FS scope.
  • Iterates registered factories and calls setMetricGroup only on those implementing MetricsAware.
  • Safe to omit from runtimes that have no process-level MetricGroup.

Existing plugin implementations require zero modifications. The single-argument configure(Configuration) and FileSystem.initialize(Configuration, PluginManager) remain untouched. There is no deprecation.

Metric scoping and labels

The metric name describes what is being measured (api_call_count, throttle_count, bytes_read). A filesystem_type label describes which filesystem produced it (s3n, s3, gs, …). Keeping these dimensions separate is the difference between a dashboard that survives the next filesystem joining this plumbing and one that does not.                        
The plugin derives a labelled scope from the MetricGroup it received via configure(Configuration, MetricGroup) before registering any metric:                                  


 final String scheme = factory.getScheme();              // "s3n" for flink-s3-fs-native                                                                                        
 final MetricGroup fsScope = pluginMetrics.addGroup("filesystem_type", scheme);     


Every counter, histogram, and gauge defined is registered against fsScope. The label is set once per plugin instance and propagates to every metric. 
                                                                                                                                                       
Usage with Prometheus 

  flink_taskmanager_filesystem_api_call_count{filesystem_type="s3n", op="PutObject"}
  flink_taskmanager_filesystem_throttle_count{filesystem_type="s3n", op="PutObject"}                                                                                             
  flink_taskmanager_filesystem_bytes_read{filesystem_type="s3n"}

                                                                                                                                                                                
Other reporters apply the same labelling: JMX exposes filesystem_type as a key on the ObjectName. Structured reporters such as InfluxDB and OpenTelemetry carry it as a tag.   

The bridge


public final class NativeS3FileSystemFactory
        implements FileSystemFactory, MetricsAware {

    // populated by setMetricGroup; null until attachMetrics fires
    private volatile MetricGroup pluginMetrics;

    @Override
    public void setMetricGroup(MetricGroup mg) {
        // Stable label that survives across reporter changes; "s3n" today,
        // future siblings register the same label with their own scheme.
        this.pluginMetrics = mg.addGroup("filesystem_type", getScheme());
    }

    @Override
    public FileSystem create(URI uri) {
        final AwsSdkMetricBridge bridge =
                pluginMetrics != null
                        ? new AwsSdkMetricBridge(pluginMetrics)
                        : AwsSdkMetricBridge.NOOP;
        final S3AsyncClient client = S3AsyncClient.builder()
                .overrideConfiguration(o -> o.addMetricPublisher(bridge))
                ...
                .build();
        ...
    }
}


The bridge is constructed lazily on create(URI), so it always observes the post-attachMetrics state of pluginMetrics. 
If attachMetrics is never called (CLI, embedded usage), the bridge is the no-op variant: the hot path stays branch-free and the SDK's publisher chain stays empty.

The bridge consumes MetricCollection records emitted by the SDK after every API call. It pulls a small, fixed set of fields:

SDK metric

Flink metric

Notes

CoreMetric.OPERATION_NAME

label op

bounded set (~15 values)

CoreMetric.API_CALL_DURATION

api_call_duration_ms{op} (Histogram)


CoreMetric.API_CALL_SUCCESSFUL

partitions api_call_count{op,status_class}


HttpMetric.HTTP_STATUS_CODE

classified into {2xx, 4xx, 5xx, throttled}

Classify, do not expose raw code

CoreMetric.RETRY_COUNT

retry_count{op,reason}

reason from a closed enum

HttpMetric.MAX_RETRY_EXCEEDED

feeds max_retries_exceeded_total


CoreMetric.SERVICE_ID (= "S3")

filtering only

not exposed as a label

The bridge holds bounded Counter and Histogram instances (one per operation, prepared up front), so the hot path is a bounded Map lookup followed by a counter increment. There is no allocation per metric record.

Plugin-specific extensions (Tier 2)

Two things matter to operators that the SDK cannot see, because they live one layer above the SDK:

  1. NativeS3InputStream reopens. When the input stream encounters EOF or a transient IOException mid-read, it reopens the underlying GET with an updated range. This event is invisible to the SDK (the SDK sees the new GET as a fresh call). We add flink_fs_s3n_stream_reopen_count{reason} and flink_fs_s3n_stream_reopen_latency_ms.

  2. Recoverable writer / multipart lifecycle. Each call site of RecoverableWriter.open / persist / closeForCommit / commit / commitAfterRecovery / discard is a state transition: in-progress → pending → committed (or aborted). We track these as Counters. The most operationally important one is mpu_aborted_total: aborted MPUs accumulate parts in the bucket and incur cost until the bucket lifecycle policy reaps them.

The metric surface (v1)

Name

Type

Labels

What it answers

Example Failures Surfaced

api_call_count

Counter

{op, status_class}

Baseline traffic + success/failure split

status_class="4xx" rate suddenly grows → an IAM policy change broke object access for a subset of operations.

api_call_duration_ms

Histogram

{op}

P50/P95/P99 latency, per-operation

P99 of PutObject rises from 80 ms to 4s when the bucket's region experiences degraded write latency.

retry_count

Counter

{op, reason}

Retry storms attribution

reason="throttled" climbs in step with throttle_count — retries are masking SlowDown, not transient network errors.

throttle_count

Counter

{op}

"Are we throttled?" — the most-asked question

Spikes when a job's PUT rate during checkpoint barrier alignment exceeds the per-prefix S3 request-rate limit.

max_retries_exceeded_total

Counter

{op}

Final failures after retry exhaustion

Becomes non-zero when a checkpoint subtask sees user-visible IO failures →  typically pages on-call.  

bytes_read

Counter

—

Bandwidth

Recovery downloads 50 GB of state, but bytes_read reports only 2 GB → reopens or partial reads, not a bandwidth issue. 

bytes_written

Counter

—

Bandwidth

Sustained drop while the job is running flags a stuck sink or a failing checkpoint barrier.

mpu_initiated_total

Counter

—

MPU lifecycle

Sudden spike correlated with raised sink parallelism — too many concurrent file parts for the upload pool.

mpu_completed_total

Counter

—


Falls behind mpu_initiated_total when CompleteMultipartUpload is slow — the writer opens uploads faster than S3 closes them.

mpu_aborted_total

Counter

—

Cost-impacting leaks

Increments when a TaskManager crashes mid-checkpoint, leaving orphan parts in the bucket until the lifecycle policy reaps them. 

mpu_in_flight

Gauge

—

Capacity

Sits at 0 in a healthy job between checkpoints; a non-zero baseline means commits are stuck and parts are accumulating. 

mpu_complete_duration_ms

Histogram

—

Slowest typical operation

P99 climbs to multi-second when CompleteMultipartUpload becomes the dominant contributor to checkpoint duration.

stream_reopen_count

Counter

{reason}

Detect flaky reads

reason="eof" spikes on a deployment behind an ELB that resets idle TCP connections after 60s. 

active_streams

Gauge

{kind=in/out}

Pool sizing

Plateaus near http-client.max-concurrency → reader-side starvation. raise starvation. Raise the cap or split the workload. 

connection_acquire_duration_ms

Histogram

—

Detect pool saturation

Jumps from microseconds to hundreds of milliseconds when parallelism × concurrent requests exceeds the HTTP connection-pool size. 

entropy_bucket_count

Counter

{prefix_hash}

Verify entropy works (opt-in)

All traffic hashes to 2 of 16 prefixes → entropy length is too short, and one S3 partition is hot.   

iops

derived rate from api_call_count


Is the request rate the bottleneck, not bandwidth? 

Hits a non-AWS S3-compatible store's request-rate ceiling while bandwidth stays low.

bucket_size_bytes

Histogram


Detect "many small files" 

P50 in single-digit KB with high api_call_count → small-file storm; recovery time is dominated by per-request overhead.

Cardinality discipline (a hard constraint)

This is where well-intended observability features turn into outages. The rules are simple:

  • Never label with a bucket name unless an operator opts in via s3.metrics.detailed.enabled.

  • Never label with key, prefix, or object name. Period.

  • Never label with full HTTP status; use a four-value classifier.

  • Always label with operation name (closed set, ≤ 15 distinct values for S3).

  • Retry reason is a closed enum: {throttled, timeout, conn_reset, 5xx, other}.

  • The opt-in prefix_hash for entropy verification uses a fixed-size hash modulo a small constant (default 16) so that no matter how many entropy values are generated, the cardinality is bounded.

Configuration

We resist the temptation to add many flags. The configuration surface is:

s3.metrics.enabled: true                # default true
s3.metrics.allowlist:                
     - api_call_count                                                                                                                                                          
     - api_call_duration_ms                                                                                                                                                    
     - throttle_count                                                                                                                                                          
     - retry_count                                                                                                                                                              
     - iops                                                                                                                                                                    
     - mpu_aborted_total
s3.metrics.detailed.enabled: false      # opt-in: bucket label, request-size hist
s3.metrics.histogram.window-size: 1024  # reservoir size; bounds memory
s3.metrics.entropy-bucket.cardinality: 16  # hash modulo for entropy verification
s3.metrics.enabled: true ships out of the box because the v1 surface is cheap. Detailed mode is opt-in because it widens cardinality.

Failure scenarios

SL.NO

Scenario

Effect

Mitigation

1

The metric backend is down.

MetricGroup calls become no-ops or fail.

Flink's reporter framework already isolates reporters; an exception in a reporter does not propagate to the metric source. The bridge wraps its publish path in a try-catch as a defence in depth. IO is never affected.

2

The AWS SDK upgrades and renames metric keys.

Some metrics stop being populated.

The bridge reads CoreMetric.X constants by class reference, so a renamed constant is a compile-time break, not a silent regression. CI integration test runs against the SDK version we ship; an unexpected silence in the test fails the build.

3

Cardinality blowup despite our rules.

Memory and time-series count grow unbounded.

Closed-set operation enum; status code is classified, not raw; entropy hash modulo. Cardinality test in CI asserts an upper bound.

4

High-QPS workload (10k+ ops/sec) overwhelms histograms.

Reservoir sampling skews; CPU goes up.

Reservoir size is fixed at 1024 by default; the update(long) call is O(1) using Flink's existing histogram implementations. Internal benchmark target: ≤ 1 % CPU overhead at 10k ops/sec on a single TM.

5

Plugin classloader can't see MetricGroup.

NoClassDefFoundError at plugin init.

org.apache.flink.metrics is already on the parent allowlist. ArchUnit rule guards against reaching beyond that.

6

Two filesystem instances were created in the same component.

Metric registration conflict on duplicate names.

Plugin scopes metrics under <component>.filesystem.<scheme>.<authority_or_default>. FileSystem.get(URI) already deduplicates per (scheme, authority), so this is naturally bounded.

7

Operator sets s3.metrics.detailed.enabled=true on a job that touches thousands of buckets.

Cardinality blowup (opt-in).

Documentation flags this loudly. Detailed mode is off by default.

8

The bridge holds references that prevent the classloader unload.

On dynamic plugin reload (rare), classloader leak.

FileSystem.initialize clears the FS cache and unregisters metric groups before reloading. We add a corresponding close() on the bridge.

Performance considerations

SDK publishing path. AWS SDK v2 calls MetricPublisher#publish asynchronously, after the response has completed, on the SDK's internal completion executor. The bridge does roughly:

- 1 enum lookup to map operation name → Counter
- 1 enum lookup to classify status code
- 1 to 3 counter increments (api_call_count, retry_count if any, throttle_count if any)
- 1 histogram update (api_call_duration_ms)

In a microbenchmark on a typical x86 host, this is on the order of a few hundred nanoseconds per API call. At 10,000 API calls per second on a single TaskManager, that is well under 1 % of one CPU. AWS SDK's own publishing overhead dominates ours.

Stream-level instrumentation. The reopen counter on NativeS3InputStream and the lifecycle counters on the recoverable writer are single counter increments at events that occur on the order of seconds, not milliseconds. The cost is immeasurable.

Memory. Sixteen metrics, ~50 time series, histogram reservoirs of 1024 longs each → a few hundred kilobytes per TaskManager. This is a rounding error against any real Flink JVM.

What we explicitly avoided. We did not put metrics on every read() or write() byte; we did not allocate a wrapper object per IO; we did not introduce a new background thread.

Gains and losses

Gains.

  • Operators can answer the working set of S3 questions in real time.

  • Same observability stack as the rest of Flink — one Grafana, one alerting pipeline.

  • Lays the foundation for the rest of the filesystem plugin family (Hadoop S3, Azure, GCS, OSS) to adopt the same plumbing.

  • Closes a recurring gap that today is filled by guesswork, CloudTrail, and tcpdump.

Losses/costs.

  • One additive public-API change to FileSystemFactory to maintain.

  • A small amount of code coupling to AWS SDK v2 metric key names. Mitigated by an internal abstraction.

  • Marginally larger plugin JAR (~tens of kilobytes).

Net. The gains are operational. The losses are surface-level engineering costs. The gains far exceed the losses.

Compatibility, deprecation, migration

Source / binary compatibility. Additive MetricsAware marker in org.apache.flink.core.plugin. Existing FileSystemFactory implementations (in-tree and third-party) are byte-for-byte unchanged; they do not need to recompile. FileSystem.initialize(Configuration, PluginManager) is unchanged.

API additions. One new interface (MetricsAware) and one new static method (FileSystem.attachMetrics(MetricGroup)). No removals.

Behavioural compatibility. A plugin that does not implement MetricsAware continues to behave exactly as today. An operator upgrading Flink with no other change sees flink-s3-fs-native metrics appear automatically when running under TM / JM entrypoints (which now invoke attachMetrics). Metrics are absent from CLI / HistoryServer / YARN-client contexts, which matches the current state of the world.

Deprecation. None.

Migration plan. Nothing to migrate from. Operators on flink-s3-fs-hadoop / -presto see no change until those plugins opt into MetricsAware (out of scope here).

Test plan

  1. Unit tests. The bridge's translation logic from MetricCollection Flink counters are pure. We test it with synthetic MetricCollection instances covering each operation type, status class, and retry path.
  2. Cardinality bounds. A focused unit test asserts that exercising the bridge with 10,000 distinct keys, buckets, and statuses produces no more than the documented number of time series.
  3. Integration test against MinIO. A flink-fs-tests-style integration test runs a small streaming job with checkpointing onto MinIO, then asserts that the expected metrics are present with non-zero values. This also catches AWS SDK upgrade regressions because the SDK's metric keys are validated end-to-end.
  4. Failure injection. A second integration test runs against MinIO with a fault-injection proxy that returns 503 SlowDown on a configurable fraction of requests; the test asserts that throttle_count and retry_count{reason=throttled} increment, and that the IO succeeds.
  5. Performance test. A benchmark  flink-benchmarks measures the per-API-call overhead of the bridge. Acceptance bar: ≤ 1 % CPU overhead at 10k ops/sec.


Open questions for community discussion

  1. Should s3.metrics.enabled default to true or false?

    The v1 surface is cheap. Defaulting  true gives every user the value automatically. Defaulting to it false is more conservative but trades operational benefit for a config knob nobody will know to flip. My preference is to set to true.

  2. Per-checkpoint correlation.
    Some operators want to know which PUT belonged to which checkpoint. This requires propagating  ThreadLocal<CheckpointId> through the snapshot path and into the SDK's request execution chain, plus a corresponding label on the metrics. It is feasible, but doubles the design surface. Author's preference: defer to a successor FLIP.

APPENDIX

Appendix A: Worked example

Suppose a job that has been running fine starts seeing checkpoints stretch from 30 seconds to 12 minutes overnight. With this FLIP shipped, the operator's investigation looks like:

  1. Open the Flink dashboard. The flink_fs_s3_native_throttle_count rate is up 50× compared to last week.

  2. api_call_duration_ms{op="UploadPart"} P99 has gone from 200 ms to 9s.

  3. retry_count{op="UploadPart", reason="throttled"} is climbing in step.

In ten seconds, the operator knows the cause is S3 throttling on multipart uploads. They check whether entropy is configured, the entropy_bucket_count distribution should be flat across hashes and it is not; one bucket dominates. They tune the entropy length, redeploy, and the regression resolves.

This sequence, today, would take hours and require a CloudTrail dump.

Appendix B: Worked example for cost

The same job, two weeks later, generates a cost alert. The bucket has accumulated 2 TB of "incomplete multipart upload" parts that the lifecycle policy hasn't reaped yet. With this FLIP:

  • mpu_initiated_total − mpu_completed_total − mpu_aborted_total per minute is the rate of "leaked" MPUs.

  • A simple Prometheus alert triggers when that rate is positive for more than five minutes.

The leak is caught the moment it happens, not when AWS bills.