Skip to content

New Container: Prometheus #1075

Open
Open

Description

@aeroyorch

Feature Request: PrometheusContainer

What is the new container you'd like to have?

I'd like to propose a PrometheusContainer for integration testing with Prometheus.

Relevant resources:

Besides exposing the Prometheus UI/API, it could provide convenience methods to configure scrape targets and rules directly, without requiring users to write and mount a complete prometheus.yml, for example:

prometheus = (
    PrometheusContainer()
    .with_scrape_target("app", app_container, port=8080, metrics_path="/metrics")
    .with_scrape_target("redis", redis_exporter)
)

The container could generate the corresponding prometheus.yml internally while still allowing users to provide a custom configuration file if needed.

Why not just use a generic container for this?

While DockerContainer("prom/prometheus") works, most tests usually need additional setup:

  • Configuring scrape targets.
  • Providing a Prometheus configuration.
  • Waiting until Prometheus is ready to accept requests.
  • Reload Prometheus on config change.
  • etc.

Other references

A similar idea has already been discussed in the testcontainers-java

Activity

  1. alexanderankin commented on Jul 5, 2026

    @alexanderankin
    Member

    very reasonable, configuring these things is a nightmare, see if you can make your changes forwards compatible with a future lgtm container per #733

  2. aeroyorch commented on Jul 5, 2026

    @aeroyorch
    Author

    very reasonable, configuring these things is a nightmare, see if you can make your changes forwards compatible with a future lgtm container per #733

    What do you mean by "forward compatible"? grafana-otel-lgtm seems to be an all-in-one container that includes Prometheus along with several other services.

  3. alexanderankin commented on Jul 5, 2026

    @alexanderankin
    Member

    i mean like put it in a place that would make it obvious that the prometheus and lgtm container belong to one area/together

  4. aeroyorch commented on Jul 5, 2026

    @aeroyorch
    Author

    Ah, you mean in terms of an optional dependency group, right? In that case, maybe an observability extra would fit both.

  5. alexanderankin commented on Jul 5, 2026

    @alexanderankin
    Member
  6. aeroyorch commented on Jul 5, 2026

    @aeroyorch
    Author

    I don't know if I'd lean towards two separate groups, following the existing testcontainers structure:

    • prometheus: PrometheusContainer (and potentially AlertManagerContainer in the future)
    • grafana: Grafana-related components

    They're different providers, even if they're often used together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions