# Unable to view prometheus metrics using Spring boot 3

**URL:** <https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819>\
**Category:** Community Support\
**Tags:** java-sdk, prometheus, metrics\
**Created:** [July 13, 2023, 4:23am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819 "2023-07-13T04:23:38Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 13, 2023, 4:23am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/1 "2023-07-13T04:23:38Z")

</div>

Hi team! Following the instructions shared in the metrics for JDK documentation on observability#metrics. I am setting up a Bean of type `TemporalOptionsCustomizer<WorkflowServiceStubsOptions.Builder>` as mentioned in this document: [https://github.com/temporalio/sdk-java/tree/master/temporal-spring-boot-autoconfigure-alpha#customization-of-options](https://github.com/temporalio/sdk-java/tree/master/temporal-spring-boot-autoconfigure-alpha#customization-of-options)).

But when I go to `/actuator/prometheus` endpoint, all metrics except the temporal ones are showing up. Can someone please help identify if I am missing something? My workers come up and I am able to run workflows no problem.

I have uploaded the source code here: [https://github.com/gauravojha/learning-temporal](https://github.com/gauravojha/learning-temporal)

Basically, my build.gradle has this snippet

```auto
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	implementation 'org.springframework.boot:spring-boot-starter-actuator'
	implementation 'io.temporal:temporal-spring-boot-starter-alpha:1.20.0'
	implementation 'io.micrometer:micrometer-registry-prometheus'
}

```

And the bean looks like

```auto
@Bean
  public TemporalOptionsCustomizer<WorkflowServiceStubsOptions.Builder>
      customServiceStubsOptions() {
    return new TemporalOptionsCustomizer<>() {
      @Nonnull
      @Override
      public WorkflowServiceStubsOptions.Builder customize(
          @Nonnull WorkflowServiceStubsOptions.Builder optionsBuilder) {
        PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
        StatsReporter reporter = new MicrometerClientStatsReporter(registry);
        Map<String, String> mp = ImmutableMap.of("ojha", "ojha");
        // set up a new scope, report every 1 seconds
        Scope scope =
            new RootScopeBuilder()
                .tags(mp)
                .reporter(reporter)
                .reportEvery(com.uber.m3.util.Duration.ofSeconds(1));
        optionsBuilder.setMetricsScope(scope);
        return optionsBuilder;
      }
    };
  }

```

I don’t see any error reported in the logs. I followed the examples in `temporal-java-samples` project, and I do not see any metric specific configuration, or anything which is different than what I have in my project above.

---

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 13, 2023, 4:24am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/2 "2023-07-13T04:24:14Z")

</div>

Link to the metrics documentation I followed: [Java SDK developer's guide - Observability | Temporal Documentation](https://docs.temporal.io/dev-guide/java/observability#metrics)

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 13, 2023, 10:37pm UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/3 "2023-07-13T22:37:27Z")

</div>

We have [spring boot sample](https://github.com/temporalio/samples-java#running-springboot-samples) that shows how to config actuator and sdk metrics if that helps. If you use temporal-spring-boot-starter there is i think no need for your to set up custom WorkflowServiceStubs and metrics scope, its done for you via application config. Note the samples use SpringBoot 2

---

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 14, 2023, 1:07am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/4 "2023-07-14T01:07:51Z")

</div>

Thanks @tihomir … yeah I am already configuring my project with temporal-spring-boot-starter, and I compared my project with the sample provided, perhaps I am missing something very basic, but I do not see any difference. If I remove the custom WorkflowServiceStubs I have, still nothing shows up on prometheus endpoint. I will next try with spring boot 2, just to make sure its not a spring boot 3 thing, but I would really appreciate if someone in the community could (if they have time) glance [through the repo I have added](https://github.com/gauravojha/learning-temporal) to see if I am making a mistake. Even the library versions are same as the one in samples.

Update:  
I just tried with spring boot 2 (same version in samples) as well, same result… Even tried switching between JDK 11 and 17 just to make sure

```auto
// portion of build.gradle
plugins {
	id 'java'
	id 'org.springframework.boot' version '2.7.13'
	id 'io.spring.dependency-management' version '1.1.0'
	id 'com.diffplug.spotless' version '6.19.0'
}

group = 'dev.gauravojha'
version = '0.0.1-SNAPSHOT'

java {
	sourceCompatibility = JavaVersion.VERSION_1_8
}

```

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 1:28am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/5 "2023-07-14T01:28:46Z")

</div>

Will look at your repo, just fyi I think you forgot to commit the gradle wrapper jar here: [https://github.com/gauravojha/learning-temporal/tree/main/gradle/wrapper](https://github.com/gauravojha/learning-temporal/tree/main/gradle/wrapper)

---

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 14, 2023, 1:36am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/6 "2023-07-14T01:36:59Z")

</div>

Thanks @tihomir !! Appreciate the help. Just added the jar

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 1:48am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/7 "2023-07-14T01:48:33Z")

</div>

Did you try changing [https://github.com/gauravojha/learning-temporal/blob/main/src/main/resources/application.yml#L5](https://github.com/gauravojha/learning-temporal/blob/main/src/main/resources/application.yml#L5)

to

`include: prometheus`

and then look at [http://localhost:8080/actuator/prometheus](http://localhost:8080/actuator/prometheus)

“\*” should also work fine. maybe you were looking at different actuator url?

---

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 14, 2023, 1:52am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/8 "2023-07-14T01:52:49Z")

</div>

yup, tried that as well, to cross out any weird thing which ‘\*’ might cause… but nope, same result

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 1:59am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/9 "2023-07-14T01:59:28Z")

