# How to access the Metric Data which is getting generated using java SDK

**URL:** <https://community.temporal.io/t/how-to-access-the-metric-data-which-is-getting-generated-using-java-sdk/502>\
**Category:** Community Support\
**Tags:** java-sdk, helm, metrics\
**Created:** [August 21, 2020, 9:32am UTC](https://community.temporal.io/t/how-to-access-the-metric-data-which-is-getting-generated-using-java-sdk/502 "2020-08-21T09:32:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![techFool](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@techFool](https://community.temporal.io/u/techFool)\
**Post date:** [August 21, 2020, 9:32am UTC](https://community.temporal.io/t/how-to-access-the-metric-data-which-is-getting-generated-using-java-sdk/502/1 "2020-08-21T09:32:33Z")

</div>

Experts,

How can we access the temporal data which is generating the Metrics. I am trying to access the Metric using Java SDK by using this link [How to enable Metrics Support using JAVA SDK](https://community.temporal.io/t/how-to-enable-metrics-support-using-java-sdk/366)

TIA

---

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [August 21, 2020, 9:28pm UTC](https://community.temporal.io/t/how-to-access-the-metric-data-which-is-getting-generated-using-java-sdk/502/3 "2020-08-21T21:28:28Z")

</div>

You need to do something like this:

```java
    new WorkflowServiceStubsImpl(null, WorkflowServiceStubsOptions
                    .newBuilder()
                    .setChannel(channel)
                    .setRpcTimeout(rpcTimeout)
                    .setQueryRpcTimeout(queryRpcTimeout)
                    **.setMetricsScope(StatsDMetricsScopeFactory.getStatsDMetricScope("PROD"))**
                    .build());

```

Inside the metric Scope you need to create a  
import com.uber.m3.tally.StatsReporter so it can connect to your statsD or other metrics client

```java
public static Scope getStatsDMetricScope(String environment) {
        StatsDClient statsDClient =
                new NonBlockingStatsDClient(
                        environment /* metrics prefix */,
                        "127.0.0.1" /* statsD server hostname */,
                        8125 /* statsD port */);
        StatsReporter statsReporter = new StatsDReporter(statsDClient);
        return new RootScopeBuilder()
                .reporter(statsReporter)
                .reportEvery(Duration.ofSeconds(10));
    }

```
