Spring Boot metrics in Prometheus with Micrometer

Connect Spring Boot services to Prometheus through Micrometer's Prometheus registry, expose /actuator/prometheus safely, and add business metrics. This page covers the method, setup sequence, security and common failures.

On this page

How Spring Boot metrics reach Prometheus through Micrometer

Picture a team whose Spring Boot services run in production, yet nobody can see their request rates or error counts in Prometheus. The supported way to close that gap is Micrometer's Prometheus registry together with the actuator endpoint at /actuator/prometheus, and Prometheus collects the data by scraping that endpoint over HTTP. The application publishes its metrics in the Prometheus text format, and the Prometheus server pulls them on its own schedule, so the service itself never needs to know where Prometheus lives.

Two details trip up most first-time setups. First, Spring Boot does not expose the endpoint by default, so the actuator must be given the prometheus endpoint in its exposure settings and the micrometer-registry-prometheus dependency must be on the classpath. Second, Micrometer sits on top of the Prometheus Java client, and the artifact choice decides which client generation you get. The micrometer-registry-prometheus artifact uses the 1.x client, while micrometer-registry-prometheus-simpleclient uses the legacy 0.x client. Confirm which one your existing services and libraries already depend on before you add a second client to the same classpath, because mixed generations cause conflicts that look like missing metrics.

DeployOpen plans and implements this setup in your own infrastructure, including the dependency choice, actuator exposure, the scrape configuration for each service, and how the endpoint is protected from unauthenticated access. Before any build starts, the team should agree on which services are in scope, which Prometheus servers scrape them, and who owns the endpoint's access controls. Ask for these decisions to be written into the scope so that the build has a clear finish line.

What you need before wiring Spring Boot to Prometheus

Four decisions and checks sit in front of any Micrometer setup: the Spring Boot and Micrometer versions, the Prometheus client registry, a reachable Prometheus server, and how the scrape is secured. Settle them together, because each one constrains the others. Confirm exact compatible versions against the Spring Boot and Micrometer documentation rather than assuming them.

Spring Boot and Micrometer versions

Record the Spring Boot version in use and confirm which Micrometer release it manages before adding any registry dependency. Check that the actuator starter and the Micrometer Prometheus registry come from the same compatible line, and pin them through the Spring Boot bill of materials instead of hand-picking versions. Ask whether any service runs an older Spring Boot line, since upgrades to that line may change defaults for actuator exposure and metric names. Confirm the exact pairing in the official documentation for your release.

Spring Boot metrics docs

Actuator exposure defaults

The /actuator/prometheus endpoint is not available by default, so each application must explicitly expose it. Decide which actuator endpoints are exposed over the web, and keep the list short so that health, metrics and Prometheus endpoints are the only ones reachable from the scrape network. Plan this per service, because a shared base configuration applied to every application is the most common source of exposed diagnostics.

Prometheus client registry choice

Micrometer's Prometheus registry uses the 1.x Prometheus Java client, while the simpleclient variant uses the legacy 0.x client. Choose the 1.x registry for new services and confirm that no existing dashboard, recording rule or library in the estate depends on the 0.x client's behavior. Mixing registries across services in one estate complicates metric naming reviews, so document the decision once for all teams.

Micrometer Prometheus registry

Running Prometheus and network path

Confirm that a Prometheus server is running and that its scrape job can reach every application's HTTP port across the network, through any firewall, load balancer or Kubernetes network policy in between. Note that Prometheus stores data locally on a single node, so confirm its retention and storage sizing before adding many new targets. Verify the path with a test scrape from the Prometheus host, not just from a workstation.

Management port and certificates

Decide whether the scrape uses the main application port or a separate management port, because a separate port lets you restrict the metrics endpoint to the scrape network without changing the public API. Decide how Prometheus authenticates to the endpoint, whether by TLS with client certificates, HTTP basic authentication over TLS, or network controls alone. Basic authentication without TLS sends credentials in cleartext, so do not plan that option. Confirm the certificate issuer, rotation process and minimum TLS version your security team requires.

Configuring the Prometheus registry and exposing the endpoint

