Esri / Esri/arcgis-python-api

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

Offen
#2,472 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
Python
Sterne
2.2k
Forks
1.1k
Ø Merge
2 Std. 40 Min.
Gemergte PRs (30 T.)
2

Beschreibung

**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:
```python
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:
```python
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)

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Data Store Metrics Manager-Einstiegspunkt `dsmm.query` und führe die bereitgestellte Python-Reproduktion mit wiederholten Abfragen über 15 Minuten aus. Vergleiche den zurückgegebenen Zeitstempelbereich zwischen den Aufrufen und verfolge, wie `ago` und `ago_unit` angewendet werden. Die Aufgabe ist abgeschlossen, wenn wiederholte Abfragen das erwartete fortschreitende gleitende Fenster ergeben, unter Berücksichtigung der dokumentierten Verzögerung bei der Datenaufnahme.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, data
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.