Basic authentication for Prometheus with bcrypt

Basic authentication with bcrypt-hashed passwords protects Prometheus web endpoints when it is paired with TLS, and it suits small, controlled estates. This page covers how to set it up, configure scrapers and Grafana, and recognize when a reverse proxy with SSO is the better answer.

On this page

When basic authentication for Prometheus is enough and when it is not

A Prometheus server or Alertmanager is often reachable by more people and systems than the network should allow: a shared monitoring VM on a flat subnet, a dashboard host that several teams can reach, or a debugging port exposed during an incident and never closed. Prometheus supports HTTP basic authentication with bcrypt-hashed passwords, configured in a web configuration file that is passed to the server with a flag. The password is stored only as a bcrypt hash, so the file does not reveal the secret. Basic auth is supported alongside TLS and client certificate authentication, but it has no built-in single sign-on, so every user is a local credential that someone must create, rotate and remove by hand. Basic auth is a reasonable first control when the user count is small, the people are known, the server sits on a restricted network, and the main risk is accidental or unauthenticated access rather than targeted attack.

Basic auth is not enough when the credentials must cross a network in cleartext. Without TLS, the username and password travel with every request, so anyone able to observe that traffic can capture them. Basic auth should therefore never be enabled on its own on a path that leaves a trusted segment. It is also a poor fit when you need per-person accountability, joiner and leaver workflows tied to a corporate directory, multi-factor authentication, or consistent sign-in across Grafana, Alertmanager and other tools. In those cases, an authenticating reverse proxy in front of the web UI and API, backed by an identity provider, is usually the better answer. Confirm with your identity team whether an existing provider can sit in front of Prometheus before you commit to local accounts.

Teams that typically need basic auth include small platform groups running a single Prometheus for their own estate, and internal teams where a proxy and SSO are not yet available. Before choosing it, confirm three things in your own environment: that TLS is already planned for the same listener, that the list of users is short and owned by a named person, and that the admin and lifecycle APIs remain disabled or restricted, since basic auth does not limit what an authenticated user can do with them. If any of these fail, treat basic auth as a stopgap and plan the proxy or client certificate option instead.

How basic auth, TLS, scrapers and Grafana fit together

The diagram starts with an engineer's browser and Grafana, which send queries to the Prometheus server over HTTPS. Scrapers and Alertmanager reach the same endpoints, and each request must carry credentials that the server checks against bcrypt hashes. The trust boundary sits at the network edge, so the key check is that TLS covers every hop where the password travels, since basic auth without TLS exposes credentials in cleartext.

Clients reach Prometheus over TLS, and each request passes a bcrypt-backed basic auth check.

Which access control fits each Prometheus endpoint

This table compares four ways to control access to Prometheus endpoints: bcrypt basic authentication, TLS with client certificates, an authenticating reverse proxy with SSO, and network-only controls. Read each row against the users and services that reach the endpoint, and use the last column to decide when a single option stops being enough.

ControlWhat it protects and who it fitsMain operational costWhere it stops being adequate
Basic authentication with bcryptProtects the web UI and API with a username and password stored as bcrypt hashes. Fits human users and simple scrapers that can send credentials.Hash generation, password rotation across every scraper and Grafana data source, and secret storage for each client.Cleartext credentials without TLS. No built-in single sign-on, MFA or per-user audit trail.
TLS with client certificatesEncrypts traffic and requires a trusted client certificate before the request reaches Prometheus. Fits scrapers, Alertmanager and automated clients rather than interactive users.Certificate issuance, distribution, rotation and revocation handling for every client.Human users who need a browser login, or environments where no internal certificate authority is available to issue client certificates.
Authenticating reverse proxy with SSOPlaces an identity-aware proxy in front of the web UI and API, so users sign in through the organization's identity provider. Fits human users, with service accounts handled separately.Proxy deployment and configuration, identity provider integration, and a separate path for machine clients such as scrapers.Machine-to-machine scrapes that cannot complete an interactive login, and any setup where the proxy becomes a single point of failure.
Network-only controlsLimits which hosts can reach Prometheus through firewall rules, security groups or private network placement. Fits internal scrapers and operators on a controlled segment.Network design, firewall rule maintenance and change control as hosts and subnets change.Any path reachable from a wider network, shared hosts, or environments where an assessor expects authentication on the endpoint itself.