This sequence takes a Spring Boot service from no metrics endpoint to a Prometheus target that is scraped successfully, with each step confirmed before the next one begins. The result is a service whose Micrometer metrics appear in Prometheus under a known job and instance.

  1. Add the actuator and Prometheus registry dependencies

    The developer adds the Spring Boot actuator starter and the micrometer-registry-prometheus dependency to the build file. Micrometer uses the Prometheus Java client, and the 1.x client is the registry that current projects should choose; the legacy 0.x client is available through a separate simpleclient registry, so confirm which one your dependency manager resolves before building. Check that the dependency tree contains the 1.x registry and that the application still starts cleanly.

  2. Expose the prometheus endpoint in configuration

    The actuator endpoint at /actuator/prometheus is not available by default, so the developer must add the prometheus endpoint to the exposure settings in application configuration, typically through the management endpoint web exposure property. Limit exposure to the endpoints the scraper needs so health and other actuator endpoints are not published by accident. Confirm the result by starting the service and checking that the endpoint answers rather than returning a not-found response.

  3. Set common application tags

    The developer sets common tags, such as the application name and environment, through the Micrometer meter registry customization so every metric carries the same identifying labels. Keep the values low cardinality, for example a fixed environment name rather than a host or build identifier, because every tag value multiplies the number of series Prometheus stores. Confirm the tags by reading the raw output in the next step and checking that each series includes them.

  4. Verify the raw exposition output

    Before Prometheus is involved, the team checks what the service publishes. Run curl against the endpoint on the service host or from a jump host that can reach it, for example against the management port if one is configured. The response should be plain text in the Prometheus exposition format, with JVM and HTTP server metrics present and the common tags attached. If the response is empty, a 401 or 403, or missing the tags, return to the exposure and security settings before continuing.

  5. Add a scrape job for the endpoint

    The Prometheus administrator adds a scrape job to the configuration file, naming the job after the service and listing its address in static_configs, or in a service discovery block if the platform provides one. Set metrics_path to /actuator/prometheus when the default path is not used, and set any authentication the endpoint requires. Validate the file with promtool check config before reloading Prometheus, so a syntax problem does not block the change. The step is done when the configuration check passes.

  6. Confirm the target is up in Prometheus

    After the configuration is reloaded, the administrator opens the targets page in the Prometheus web UI and checks that the new job shows the target as up, with a recent last scrape time and no error message. Then run a simple query, such as the up metric filtered to the job name, and confirm it returns 1. A target that shows as down usually points to a network path, port, path or authentication mismatch, which the error text on the targets page identifies.

Adding custom business metrics without inflating cardinality

A counter records a value that only goes up, such as orders placed or payments rejected. Micrometer's Prometheus registry exposes a counter with a _total suffix, so a meter named orders.placed appears as orders_placed_total in the scrape output. Prometheus is designed for counters because queries use rate() or increase() to turn the running total into a per-second or per-window figure, and those functions handle process restarts through counter reset detection.

  • Use counters for events: Count things that happen, not things that are currently true.
  • Let the registry add the suffix: Name the meter without _total so the exported name is not duplicated.
  • Register once: Build the counter at startup and reuse the reference rather than creating it on every request.
  • Keep tag sets small: A counter with a status tag such as outcome produces one series per distinct value.
  • Query with rate: Dashboards and alerts should apply rate() or increase() to the counter.

Confirm the exact metric names in your running /actuator/prometheus output before writing alert rules against them.

How Micrometer meters map to Prometheus series

This table compares each Micrometer meter type with the Prometheus series it produces on the /actuator/prometheus endpoint. Read it as a starting point, then confirm the exact names in your own running endpoint before you write alert rules or dashboards, because suffixes and base units depend on your Micrometer version and meter configuration.

Micrometer conceptPrometheus outputWhat to check
Meter name with dotsDots become underscores, for example http.server.requests becomes http_server_requestsSearch the scrape output for the converted name before writing any PromQL
TagsBecome Prometheus labels with the same key, with dots converted to underscoresConfirm each tag is bounded, since every distinct value creates a new series
CounterUsually exposed with a _total suffixUse rate() or increase() in queries rather than reading the raw value
GaugeExposed under the meter name with no added suffixCheck whether the value is a current reading or a value you expect to rise
TimerExposes _count, _sum and, when histograms are enabled, _bucket series, with a base unit suffix such as _secondsConfirm which quantiles or buckets are published, since this changes the query and storage cost
Distribution summaryExposes _count, _sum and optionally _bucket series, with the base unit added when one is setSet the base unit explicitly so the name carries the right unit
Base units and suffixesThe registry appends units such as _seconds or _bytes when the meter declares themVerify the unit suffix against the endpoint before alert thresholds depend on it

How a scrape travels from Spring Boot to Prometheus