</div>

> same result

just to confirm with this you mean you do not see any metrics that start with “temporal\_” on the [http://localhost:8080/actuator/prometheus](http://localhost:8080/actuator/prometheus) endpoint? What do you see instead?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 2:04am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/10 "2023-07-14T02:04:51Z")

</div>

The only other diff i see now is

> <https://github.com/gauravojha/learning-temporal/blob/main/build.gradle#L24C25-L24C63>

try changing to runtime only: [https://github.com/temporalio/samples-java/blob/main/springboot/build.gradle#L12](https://github.com/temporalio/samples-java/blob/main/springboot/build.gradle#L12)

---

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 14, 2023, 2:24am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/11 "2023-07-14T02:24:20Z")

</div>

Thanks @tihomir

> just to confirm with this you mean you do not see any metrics that start with “temporal\_” on the

Yes. I don’t see any metrics with temporal\_. I see all other system and application metrics, but no Temporal SDK metrics. Attaching a screenshot

 ![Screenshot 2023-07-13 at 7.18.59 PM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/d/d9abf4afb28203c1c72f09765419173c887b58c9.jpeg)

> try changing to runtimeOnly

Yup, tried that as well. In fact I have pushed a new branch with these changes as well: [GitHub - gauravojha/learning-temporal at more\_tests](https://github.com/gauravojha/learning-temporal/tree/more_tests) if someone wants to take a stab at running the application.

I also tried a couple more things:

1. changed the namespace to “default”. No change
2. copied springboot `TemporalOptionsConfig` [config class](https://github.com/temporalio/samples-java/blob/main/springboot/src/main/java/io/temporal/samples/springboot/customize/TemporalOptionsConfig.java) into my branch, and removed the earlier Bean config I was doing. Same result

I have a feeling i am missing out on a very basic config somewhere, but the repo is already stripped down to a very minimal codebase, so comparing with the samples repo 1:1, I am unable to see what I am missing out on ☹

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 3:05am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/12 "2023-07-14T03:05:36Z")

</div>

Was able to run your demo and yeah can reproduce.

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 3:19am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/13 "2023-07-14T03:19:52Z")

</div>

> I have a feeling i am missing out on a very basic config

Yeah you were right 🙂

> <https://github.com/gauravojha/learning-temporal/blob/more_tests/src/main/resources/application.yml#L9>

change

`target: local`

to

`target: 127.0.0.1:7233`

and you should see sdk metrics in /actuator/prometheus, no other changes required

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 14, 2023, 3:32am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/14 "2023-07-14T03:32:28Z")

</div>

Found reason for this in sdk: [https://github.com/temporalio/sdk-java/blob/master/temporal-spring-boot-autoconfigure-alpha/src/main/java/io/temporal/spring/boot/autoconfigure/template/ServiceStubsTemplate.java#L69-L71](https://github.com/temporalio/sdk-java/blob/master/temporal-spring-boot-autoconfigure-alpha/src/main/java/io/temporal/spring/boot/autoconfigure/template/ServiceStubsTemplate.java#L69-L71)

if you set target to “local” it creates  
`WorkflowServiceStubs.newLocalServiceStubs();`

and does not register metricsScope…filed issue [here](https://github.com/temporalio/sdk-java/issues/1815).

---

<div class="post-metadata">

**Author:** ![gauravojha](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gauravojha](https://community.temporal.io/u/gauravojha)\
**Post date:** [July 14, 2023, 6:13am UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/15 "2023-07-14T06:13:29Z")

</div>

Thank you!! I appreciate your help on this… yup, i can see the metrics now…

---

<div class="post-metadata">

**Author:** ![Prats](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/prats/32/1781_2.png) [@Prats](https://community.temporal.io/u/Prats)\
**Post date:** [January 25, 2024, 1:47pm UTC](https://community.temporal.io/t/unable-to-view-prometheus-metrics-using-spring-boot-3/8819/16 "2024-01-25T13:47:16Z")

</div>

Hi Tihomir,

Am facing the same issue too. I don’t see temporal metrics, everything else is coming.  
We are using temporal spring boot autoconfigure module. I have added the config, not sure what am I missing.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/5/5c77041ea1cd7f2c40b271d3c523864a582c3d88.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/3/3feee56ee9882fc2f57778e036994524ff3acf9c.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/a/ad695c98bb3dbc9ddf107f1968717fe229a7a523.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/5/5bf69cfc3caa219430ecfaf99b545e8e284588dc.png)  
Do we need to add any port here for temporal metrics?

I see here a different port, [samples-java/springboot/src/main/java/io/temporal/samples/springboot/metrics at main · temporalio/samples-java · GitHub](https://github.com/temporalio/samples-java/tree/main/springboot/src/main/java/io/temporal/samples/springboot/metrics)

I deploy this on kubernetes do port forwarding and check.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/8/894ae73acc175ff0b67f78c0965cae29a83df37f.jpeg)

And i don’t see temporal metrics.

@tihomir Could you please help