Generating bcrypt hashes and enabling basic auth in the web configuration

This sequence turns on bcrypt-hashed basic authentication and TLS for Prometheus through a web configuration file, with a check at each stage so the team can confirm the change works and roll it back if it does not.

  1. Confirm the endpoints and users in scope

    The team lists which Prometheus endpoints need protection (the web UI, the query API, and any metrics endpoints that are reachable by others), along with the named users or service accounts that need access and which of them only need read access. Write this list down before changing any configuration, because the same web configuration file applies to every endpoint served by that process. Done means each user has a name and a role, and the team knows which scrapers and dashboards will need credentials. Confirm with the service owners that no other consumer depends on anonymous access.

  2. Generate bcrypt hashes for each user

    Create a bcrypt hash for each user's password with a hashing tool the team already trusts and can audit, such as a short script using a well-maintained bcrypt library or a vetted command-line utility. Generate each password with a password manager, enter it once into the hashing step, and store only the plaintext in the password manager. Check that each output starts with a bcrypt prefix and that the hash verifies against the original password before continuing. Done means every user has a bcrypt hash and no plaintext password is written into a file, a ticket or a shell history.

  3. Write the web configuration file with auth and TLS

    Create a web configuration file, for example web.yml, with a basic_auth_users block that maps each username to its bcrypt hash. In the same file, add a tls_server_config block that points to the server certificate and key and sets the minimum TLS version to 1.2 or higher. Restrict file permissions so only the Prometheus service account can read the key and the hashes. Done means the file contains no plaintext passwords and the certificate paths resolve on the host.

  4. Pass the web configuration file to the server

    Start Prometheus with the --web.config.file flag pointing to the new file, keeping every other existing flag unchanged. If the server runs under a service manager, add the flag to the unit file or container command and record the change in version control. Confirm the process starts and that its logs show the web configuration was loaded without parse errors. Done means the service is running and the log contains no authentication or TLS configuration errors.

  5. Validate the file with promtool before reload

    Run promtool check web-config against the file on the same host or in the same container image as the server, and fix any reported errors before the server reads the new file in production. Keep the previous file in place so you can restore it. Done means promtool reports the file as valid, and the team has a copy of the prior configuration for rollback.

  6. Reload or restart the server

    Apply the validated file by restarting the Prometheus process, since the web configuration is read at startup. Plan the restart outside the window when dashboards and alert evaluation are most important, and tell the people who depend on the endpoints that they must now send credentials and use HTTPS. Done means the process is up and the health endpoint responds over HTTPS.

  7. Test refused and accepted requests

    From a host outside the server, send one request with no credentials and expect an authentication failure, then send one request with a valid username and password and expect a successful response. Repeat the test with a wrong password and confirm it is refused. Also confirm a plain HTTP request no longer succeeds. Done means the three expected results are recorded, and any unexpected success or failure is investigated before the change is accepted.

  8. Document the rollback path

    Record the previous unit file or command line, the previous configuration, and the commands needed to restore them, then rehearse the rollback in a non-production environment if one exists. If scrapers or Grafana break after the change, restore the prior file and restart, then fix the credentials on the client side. Done means the team can restore anonymous access within its normal change process, and the rollback steps are stored with the change record.

Configuring scrapers, Alertmanager and Grafana for protected endpoints

Prometheus itself is a client when it scrapes targets. If an exporter or application endpoint requires basic auth, the scrape job in prometheus.yml must send matching credentials over TLS. The username and password belong in the scrape job's basic_auth section, and the password should be referenced from a file so that the plain text never appears in the configuration file or in version control. Each scrape job holds only the credentials for its own targets, which keeps the blast radius small if one file is exposed.

  • Credentials per job: Give each scrape job or exporter its own account where the target supports it, so one revoked password does not break every scrape.
  • Password from a file: Use the password file option in the basic_auth block rather than an inline password value, and restrict the file to the Prometheus service account.
  • TLS settings: Pair the job with a tls_config block that trusts the correct CA and sets a server name that matches the certificate.
  • Reload and check: Validate the file with promtool check config before reloading, then confirm each target shows as up on the targets page.
  • Confirm per version: Check the scrape configuration reference for the Prometheus version in use, since field names and file options can change between releases.

