[
https://issues.apache.org/jira/browse/BEAM-4178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16522460#comment-16522460
]
Scott Wegner commented on BEAM-4178:
------------------------------------
[~kenn] you are correct. The Beam metrics API design allows dynamically
creating and writing to any metric at runtime, and as a consequence the metric
names are not registered with Dataflow/Stackdriver until they are first written.
One workaround would be to create an {{InitCounters}} step at the top of your
pipeline which simply calls {{inc(0)}} once for each counter you want to
monitor in Stackdriver. In java:
{{Counter myCounter = Metrics.counter(MyPipeline.class, "myCounter");}}
{{ p.apply(Create.of("unused"))}}
{{ .apply(MapElements.into(TypeDescriptors.strings()).via(unused -> }}{{{}}
{{ }}{{ myCounter.inc(0);}}
{{}}{{ return unused;}}
{{ }}}{{);}}
Adding a few other people have been interested in this space: [~foegler]
[~pabloem] [~bchambers] [~echauchot]
> Metric doesn't appear until first changed
> -----------------------------------------
>
> Key: BEAM-4178
> URL: https://issues.apache.org/jira/browse/BEAM-4178
> Project: Beam
> Issue Type: Bug
> Components: beam-model, runner-dataflow, sdk-java-core
> Affects Versions: 2.4.0
> Environment: Java, DataflowRunner
> Reporter: Kevin Peterson
> Assignee: Scott Wegner
> Priority: Minor
>
> When defining a counter Metric, I've noticed that the Metric does not show up
> in the Dataflow UI (or stackdriver) until it is first incremented or
> decremented.
> Ideally, some initial value for the metric should be reported when the
> pipeline is started.
> The specific use case I have in mind is setting up a Stackdriver alert for a
> error condition in the pipeline. But because the metric doesn't show up until
> an error actually happens, I can't set the metric up in advance.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)