Last active
September 20, 2022 18:03
-
-
Save nishitpatel01/38203da1a5478673163622a4e6e0acbe to your computer and use it in GitHub Desktop.
Query TSI dataset for anomaly or forecasting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create json payload for API query | |
request_body = { | |
"detectionTime": "2021-06-27T15:00:00Z", | |
"slicingParams": { | |
"dimensionNames": ["measure"] | |
}, | |
"timeseriesParams": { | |
"forecastHistory": "259200s", | |
"granularity": "1800s", | |
"metric": "temp", | |
}, | |
"forecastParams": { | |
"noiseThreshold": 50.0, | |
"seasonalityHint": "DAILY" | |
}, | |
"returnTimeseries": "true" | |
} | |
dataset = "sensor-data" | |
# get forecast | |
query_ds_endpt = f'https://timeseriesinsights.googleapis.com/v1/projects/{PROJECT_ID}/datasets/{dataset}:query' | |
res = query_ts(method="POST", endpoint=query_ds_endpt, data=request_body, auth_token=token_array[0]) | |
res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment