Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions asap-tools/experiments/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

PROMETHEUS_CONFIG_DIR = "prometheus_config"
PROMETHEUS_CONFIG_FILE = "prometheus.yml"
# Long-window baseline queries can run for minutes; Prometheus would cancel
# them after its 2-minute default.
PROMETHEUS_QUERY_TIMEOUT = "24h"
# The 50M default rejects 24h windows over a few hundred 1s-scraped series.
# Peak query memory is roughly 16 B per sample (~8 GB at this cap).
PROMETHEUS_QUERY_MAX_SAMPLES = 500_000_000
PROMETHEUS_REMOTE_WRITE_ENDPOINT = "/api/v1/write"
HTTP_READINESS_CURL_TIMEOUT_SECONDS = 5
QUERY_ENGINE_RUNTIME_INFO_ENDPOINT = "/api/v1/status/runtimeinfo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ services:
command:
- "-storageDataPath=/victoria-metrics-data"
- "-httpListenAddr=:8428"
- "-retentionPeriod=1d"
# Keep a 24 h window plus the run, and let long-window queries finish
# (the defaults are 30 s per query and 10 s waiting in the queue).
- "-retentionPeriod=3d"
- "-search.maxQueryDuration=24h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, VictoriaMetrics has per-query limits besides duration: -search.maxPointsPerTimeseries (default 30000), -search.maxSamplesPerSeries, -search.maxSamplesPerQuery, -search.maxUniqueTimeseries. Long-window/many-series queries can be rejected with a limit-exceeded error, so the 6h/24h baselines could still fail.

- "-search.maxQueueDuration=24h"
# Raise the per-query caps so 24 h windows over many series aren't rejected.
- "-search.maxSamplesPerQuery=10000000000"
- "-search.maxPointsPerTimeseries=1000000"
{% if cpu_limit or memory_limit -%}
deploy:
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

from .base import DockerServiceBase
from experiment_utils.providers.base import InfrastructureProvider
from constants import PROMETHEUS_CONFIG_DIR, PROMETHEUS_CONFIG_FILE
from constants import (
PROMETHEUS_CONFIG_DIR,
PROMETHEUS_CONFIG_FILE,
PROMETHEUS_QUERY_MAX_SAMPLES,
PROMETHEUS_QUERY_TIMEOUT,
)


class DockerPrometheusService(DockerServiceBase):
Expand Down Expand Up @@ -98,6 +103,8 @@ def start(
"--web.console.libraries=/etc/prometheus/console_libraries",
"--web.console.templates=/etc/prometheus/consoles",
"--web.enable-lifecycle",
f"--query.timeout={PROMETHEUS_QUERY_TIMEOUT}",
f"--query.max-samples={PROMETHEUS_QUERY_MAX_SAMPLES}",
]
)

Expand Down
14 changes: 12 additions & 2 deletions asap-tools/experiments/experiment_utils/services/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

from .base import BaseService
from experiment_utils.providers.base import InfrastructureProvider
from constants import PROMETHEUS_CONFIG_DIR, PROMETHEUS_CONFIG_FILE
from constants import (
PROMETHEUS_CONFIG_DIR,
PROMETHEUS_CONFIG_FILE,
PROMETHEUS_QUERY_MAX_SAMPLES,
PROMETHEUS_QUERY_TIMEOUT,
)


class PrometheusService(BaseService):
Expand Down Expand Up @@ -89,7 +94,12 @@ def _start_prometheus(self, experiment_output_dir: str) -> None:
time.sleep(3)

# Start prometheus
cmd = f"./prometheus --config.file={PROMETHEUS_CONFIG_FILE} > /dev/null 2>&1 < /dev/null &"
cmd = (
f"./prometheus --config.file={PROMETHEUS_CONFIG_FILE}"
f" --query.timeout={PROMETHEUS_QUERY_TIMEOUT}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising --query.timeout alone may not be enough: Prometheus also caps --query.max-samples (default 50M). A 24h *_over_time over many series can exceed it and fail immediately with "query processing would load too many samples into memory", regardless of the timeout. Same applies to docker_prometheus.py.

f" --query.max-samples={PROMETHEUS_QUERY_MAX_SAMPLES}"
" > /dev/null 2>&1 < /dev/null &"
)
self.provider.execute_command(
node_idx=self.node_offset,
cmd=cmd,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Tuple
from requests.adapters import HTTPAdapter

from .query_client import QueryClient, QueryResponse
Expand All @@ -15,7 +15,9 @@ def __init__(
database: str = "default",
user: str = "default",
password: str = "",
timeout: int = 30,
# (connect, read): long-window baseline queries can take minutes, but a
# dead server must still fail instead of hanging the querier.
timeout: Tuple[float, float] = (10, 24 * 60 * 60),
**kwargs: Any,
):
super().__init__(server_url, server_name)
Expand Down Expand Up @@ -96,7 +98,7 @@ def execute_query(
return QueryResponse(
success=False,
data=None,
error_message=f"Request timed out after {self.timeout}s",
error_message=f"Request timed out (connect, read timeout: {self.timeout}s)",
)
except Exception as e:
return QueryResponse(
Expand Down
Loading