title: Labeling Google Cloud Dataflow job using Apache Beam
body: <p>I am working on a Dataflow pipeline using Apache Beam to read some data streams and wondering how to label the Dataflow job in Google Cloud Platform. There exists method <code>void setLabels(Map&lt;String, String&gt; labels)</code> in the  <code>DataflowPipelineOptions</code>-class but I am not sure how to use the method.</p>
  <p>Using <code>setLabels()</code> the following way is apparently wrong:</p>
  <pre><code>        PipelineOptionsFactory.register(DataflowPipelineOptions.class);
  
          Map&lt;String, String&gt; labels = null;
          labels.put(&quot;env&quot;, &quot;dev&quot;);
          
          PipelineOptions options = PipelineOptionsFactory
                  .fromArgs(args)
                  .withValidation()
                  .as(DataflowPipelineOptions.class)
                  .setLabels(labels);
      
          options.setRunner(DataflowRunner.class);
      
          Pipeline pipeline = Pipeline.create(options);
  </code></pre>
  <p>I would appreciate some help regarding usage of <code>DataflowPipelineOptions</code> and labeling of a Dataflow job. Thanks in advance.</p>