Data Store Metrics Manager repeated queries not updating "ago" time frame

Open
#2,472 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
api, data

Research direction

Start with the Data Store Metrics Manager entry point, dsmm.query, and run the provided Python reproduction with repeated 15-minute queries. Compare the returned timestamp range across calls and trace how ago and ago_unit are applied. Done means repeated queries produce the expected advancing sliding window, accounting for the documented data-ingestion lag.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
It appears that repeated calls to query() for the Data Store Metrics manager are not updating the timeframe based on the ago parameter. For example, when ago is set to 15 (and ago_unit to minutes), and the query is repeated once a minute, the results are always returned for the same time frame on each subsequent call, rather than advancing a minute each time.

The expectation is that "ago" means the query will return the results for the previous period relative to the time at which the query is made. So for ago and ago_unit of 15 and minutes, the result should be a sliding 15-minute window of time. So, if a query is made at 9:00, it should return the results from 8:45-9:00, and if a subsequent call is made at 9:05, it should return the results for 8:50-9:05.

(Noe that there is a several minute lag between the time of a query, and the most recently available data, so a query at 9:00 usually returns data in a range more like 8:45-8:53 or 8:45-8:54.)

The issue is that it appears once a query is made, the timeframe becomes locked, and all subsequent queries -- even minutes later -- still return results for that same initial timeframe, rather than representing a sliding window into the past relative to the time a query is made.

To Reproduce
Steps to reproduce the behavior:

import arcgis
from arcgis.gis import GIS
from datetime import datetime, timezone
import time

# Need to connect with Administrator account for gis.admin to be accessible.
gis = GIS("home")

# Get Data Store Metrics Manager
dsmm = gis.admin.datastore_metrics

# Set the time though which to keep querying the metric, until it is included in what is returned.
stop_at = datetime.now()

# Loop until time range for metrics returned includes the "stop at" time, or exceeded expected number of iterations.
finished = False
iterations = 1
max_iterations = 10
while( not finished and iterations <= max_iterations ):

    # Query a metric for the last 15 minutes.
    metric = dsmm.query(
        metric = arcgis.gis.admin.DataStoreMetric.AVG_CPU,
        bin_size = 1,
        bin_unit = arcgis.gis.admin.DataStoreTimeUnit.MINUTE,
        aggregation = arcgis.gis.admin.DataStoreAggregation.MAX,
        ago = 15,
        ago_unit = arcgis.gis.admin.DataStoreTimeUnit.MINUTE
    )
    
    print(f"Current time: {datetime.now()}, Last record ts: {metric[0]['ts']}, Stop at ts: {stop_at}")
    display(metric)

    # If queried metrics includes the stop_at time, then done, otherwise sleep and try again.
    if( metric[0]['ts'] >= stop_at ):
        finished = True
    else:
        time.sleep(60)
        iterations += 1

print("\nDone")

Output:

Current time: 2026-03-22 21:11:26.589495, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:12:26.595062, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:13:26.597782, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:14:26.599912, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:15:26.602785, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:16:26.605988, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:17:26.608386, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:18:26.610899, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:19:26.612860, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]
Current time: 2026-03-22 21:20:26.614942, Last record ts: 2026-03-22 21:05:00, Stop at ts: 2026-03-22 21:11:25.985634
[{'ts': datetime.datetime(2026, 3, 22, 21, 5), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 4), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 3), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 2), 'value': 3.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 1), 'value': 2.0},
 {'ts': datetime.datetime(2026, 3, 22, 21, 0), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 59), 'value': 5.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 58), 'value': 1.0},
 {'ts': datetime.datetime(2026, 3, 22, 20, 57), 'value': 1.0}]

Done

Note that in the above example, the first query (at 21:12) for the last 15-minutes of data returns data in a time frame of 20:57-21:05, and that the data from each subsequent call one minute later continues to return data from that same timeframe.

Expected behavior
When using the ago and ago_units parameter, I am expecting to be able to define a window of time for the query relative to the time at which the query is run. So if I re-run the query with the same parameters once a minute, I would expect the time window of the results to advance a minute each time as well.

Platform (please complete the following information):

  • OS: 'Windows 11
  • Browser: Chrome
  • Python API Version: 2.4.2 (ArcGIS Online Standard Runtime 13)
Dominant language
Python
Stars
2.2k
Forks
1.1k
Avg merge
2h 40m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Esri/arcgis-python-api

All issues in Esri/arcgis-python-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.