Before switching protection on, confirm that every scrape job has been updated, because a job that is missing credentials will show targets as down rather than failing with a clear error.

Why basic auth without TLS exposes credentials

Basic authentication sends the username and password with every request, so it should never be enabled on a Prometheus endpoint without TLS in front of it. The Prometheus security model says that basic authentication without TLS exposes credentials in cleartext. Bcrypt protects the password stored in the web configuration file, but it does nothing for the password in transit. Anyone who can observe traffic between a scraper, an operator's browser or Grafana and the Prometheus server can read the credential, and that includes hosts on the same network segment that have no business seeing it. Treat TLS as a precondition of the design, not an optional hardening step added later.

Certificate management becomes the main operational dependency once TLS is in place. Decide before rollout who issues the server certificate for Prometheus, who holds the private key, and who is responsible when it renews. Your internal certificate authority, a platform team or a managed PKI service are all common answers, and each needs a documented owner. Plan rotation as a routine task with a calendar entry and a tested reload path. Scrapers and Grafana data sources validate the certificate chain, so an expired or mismatched certificate causes failed scrapes and broken dashboards at the same moment. Alerting on certificate expiry before it happens is a cheap control that is easy to skip.

Confirm the protocol settings in your own environment rather than assuming defaults. The security model describes TLS 1.2 as the minimum, so check that every client, including Prometheus, Alertmanager, Grafana and any scraper or proxy, can negotiate at least that version and that older protocols are disabled where your policy requires it. Ask your security team which cipher suites they accept and verify the resulting configuration with the tooling you already use before go-live. The Prometheus security model is the reference for what the server supports, and your own test results decide what you can claim to an auditor.

Security risks to plan for after enabling basic auth

Basic authentication stops anonymous access, but it leaves several gaps that a password alone cannot close. The cards below cover credential handling, the admin surface, request forgery, attribution and second-factor options, each with the control to add and the owner who should review it.

Password reuse and weak passwords

Bcrypt slows down offline cracking of stored hashes, but it does nothing about a password that is short, guessable or reused from another system. Generate long random passwords with a password manager, and do not let teams share one password across Prometheus, Alertmanager and Grafana. Ask the security team to set a rotation rule and to check the password policy against the hashes they generate. Owner: security team.

Security model

Credentials in plain configuration

A bcrypt hash in web.yml is safe to store, but the plaintext password used by scrapers and Grafana often ends up in prometheus.yml, pipeline variables or Helm values. Move those values into a secrets store or a _file setting, and make sure CI logs and rendered templates do not print them. Ask the platform team to scan repositories for literal passwords before each release. Owner: platform engineering.

Admin and lifecycle APIs behind the same password

The admin APIs are disabled by default, but a team that enables --web.enable-admin-api or --web.enable-lifecycle for a runbook gives every holder of the basic auth password the ability to delete series or shut the server down. Keep both flags off unless a documented task needs them, and if they are needed, restrict those paths at the proxy to a named operations group. Owner: the monitoring operations lead.

No CSRF protection on mutating endpoints

Prometheus has no built-in CSRF protection on endpoints that change state. A browser session that already holds the basic auth credentials can be tricked into sending a request from another site, so the risk grows when the browser caches the password. Restrict mutating paths at the reverse proxy, check the Origin or Referer headers there, and avoid running the web UI on the same host name as other sensitive applications. Owner: application security.

Shared accounts that block attribution

Basic auth has one username and password per account, so a shared login means the audit trail shows who used the account but not which person did so. Create one credential per person or per automated client, and record which account made each change. Ask whether your proxy or access logs can capture the username for every request. Owner: security operations.

No multi-factor authentication

Basic authentication has no second factor, so a leaked password gives full read access and, depending on the enabled APIs, more. Prometheus has no built-in single sign-on, so a common answer is an authenticating reverse proxy or an identity provider that enforces multi-factor authentication for human users. Scraper accounts still need separate, tightly scoped credentials. Owner: identity and access management team.

When a reverse proxy with SSO is the better answer

Prometheus has no built-in single sign-on, so basic authentication with bcrypt is a shared-secret control, not an identity system. The Prometheus security model normally places an authenticating reverse proxy in front of the web UI and API when a team needs SSO. The proxy handles user sign-in against your identity provider, and Prometheus receives only traffic the proxy has already approved. Basic auth remains workable for a small set of operators and for machine clients such as scrapers, but it stops being the right answer once people, not just services, need to reach the server.

Several conditions tell you it is time to move. The first is a growing number of human users sharing one password, which makes it impossible to tell who ran a query or changed a setting. The second is offboarding: removing one person from a shared credential means rotating it for everyone and every scraper and Grafana data source that uses it. The third is a policy requirement for multi-factor authentication, which basic auth cannot enforce on its own. The fourth is audit: if your assessors expect per-user access records, a shared password gives you nothing to show. Confirm these requirements with your security and compliance leads before you decide, because they usually come from policy rather than from Prometheus itself.

A proxy also adds a new component to secure, patch and monitor. It becomes the entry point for every human request, so its TLS configuration, session handling, header trust and upgrade path all need the same attention you give Prometheus. Keep basic auth for scrapers where practical, and confirm how the proxy will pass identity to Prometheus and whether the admin and lifecycle endpoints stay blocked. Consult the DeployOpen proxy topic for the design before you choose a product, since the decisions on authentication flows, headers and network placement affect the whole setup.

Limits to confirm in your environment before rollout

Basic authentication with bcrypt protects Prometheus endpoints with a shared credential, and that simplicity leaves several dependencies to verify. The cards below cover the version, the configuration readers, the clients, certificates, access scope and credential lifecycle that decide whether the setup holds in your environment.

Confirm web configuration support by version

Basic auth and TLS are set through a web configuration file, and the options available depend on the exact Prometheus release you run. Confirm the web configuration keys against the documentation for your line before writing them into a deployment. The current long-term support line is 3.13, supported until July 31, 2027, so check that line first if you intend to stay on it. Pin the exact version in your change record so reviewers can match the keys to the release.

Release cycle docs

Confirm how Alertmanager and exporters read config

Alertmanager and official exporters use their own web configuration files, and each has its own supported keys and reload behavior. Confirm that every component in your estate accepts the same basic auth and TLS layout you plan to use, rather than assuming one file format applies everywhere. Record which process reads which file and how each one is validated after a change.

Confirm client and Grafana auth support

Every scraper, Grafana data source and any script that queries Prometheus must send the credentials and trust the certificate chain you configure. Check each client's documentation for basic auth, custom CA handling and TLS minimum versions before rollout. Test one scrape job and one Grafana data source end to end, because a single unsupported client can leave dashboards blank without a clear error.

Confirm certificate provisioning and renewal

Basic auth without TLS sends credentials in cleartext, so the certificates that protect the endpoints become part of the login path. Confirm who issues them, where the private keys are stored, how they reach each host, and who is alerted before expiry. Ask whether your internal CA issues certificates to the Prometheus, Alertmanager and client hosts, and whether renewal includes a reload step.

Confirm basic auth gives no per-team isolation

A single username and password grants the same read and write access to every endpoint it protects, so it cannot separate one team's metrics from another's. If different teams or customers need different visibility, basic auth alone will not provide it. Decide early whether a per-tenant read layer, an authenticating proxy or a multi-tenant long-term store is needed, and document that decision as a known limit.

Confirm how password rotation is coordinated

A bcrypt hash in the web configuration file is only one side of a credential. Every scraper, Alertmanager client, Grafana data source and automation script stores the plaintext password, so a change must reach all of them together. Agree on the owner of each rotation, the order of updates, the reload steps and the window in which old and new credentials both work, and test the procedure on a non-production estate first.

Questions buyers ask about basic auth for Prometheus

What drives the cost of enabling basic auth and TLS on Prometheus?

The cost is mostly labor: the time to design the change, prepare certificates, update every endpoint and scraper, and test that nothing breaks. Prometheus itself is licensed under Apache-2.0 with no paid edition, so software spend is not the driver. The main cost factors are the number of Prometheus servers, Alertmanager instances and exporters in scope, how many scrapers, Grafana instances and scripts call them, how many certificate sources you must work with, and how much change control your organization requires. One-time costs cover design and rollout. Recurring costs cover certificate renewal, password rotation and updates when new targets are added. Ask any quote to itemize these components separately.

How long does enabling basic auth with TLS take?

