Could not add Timeseries Insights DataSet Owner to the service account

The "Timeseries Insights DataSet Owner" role might not be shown on the UI while Timeseries Insights API is in preview. You can use the role ID roles/timeseriesinsights.datasetsOwner with the gcloud command to grant the necessary access.

 gcloud projects add-iam-policy-binding "${PROJECT_ID}" \
      --member="serviceAccount:${SVC_ACCOUNT}" \
      --role=roles/timeseriesinsights.datasetsOwner \

Also see instructioons at Setup for Full Access.

Anomaly Detection

This section lays out some common debugging steps to understand the Timeseries Insights API responses if they are different from your expectations.

Empty AnomalyDetectionResult

When executing a Timeseries Insights query on a loaded dataset, you might receive a response with empty AnomalyDetectionResult.

Example empty response,
{'anomalyDetectionResult': {},
 'name': 'projects/demo-project/datasets/demo-dataset'}

To get more insights, set returnNonAnomalies to true in the query request body,

Your query.json,
  "detectionTime": ...
  "slicingParams": { ... }
  "timeseriesParams": { ... }
  "forecastParams": { ... }
  "returnNonAnomalies": true

In addition, start with a ForecastParams.sensitivity = 1.0 and ForecastParams.noiseThreshold = 0.0. Fine tune these parameters for better precision later. See the ForecastParams configuration for detailed examples.

If still getting an empty AnomalyDetectionResult, you can alternatively try to query for an explicit slice that you expect to be present in the dataset by using the evaluateSlice API. This will force the system to return the time series for the given slice alongside with its evaluation status.

Also see examples of how to use slicingParams at the Query building Guide.

ForecastResult.label INSUFFICIENT_DATA

When executing a Timeseries Insights API query or evaluateSlice, you might observe INSUFFICIENT_DATA as the per slice ForecastResultLabel. This means that we don't have enough data to classify the particular slices.

status code: 3. message: Got density = xx. Min density = yy

If there is any status in ForecastSlice, and it looks like,

"status": {
  "code": 3,
  "message": "Got density = 1. Min density = 90"

In this example, the user asked Timeseries Insights API to make the classification if 90% of the data points present in the requested time intervals [detectionTime - TimeseriesParams.forecastHistory, detectionTime]. Timeseries Insights API could not provide a classification because only 1% of the data points were non-empty in the time series interval.

Try to experiment with the following parameters in the request to understand why the the data points might not exist.

  • detectionTime and TimeseriesParams

    • Make sure that [detectionTime - TimeseriesParams.forecastHistory, detectionTime + TimeseriesParams.granularity] is a subrange of all the events available in your dataset so that there is enough history for Timeseries Insights API to work with. This might require you to choose a detectionTime that is close to the end of the time series.

    Timeseries Insights API builds a time series by going back in time from the detectionTime. How much we go back in time and how many points are included in the time series are determined by TimeseriesParams.forecastHistory and TimeseriesParams.granularity,

    • Start with a minDensity = 0.0 if uncertain about the actual density of the events in the dataset. Fine tune the parameter for better precision later.

    Also see the Timeseries concept for parameters definitions and Timeseries configuration for more examples.