Skip to content

New Container: Prometheus #1075

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

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