Skip to content

Document how to persist prometheus data when the container is recreated #434

@demeringo

Description

@demeringo

Problem

When using the sample docker-compose file, cloud scanner metrics scrapped by prometheus are not persisted if the prometheus container is deleted and recreated.

Reason is that we store data directly inside prometheus container, so data lifecycle is the one of the container.

Solution

Use bind mount an external data volume to the prometheus container.

# Create persistent volume for your data
docker volume create prometheus-data
# Start Prometheus container
docker run \
    -p 9090:9090 \
    -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
    -v prometheus-data:/prometheus \
    prom/prometheus

Update the docker-compose file to use this external data volume instead of the default. This is similar to what we do for grafana: declare the volume , and mount it to the container in the docker-compose file.

Describe this in the documentation.

Alternatives

Additional context or elements

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions