Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse graphite time format constant #2588

Merged
merged 1 commit into from
May 25, 2023
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
5 changes: 3 additions & 2 deletions python/nav/metrics/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
_logger = logging.getLogger(__name__)

MAX_TARGETS_PER_REQUEST = 100
GRAPHITE_TIME_FORMAT = "%H:%M_%Y%m%d"


def get_metric_average(target, start="-5min", end="now", ignore_unknown=True):
Expand Down Expand Up @@ -109,9 +110,9 @@ def get_metric_data(target, start="-5min", end="now"):
# What does Graphite accept of formats? Lets check if the parameters are
# datetime objects and try to force a format then
if isinstance(start, datetime):
start = start.strftime('%H:%M%Y%m%d')
start = start.strftime(GRAPHITE_TIME_FORMAT)
if isinstance(end, datetime):
end = end.strftime('%H:%M%Y%m%d')
end = end.strftime(GRAPHITE_TIME_FORMAT)

query = {
'target': target,
Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/sortedstats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from .forms import ViewForm
from . import CLASSMAP, TIMEFRAMES
from nav.metrics.errors import GraphiteUnreachableError
from nav.metrics.data import GRAPHITE_TIME_FORMAT

GRAPHITE_TIME_FORMAT = "%H:%M_%Y%m%d"
_logger = logging.getLogger(__name__)


Expand Down