Good day to all, Started work recently with Apache Flink Stateful functions. We are using Flink reporter to put metrics to InfluxDB https://ci.apache.org/projects/flink/flink-docs-master/docs/deployment/metric_reporters/ Stateful functions provides "function" scope with several metrics out of the box https://ci.apache.org/projects/flink/flink-statefun-docs-release-2.2/deployment-and-operations/metrics.html but it's not enough and there is a need to add custom metrics and measurements. All source code seems to be closed to extention and I'm not able to find the proper way how to do this. Please share your experience if someone managed to complete this task.
The ability to add user defined metrics was added to the main branch recently for the embedded-functions SDK. See JIRA issue.
With that change, you can do something like this:
public class MyFn implements StatefulFunction {
@Override
public void invoke(Context context, Object input) {
if (isBadMessage(input)) {
context.metrics().counter("bad-message").inc();
} else {
processNormalMessage(context, input);
}
}
...
}
If you are using remote functions, then let the Apache Flink user mailing list know about it so that the maintainers consider expending the scope of that feature for remote functions as-well!
If you are in hurry, and feel comfortable of building the project yourself, you can try it out immediately.