Skip to content

Commit

Permalink
configurable query_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Szefler committed Jul 5, 2024
1 parent d3450e6 commit 0e9d2bd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions prometrix/models/prometheus_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PrometheusConfig(BaseModel):
PrometheusApis.FLAGS,
]
query_step: str = "5m"
query_interval: str = "1d"


class AWSPrometheusConfig(PrometheusConfig):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ optional = true

[tool.poetry.group.test.dependencies]
pyyaml = "^6.0.0"
pytimeparse = "^1.1.0"

[build-system]
requires = ["poetry-core"]
Expand Down
1 change: 1 addition & 0 deletions tests/config_github_kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ testConfig:
params:
url: http://localhost:9090
query_step: "5s"
query_interval: "15s"
3 changes: 2 additions & 1 deletion tests/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import yaml
from prometheus_api_client import PrometheusApiClientException
from pydantic import ValidationError
from pytimeparse import parse as parse_timedelta

from prometrix import (AWSPrometheusConfig, AzurePrometheusConfig,
CoralogixPrometheusConfig, CustomPrometheusConnect,
Expand Down Expand Up @@ -56,7 +57,7 @@ def run_test(test_type: str, config: PrometheusConfig) -> bool:
return False
result = prom_cli.safe_custom_query_range(
query="container_memory_working_set_bytes",
start_time=datetime.now() - timedelta(days=1),
start_time=datetime.now() - parse_timedelta(config.query_interval),
end_time=datetime.now(),
step=config.query_step,
)
Expand Down

0 comments on commit 0e9d2bd

Please sign in to comment.