The scrape starts in the Spring Boot application, where Micrometer's Prometheus registry turns meters recorded on the MeterRegistry into text that the actuator endpoint serves at /actuator/prometheus. The endpoint is not exposed by default, so the diagram marks it on a separate management port that the network path reaches only from Prometheus. An authenticating proxy or TLS termination, if you add one, sits between the scrape job and that port. Check which hops authenticate the caller, and confirm that the Prometheus scrape job holds the credentials it needs before alerting or Grafana read anything.

Trust boundaries and authentication points on the path from a Spring Boot metric to storage.

Securing the actuator endpoint for scraping

The Prometheus metrics endpoint is an HTTP surface that exposes internal detail about your application, so it needs the same controls as any other management interface. The cards below cover what to expose, where to expose it, how Prometheus authenticates, and how credentials are kept out of configuration. Work through them in order before the endpoint reaches a shared network.

Expose only the metrics endpoint

Spring Boot does not expose actuator endpoints by default, so the decision is which ones you enable. Set only prometheus and health in management.endpoints.web.exposure.include and leave the rest off. Review the list on every dependency upgrade, because new starters can add endpoints that become reachable as soon as they are exposed. Check the result by requesting each actuator path from outside the service and confirming it returns not found.

Spring Boot metrics docs

Avoid env and heap endpoints

The env, heapdump, threaddump and configprops endpoints can reveal property values, JVM memory contents and configuration that often includes credentials. Keep them out of the exposure list in every profile, including staging, because staging configuration is often copied to production. Confirm with a request to each path after deployment. Treat any heap dump endpoint as a credential leak risk, not a diagnostic convenience.

Move the management port internal

Setting management.server.port to a separate port lets you bind metrics to an internal interface while the application port faces users. Confirm the network policy or firewall allows only the Prometheus servers to reach that port. Check that the health endpoint used by load balancers and orchestrators still resolves on the path those systems expect. Verify the split from outside the cluster or subnet, since a bound port is not the same as a reachable one.

Authenticate scrapes with TLS

Prometheus supports TLS and client certificate authentication with TLS 1.2 as the minimum version. Client certificates let the target verify the scraper, and the scrape configuration references the certificate and key files. Agree with your security team who issues and rotates these certificates, and how a rotation is rolled out without a gap in scrape data. Confirm the target rejects connections that present no valid certificate.

Prometheus security model

Basic auth only over TLS

Prometheus supports HTTP basic authentication with bcrypt-hashed passwords, which keeps stored passwords out of plain text on the scraper side. Basic authentication without TLS sends credentials in cleartext, so pair it with TLS on every scrape. Confirm the hashed password file is readable only by the Prometheus service account. Ask whether your environment's approved hashing and rotation policy also applies to scrape credentials.

Prometheus security model

Keep secrets out of config files

Scrape passwords, certificate keys and Spring datasource credentials should not sit in application.yml or in a Prometheus configuration file committed to source control. Load them from environment variables, a mounted secret, or your secrets manager, and reference them rather than embedding values. Check that the rendered configuration in logs and admin views does not echo secret values. Ask who can read the Kubernetes or host secret store and how that access is reviewed.

Plan user access through a proxy

Prometheus has no built-in single sign-on, and its security model notes no built-in CSRF protection on mutating endpoints. Engineers who browse the Prometheus web UI or API therefore need an authenticating reverse proxy in front of it, with SSO handled there. The scrape path from Prometheus to targets is a separate flow and should not be routed through a user login. Confirm which paths the proxy protects and that admin and lifecycle endpoints stay disabled.

What drives the effort of a Spring Boot metrics rollout

The biggest driver of effort is how many services will expose metrics and how varied they are. Each Spring Boot service needs the Micrometer Prometheus registry on its classpath, the actuator endpoint exposed, and a scrape target in Prometheus, so the work scales with the count of services. Services in other languages add their own client libraries or exporters, and the team should inventory the language mix before estimating. Ask whether services already include spring-boot-starter-actuator, because teams that already expose /actuator/health usually need only a registry dependency and a property change, while teams starting from zero also have to decide what the endpoint is allowed to show. Also confirm which Micrometer registry artifact each service uses, since the 1.x Prometheus client and the legacy 0.x client are different dependencies that cannot be mixed without review.

The number of business metrics the team wants is the second driver, and it is also the one most likely to grow after go-live. Every custom counter, timer or gauge needs a name, a unit, a help string and a label set that someone has agreed to keep bounded. A cardinality review is where this effort concentrates: each label value multiplies the number of time series Prometheus stores, so a label such as user ID or order ID can turn a small service into a memory problem. Plan a review step before any new metric ships, with an owner who can reject labels, and budget time for rework when a team discovers that a metric it needs must be redesigned. The review process itself, who signs off and how it is recorded, is often the least defined part of a rollout and the part that determines whether the work stays manageable over time.

The last two drivers are the security standard and the existing Prometheus environment. If the endpoint must meet an internal standard, the work includes restricting access to the management port, deciding whether to use a separate management port, and documenting how Prometheus authenticates to it. Confirm early whether Prometheus is already running in the target environment, which version and how it is deployed, and whether a platform team already owns its configuration. Where Prometheus is new, the rollout also includes the server, storage and alerting setup, which can outweigh the instrumentation work itself. Ask the platform team which scrape and authentication patterns they already support, and confirm the Spring Boot and Micrometer versions in use against the Micrometer Prometheus registry documentation before estimating.

Common failures when Spring Boot metrics do not appear

This table lists the failures teams most often hit when a Spring Boot service is scraped by Prometheus but metrics are missing, legacy-named, blocked or unusable. Each row gives the symptom, the likely cause and a check you can run to confirm the fix worked.

SymptomLikely causeFix and how to verify
Scrape returns 404 on /actuator/prometheusThe prometheus endpoint was never exposed, since Spring Boot does not expose it by defaultAdd prometheus to management.endpoints.web.exposure.include, restart, then confirm the endpoint returns plain-text metrics with curl
Metrics missing or named with legacy prefixesThe simpleclient registry (0.x Prometheus client) is on the classpath instead of micrometer-registry-prometheus (1.x client)Remove the legacy registry, add micrometer-registry-prometheus, and check the dependency tree with your build tool for a single Prometheus client version
Endpoint responds but Prometheus target is downScrapes go to the application port while the management port is set separately, or a firewall blocks the management portConfirm management.server.port and the scrape target match, then test reachability from the Prometheus host to that port
Scrape fails with 401, 403 or TLS handshake errorsActuator security requires login, or Prometheus is configured for TLS or basic auth that the service does not matchPermit the scrape path for the Prometheus network or configure matching basic auth or certificates in scrape_configs, then check the target page for the exact error
Series count grows until Prometheus slows downUser IDs, session IDs or raw URLs were used as metric tags, creating a new time series for each valueRemove unbounded values from tags, use route templates instead of raw paths, and watch the series count per metric after deployment (illustrative check: count series by metric name)
Business counters drop to zero or double after restarts or deploysCounters reset when the process restarts, and PromQL needs rate or increase to handle resets; double counting comes from registering the same meter twice or from counting in two layersQuery with rate() or increase() rather than the raw value, register each meter once as a singleton bean, and compare the counter against an independent source such as a database count during testing
Histogram or percentile metrics look wrongPercentile publishing was enabled per endpoint without bucket planning, or the wrong bucket setting was appliedReview the histogram settings for each timer, confirm the _bucket series exist, and confirm the quantile query matches the configured buckets
Metrics appear in one environment onlyDifferent actuator settings, profiles or missing common tags between environmentsCompare the effective configuration in each profile and confirm an application tag is present so series are distinguishable across services

Questions teams ask before a Spring Boot metrics rollout

What drives the cost of a Spring Boot metrics rollout, and which parts recur?

The main cost is the engineering time to add the Micrometer Prometheus registry, expose the endpoint, secure it and review metric names across each service. Prometheus itself is licensed under Apache-2.0 with no paid edition, so the spend goes to infrastructure, storage, implementation and the people who run it. One-time work includes the first service pattern, the security design and the naming review. Recurring cost comes from storage growth, dashboard and alert upkeep, library upgrades and new services adopting the pattern. Ask any quote to separate these lines and to state which services are in scope.

How long does a rollout take when we have many Spring Boot services?

Duration depends mainly on service count, how uniform the services are, and how many teams must sign off on metric names and endpoint exposure. A small set of services that share one build template moves faster than a fleet with mixed Spring Boot versions and separate pipelines. Start with a pilot on a few services to prove the pattern, then roll out in waves so each wave reuses the same configuration and checks. Ask for the timeline in the written scope with the wave list attached, rather than a single date for the whole estate.

What must our team provide before the work starts?

Plan for four inputs from your side:

  • Service owners who confirm which services expose metrics and which business metrics matter
  • A Prometheus server, or a plan to deploy one, with a scrape configuration your team can change
  • Network access from the Prometheus server to each service's management port
  • Security sign-off on how the /actuator/prometheus endpoint is protected, including whether it is reachable only from the monitoring network