Duration depends mainly on how many endpoints and clients must change at once. A single Prometheus server with a few scrape jobs and one Grafana instance is a small change. A fleet with several Prometheus servers, Alertmanager clusters, exporters and automation that queries the API takes longer, because each consumer must be found, updated and verified before the old access path is closed. Certificate authority lead time and change windows often set the schedule more than the configuration itself. Ask for a written list of endpoints and clients and a rollout order before accepting any timeline.

What does the work need from our own team?

Expect to provide access to the certificate authority or the process that issues certificates, a place to store password hashes and secrets such as a vault or Kubernetes secrets, and named owners for each scraper and dashboard. You will also need change windows, because enabling authentication breaks any client that is not updated. Your team should confirm which Prometheus and Alertmanager versions are in use, since the Prometheus release cycle affects which fixes you receive. Agree in advance who approves password rotation and who holds the bcrypt hashing and storage process.

Can an internal team set up basic auth and TLS without outside help?

Yes, a team with Linux and Prometheus experience can usually do it, and the official security model documents both basic authentication with bcrypt-hashed passwords and TLS with a minimum of TLS 1.2. The risks are in the details: sending basic auth without TLS exposes credentials in cleartext, and missed scrapers or Grafana data sources fail only after the change. Internal teams often underestimate the inventory and testing steps. A practical check is whether one person can list every client, test each one in a staging copy, and roll back cleanly.

When is it worth bringing in a partner for this work?

A partner is worth considering when the endpoint inventory is large or unclear, when several teams own clients that must change together, when certificates come from a process that is hard to navigate, or when an audit needs clear evidence of the change. DeployOpen plans, implements and documents self-hosted open-source platforms in your own infrastructure, and most engagements are fixed-scope with scope, deliverables and timelines agreed in writing before work starts. A partner does not replace your certificate authority or your change approvals, and it does not issue audit attestations. Ask for a written scope that names every endpoint, client and handover item.

What changes if we choose a reverse proxy with SSO instead?

Prometheus has no built-in single sign-on, so SSO is normally added with an authenticating reverse proxy in front of the web UI and API. That moves identity into your identity provider, which can give central user lifecycle, multi-factor sign-in and audit trails outside Prometheus. The trade-offs are a new component to run and patch, more complex routing for machine clients that cannot complete an interactive login, and the need to protect the Prometheus port so traffic cannot bypass the proxy. Basic auth often remains for scrapers and service accounts even when SSO covers people. Decide which clients use which path before building either.

Does basic auth protect Prometheus against every risk?

No. Basic auth controls who can send HTTP requests to a Prometheus endpoint, but it does not replace network segmentation, admin API restrictions or exporter controls. Prometheus has no built-in CSRF protection on mutating endpoints, and admin and lifecycle APIs are disabled by default, so enable them only when needed. Exporters such as SNMP and Blackbox take targets from URL parameters, so anyone with access can make them send requests elsewhere. Treat basic auth as one control in a layered design and confirm each remaining exposure with your security team.

How DeployOpen scopes and delivers Prometheus access controls

DeployOpen treats basic authentication for Prometheus as one control in a larger access design, covering the web UI, the query API, scrapers and Grafana. We scope the work in writing before any change is made, then build, test and document it inside your own infrastructure so your security and operations teams can review every step.

How we scope

  • Inventory every Prometheus, Alertmanager and exporter endpoint that needs a login, and record which clients call each one.
  • Agree in writing whether basic authentication, TLS, mutual TLS or an authenticating proxy with SSO fits each endpoint.
  • Confirm who owns password hash generation, secret storage and rotation, and who approves changes to the web configuration file.

How we build

  • Generate bcrypt hashes with your chosen cost settings and store them in the web configuration file, never in plain text.
  • Enable TLS first, then configure scrape jobs, Alertmanager and Grafana data sources with matching credentials and certificate trust.
  • Validate the configuration with promtool and test failed logins, expired credentials and unauthenticated requests before sign-off.

How we hand over

  • Deliver the written configuration, a credential inventory, and the decision record explaining why basic authentication or a proxy was chosen.
  • Document the steps to add users, rotate passwords and reload configuration without interrupting scraping.
  • Walk your operations team through the runbook so they can reproduce the setup and recognize misconfigurations.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after the initial handover.
  • Retesting after Prometheus upgrades, since release lines move on a defined cycle and older lines stop receiving fixes.
  • Ask any provider to confirm in the quote who maintains the proxy, the certificates and the user list after go-live.

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.