Missing any of these usually delays the pilot more than the code change does.

Can our internal team do this without an outside partner?

Yes, a team with Spring Boot and Prometheus experience can do it, because the core steps are documented in the Spring Boot actuator metrics reference and the Micrometer Prometheus registry guide. The risk lies in consistency and review: teams often expose the endpoint without securing it, or create metric names and labels that raise cardinality. Decide whether your engineers have time to own naming standards, security review and rollout across all services. A partner is most useful when the work must be finished across many services on a fixed schedule.

Which Micrometer registry dependency should we choose?

Use the registry that matches the Prometheus Java client generation your stack supports. Micrometer's micrometer-registry-prometheus module uses the 1.x Prometheus Java client, while micrometer-registry-prometheus-simpleclient uses the legacy 0.x client. Check which Micrometer and Spring Boot versions you run before you pick one, and confirm the choice with your platform team so every service follows the same pattern. Mixed choices across services make dashboards and naming reviews harder.

How do we protect the /actuator/prometheus endpoint?

Treat the endpoint as internal operational data. Spring Boot does not expose it by default, so exposure is a deliberate setting that should be reviewed per service. Limit network reachability to the Prometheus server, and where the endpoint must share a port with application traffic, add authentication and use TLS. Prometheus itself supports TLS and client certificates with TLS 1.2 as the minimum, and basic authentication without TLS sends credentials in cleartext. Confirm the approach with your security team before the pilot.

What does a fixed-scope quote for this work include?

Ask for a written scope that lists the services in each wave, the registry and Spring Boot versions, the endpoint exposure and security design, the naming and label review, the custom business metrics to add, and the verification steps for each service. The quote should name deliverables such as configuration templates, a pilot report and handover notes, and state what your team must provide. DeployOpen does not publish a price list, so the quote follows from that written scope and the number of services involved.

Where the official Spring Boot and Micrometer guidance applies

The configuration keys and dependency coordinates for this setup live in two places: the Spring Boot actuator metrics reference and the Micrometer Prometheus registry reference. Use them as the source of truth for property names, endpoint exposure and the artifact you add to the build, and treat any example in this page as a starting point to check against them. The Spring Boot reference explains that the /actuator/prometheus endpoint is not available by default and must be exposed, which is the first setting most teams need to confirm.

Before you implement anything, check version compatibility on both sides. Micrometer's documentation distinguishes the registry built on the 1.x Prometheus Java client from the one built on the legacy 0.x client, so confirm which artifact your Spring Boot line pulls in and which client it expects. Mixing an older registry with a newer client, or copying a dependency from an outdated blog post, is a common way to end up with a scrape endpoint that returns nothing useful. Record the Spring Boot version, Micrometer version and Prometheus client version in your change ticket so the next upgrade starts from a known baseline.

Read the reference pages again whenever you upgrade Spring Boot, because property names and default behavior can change between releases. Ask your platform or security team to confirm which actuator endpoints they permit on each network zone, since the reference documents exposure settings but not your organization's policy. Once the version and exposure questions are settled, the rest of this page covers the decisions specific to running the endpoint in production.

How DeployOpen works on this

DeployOpen plans, implements, hardens, documents and supports Spring Boot metrics in Prometheus with Micrometer inside your own infrastructure. The work starts with a written scope that defines which services expose metrics, how the endpoint is secured, and which business metrics are added.

How we scope

  • Inventory the Spring Boot services, their current actuator exposure, and the Prometheus servers that will scrape them.
  • Agree in writing which Micrometer registry dependencies, endpoint settings and custom business metrics are in scope.
  • Set the security boundary for /actuator/prometheus, including network path, TLS, and authentication for each scraper.

How we build

  • Add the Micrometer Prometheus registry with the client generation your services need, and expose the endpoint through configuration.
  • Review metric names, tags and label values so custom business metrics keep cardinality under control before they ship.
  • Test scrapes end to end, confirming series appear in Prometheus and that the endpoint is not reachable from untrusted networks.

How we hand over

  • Document the endpoint settings, dependency versions, security configuration and the naming standard applied to each service.
  • Provide scrape job configuration and a list of custom metrics with their purpose, labels and owning team.
  • Walk your engineers through upgrade steps for Spring Boot and Micrometer, and how to add a new business metric safely.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer, and the scope for that is quoted separately.
  • Ask us to confirm which Spring Boot and Micrometer versions your upgrade plan targets before the work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.