timeseries_insights.proto 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.timeseriesinsights.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/protobuf/duration.proto";
  21. import "google/protobuf/empty.proto";
  22. import "google/protobuf/timestamp.proto";
  23. import "google/rpc/status.proto";
  24. option cc_enable_arenas = true;
  25. option go_package = "google.golang.org/genproto/googleapis/cloud/timeseriesinsights/v1;timeseriesinsights";
  26. option java_multiple_files = true;
  27. option java_outer_classname = "TimeseriesInsightsProto";
  28. option java_package = "com.google.cloud.timeseriesinsights.v1";
  29. service TimeseriesInsightsController {
  30. option (google.api.default_host) = "timeseriesinsights.googleapis.com";
  31. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  32. // Lists [DataSets][google.cloud.timeseriesinsights.v1.DataSet] under the project.
  33. //
  34. // The order of the results is unspecified but deterministic. Newly created
  35. // [DataSets][google.cloud.timeseriesinsights.v1.DataSet] will not necessarily be added to the end
  36. // of this list.
  37. rpc ListDataSets(ListDataSetsRequest) returns (ListDataSetsResponse) {
  38. option (google.api.http) = {
  39. get: "/v1/{parent=projects/*/locations/*}/datasets"
  40. additional_bindings {
  41. get: "/v1/{parent=projects/*}/datasets"
  42. }
  43. };
  44. option (google.api.method_signature) = "parent";
  45. }
  46. // Create a [DataSet][google.cloud.timeseriesinsights.v1.DataSet] from data stored on Cloud
  47. // Storage.
  48. //
  49. // The data must stay immutable while we process the
  50. // [DataSet][google.cloud.timeseriesinsights.v1.DataSet] creation; otherwise, undefined outcomes
  51. // might result. For more information, see [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
  52. rpc CreateDataSet(CreateDataSetRequest) returns (DataSet) {
  53. option (google.api.http) = {
  54. post: "/v1/{parent=projects/*/locations/*}/datasets"
  55. body: "dataset"
  56. additional_bindings {
  57. post: "/v1/{parent=projects/*}/datasets"
  58. body: "dataset"
  59. }
  60. };
  61. option (google.api.method_signature) = "parent,dataset";
  62. }
  63. // Delete a [DataSet][google.cloud.timeseriesinsights.v1.DataSet] from the system.
  64. //
  65. // **NOTE**: If the [DataSet][google.cloud.timeseriesinsights.v1.DataSet] is still being
  66. // processed, it will be aborted and deleted.
  67. rpc DeleteDataSet(DeleteDataSetRequest) returns (google.protobuf.Empty) {
  68. option (google.api.http) = {
  69. delete: "/v1/{name=projects/*/locations/*/datasets/*}"
  70. additional_bindings {
  71. delete: "/v1/{name=projects/*/datasets/*}"
  72. }
  73. };
  74. option (google.api.method_signature) = "name";
  75. }
  76. // Append events to a `LOADED` [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
  77. rpc AppendEvents(AppendEventsRequest) returns (AppendEventsResponse) {
  78. option (google.api.http) = {
  79. post: "/v1/{dataset=projects/*/locations/*/datasets/*}:appendEvents"
  80. body: "*"
  81. additional_bindings {
  82. post: "/v1/{dataset=projects/*/datasets/*}:appendEvents"
  83. body: "*"
  84. }
  85. };
  86. option (google.api.method_signature) = "dataset,events";
  87. }
  88. // Execute a Timeseries Insights query over a loaded
  89. // [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
  90. rpc QueryDataSet(QueryDataSetRequest) returns (QueryDataSetResponse) {
  91. option (google.api.http) = {
  92. post: "/v1/{name=projects/*/locations/*/datasets/*}:query"
  93. body: "*"
  94. additional_bindings {
  95. post: "/v1/{name=projects/*/datasets/*}:query"
  96. body: "*"
  97. }
  98. };
  99. }
  100. // Evaluate an explicit slice from a loaded [DataSet][google.cloud.timeseriesinsights.v1.DataSet].
  101. rpc EvaluateSlice(EvaluateSliceRequest) returns (EvaluatedSlice) {
  102. option (google.api.http) = {
  103. post: "/v1/{dataset=projects/*/locations/*/datasets/*}:evaluateSlice"
  104. body: "*"
  105. additional_bindings {
  106. post: "/v1/{dataset=projects/*/datasets/*}:evaluateSlice"
  107. body: "*"
  108. }
  109. };
  110. }
  111. // Evaluate an explicit timeseries.
  112. rpc EvaluateTimeseries(EvaluateTimeseriesRequest) returns (EvaluatedSlice) {
  113. option (google.api.http) = {
  114. post: "/v1/{parent=projects/*/locations/*}/datasets:evaluateTimeseries"
  115. body: "*"
  116. additional_bindings {
  117. post: "/v1/{parent=projects/*}/datasets:evaluateTimeseries"
  118. body: "*"
  119. }
  120. };
  121. }
  122. }
  123. // Mapping of BigQuery columns to timestamp, group_id and dimensions.
  124. message BigqueryMapping {
  125. // The column which should be used as the event timestamps. If not specified
  126. // 'Timestamp' is used by default. The column may have TIMESTAMP or INT64
  127. // type (the latter is interpreted as microseconds since the Unix epoch).
  128. string timestamp_column = 1;
  129. // The column which should be used as the group ID (grouping events into
  130. // sessions). If not specified 'GroupId' is used by default, if the input
  131. // table does not have such a column, random unique group IDs are
  132. // generated automatically (different group ID per input row).
  133. string group_id_column = 2;
  134. // The list of columns that should be translated to dimensions. If empty,
  135. // all columns are translated to dimensions. The timestamp and group_id
  136. // columns should not be listed here again. Columns are expected to have
  137. // primitive types (STRING, INT64, FLOAT64 or NUMERIC).
  138. repeated string dimension_column = 3;
  139. }
  140. // A data source consists of multiple [Event][google.cloud.timeseriesinsights.v1.Event] objects stored on
  141. // Cloud Storage. Each Event should be in JSON format, with one Event
  142. // per line, also known as JSON Lines format.
  143. message DataSource {
  144. // Data source URI.
  145. //
  146. // 1) Google Cloud Storage files (JSON) are defined in the following form.
  147. // `gs://bucket_name/object_name`. For more information on Cloud Storage URIs,
  148. // please see https://cloud.google.com/storage/docs/reference-uris.
  149. string uri = 1;
  150. // For BigQuery inputs defines the columns that should be used for dimensions
  151. // (including time and group ID).
  152. BigqueryMapping bq_mapping = 2;
  153. }
  154. // A collection of data sources sent for processing.
  155. message DataSet {
  156. option (google.api.resource) = {
  157. type: "timeseriesinsights.googleapis.com/Dataset"
  158. pattern: "projects/{project}/datasets/{dataset}"
  159. pattern: "projects/{project}/locations/{location}/datasets/{dataset}"
  160. };
  161. // DataSet state.
  162. enum State {
  163. // Unspecified / undefined state.
  164. STATE_UNSPECIFIED = 0;
  165. // Dataset is unknown to the system; we have never seen this dataset before
  166. // or we have seen this dataset but have fully GC-ed it.
  167. UNKNOWN = 1;
  168. // Dataset processing is pending.
  169. PENDING = 2;
  170. // Dataset is loading.
  171. LOADING = 3;
  172. // Dataset is loaded and can be queried.
  173. LOADED = 4;
  174. // Dataset is unloading.
  175. UNLOADING = 5;
  176. // Dataset is unloaded and is removed from the system.
  177. UNLOADED = 6;
  178. // Dataset processing failed.
  179. FAILED = 7;
  180. }
  181. // The dataset name, which will be used for querying, status and unload
  182. // requests. This must be unique within a project.
  183. string name = 1;
  184. // [Data dimension names][google.cloud.timeseriesinsights.v1.EventDimension.name] allowed for this `DataSet`.
  185. //
  186. // If left empty, all dimension names are included. This field works as a
  187. // filter to avoid regenerating the data.
  188. repeated string data_names = 2;
  189. // Input data.
  190. repeated DataSource data_sources = 3;
  191. // Dataset state in the system.
  192. State state = 4;
  193. // Dataset processing status.
  194. google.rpc.Status status = 5;
  195. // Periodically we discard dataset [Event][google.cloud.timeseriesinsights.v1.Event] objects that have
  196. // timestamps older than 'ttl'. Omitting this field or a zero value means no
  197. // events are discarded.
  198. google.protobuf.Duration ttl = 6;
  199. }
  200. // Represents an event dimension.
  201. message EventDimension {
  202. // Dimension name.
  203. //
  204. // **NOTE**: `EventDimension` names must be composed of alphanumeric
  205. // characters only, and are case insensitive. Unicode characters are *not*
  206. // supported. The underscore '_' is also allowed.
  207. string name = 1;
  208. // Dimension value.
  209. //
  210. // **NOTE**: All entries of the dimension `name` must have the same `value`
  211. // type.
  212. oneof value {
  213. // String representation.
  214. //
  215. // **NOTE**: String values are case insensitive. Unicode characters are
  216. // supported.
  217. string string_val = 2;
  218. // Long representation.
  219. int64 long_val = 3;
  220. // Bool representation.
  221. bool bool_val = 4;
  222. // Double representation.
  223. double double_val = 5;
  224. }
  225. }
  226. // Represents an entry in a data source.
  227. //
  228. // Each Event has:
  229. //
  230. // * A timestamp at which the event occurs.
  231. // * One or multiple dimensions.
  232. // * Optionally, a group ID that allows clients to group logically related
  233. // events (for example, all events representing payments transactions done by
  234. // a user in a day have the same group ID). If a group ID is not provided, an
  235. // internal one will be generated based on the content and `eventTime`.
  236. //
  237. // **NOTE**:
  238. //
  239. // * Internally, we discretize time in equal-sized chunks and we assume an
  240. // event has a 0
  241. // [TimeseriesPoint.value][google.cloud.timeseriesinsights.v1.TimeseriesPoint.value]
  242. // in a chunk that does not contain any occurrences of an event in the input.
  243. // * The number of Events with the same group ID should be limited.
  244. // * Group ID *cannot* be queried.
  245. // * Group ID does *not* correspond to a user ID or the like. If a user ID is of
  246. // interest to be queried, use a user ID `dimension` instead.
  247. message Event {
  248. // Event dimensions.
  249. repeated EventDimension dimensions = 1;
  250. // Event group ID.
  251. //
  252. // **NOTE**: JSON encoding should use a string to hold a 64-bit integer value,
  253. // because a native JSON number holds only 53 binary bits for an integer.
  254. int64 group_id = 2;
  255. // Event timestamp.
  256. google.protobuf.Timestamp event_time = 3;
  257. }
  258. // Appends events to an existing DataSet.
  259. message AppendEventsRequest {
  260. // Events to be appended.
  261. //
  262. // Note:
  263. //
  264. // 0. The [DataSet][google.cloud.timeseriesinsights.v1.DataSet] must be shown in a `LOADED` state
  265. // in the results of `list` method; otherwise, all events from
  266. // the append request will be dropped, and a `NOT_FOUND` status will be
  267. // returned.
  268. // 0. All events in a single request must have the same
  269. // [groupId][google.cloud.timeseriesinsights.v1.Event.group_id] if set; otherwise, an
  270. // `INVALID_ARGUMENT` status will be returned.
  271. // 0. If [groupId][google.cloud.timeseriesinsights.v1.Event.group_id] is not set (or 0), there
  272. // should be only 1 event; otherwise, an `INVALID_ARGUMENT` status will be
  273. // returned.
  274. // 0. The events must be newer than the current time minus
  275. // [DataSet TTL][google.cloud.timeseriesinsights.v1.DataSet.ttl] or they will be dropped.
  276. repeated Event events = 1;
  277. // Required. The DataSet to which we want to append to in the format of
  278. // "projects/{project}/datasets/{dataset}"
  279. string dataset = 2 [
  280. (google.api.field_behavior) = REQUIRED,
  281. (google.api.resource_reference) = {
  282. type: "timeseriesinsights.googleapis.com/Dataset"
  283. }
  284. ];
  285. }
  286. // Response for an AppendEvents RPC.
  287. message AppendEventsResponse {
  288. // Dropped events; empty if all events are successfully added.
  289. repeated Event dropped_events = 1;
  290. }
  291. // Create a DataSet request.
  292. message CreateDataSetRequest {
  293. // Required. Client project name which will own this DataSet in the format of
  294. // 'projects/{project}'.
  295. string parent = 1 [
  296. (google.api.field_behavior) = REQUIRED,
  297. (google.api.resource_reference) = {
  298. type: "cloudresourcemanager.googleapis.com/Project"
  299. }
  300. ];
  301. // Required. Dataset to be loaded.
  302. DataSet dataset = 2 [(google.api.field_behavior) = REQUIRED];
  303. }
  304. // Unload DataSet request from the serving system.
  305. message DeleteDataSetRequest {
  306. // Required. Dataset name in the format of "projects/{project}/datasets/{dataset}"
  307. string name = 1 [
  308. (google.api.field_behavior) = REQUIRED,
  309. (google.api.resource_reference) = {
  310. type: "timeseriesinsights.googleapis.com/Dataset"
  311. }
  312. ];
  313. }
  314. // List the DataSets created by the current project.
  315. message ListDataSetsRequest {
  316. // Required. Project owning the DataSet in the format of "projects/{project}".
  317. string parent = 1 [
  318. (google.api.field_behavior) = REQUIRED,
  319. (google.api.resource_reference) = {
  320. type: "cloudresourcemanager.googleapis.com/Project"
  321. }
  322. ];
  323. // Number of results to return in the list.
  324. int32 page_size = 2;
  325. // Token to provide to skip to a particular spot in the list.
  326. string page_token = 3;
  327. }
  328. // Created DataSets list response.
  329. message ListDataSetsResponse {
  330. // The list of created DataSets.
  331. repeated DataSet datasets = 1;
  332. // Token to receive the next page of results.
  333. string next_page_token = 2;
  334. }
  335. // A categorical dimension fixed to a certain value.
  336. message PinnedDimension {
  337. // The name of the dimension for which we are fixing its value.
  338. string name = 1;
  339. // Dimension value.
  340. //
  341. // **NOTE**: The `value` type must match that in the data with the same
  342. // `dimension` as name.
  343. oneof value {
  344. // A string value. This can be used for [dimensions][google.cloud.timeseriesinsights.v1.EventDimension], which
  345. // have their value field set to [string_val][google.cloud.timeseriesinsights.v1.EventDimension.string_val].
  346. string string_val = 2;
  347. // A bool value. This can be used for [dimensions][google.cloud.timeseriesinsights.v1.EventDimension], which
  348. // have their value field set to [bool_val][google.cloud.timeseriesinsights.v1.EventDimension.bool_val].
  349. bool bool_val = 3;
  350. }
  351. }
  352. // Parameters that control the sensitivity and other options for the time series
  353. // forecast.
  354. message ForecastParams {
  355. // A time period of a fixed interval.
  356. enum Period {
  357. // Unknown or simply not given.
  358. PERIOD_UNSPECIFIED = 0;
  359. // 1 hour
  360. HOURLY = 5;
  361. // 24 hours
  362. DAILY = 1;
  363. // 7 days
  364. WEEKLY = 2;
  365. // 30 days
  366. MONTHLY = 3;
  367. // 365 days
  368. YEARLY = 4;
  369. }
  370. // Optional. Penalize variations between the actual and forecasted values smaller than
  371. // this. For more information about how this parameter affects the score, see
  372. // the [anomalyScore](EvaluatedSlice.anomaly_score) formula.
  373. //
  374. // Intuitively, anomaly scores summarize how statistically significant the
  375. // change between the actual and forecasted value is compared with what we
  376. // expect the change to be (see
  377. // [expectedDeviation](EvaluatedSlice.expected_deviation)). However, in
  378. // practice, depending on the application, changes smaller than certain
  379. // absolute values, while statistically significant, may not be important.
  380. //
  381. // This parameter allows us to penalize such low absolute value changes.
  382. //
  383. // Must be in the (0.0, inf) range.
  384. //
  385. // If unspecified, it defaults to 0.000001.
  386. optional double noise_threshold = 12 [(google.api.field_behavior) = OPTIONAL];
  387. // Optional. Specifying any known seasonality/periodicity in the time series
  388. // for the slices we will analyze can improve the quality of the results.
  389. //
  390. // If unsure, simply leave it unspecified by not setting a value for this
  391. // field.
  392. //
  393. // If your time series has multiple seasonal patterns, then set it to the most
  394. // granular one (e.g. if it has daily and weekly patterns, set this to DAILY).
  395. Period seasonality_hint = 10 [(google.api.field_behavior) = OPTIONAL];
  396. // Optional. The length of the returned [forecasted
  397. // timeseries][EvaluatedSlice.forecast].
  398. //
  399. // This duration is currently capped at 100 x
  400. // [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity].
  401. //
  402. // Example: If the detection point is set to "2020-12-27T00:00:00Z", the
  403. // [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] to "3600s" and the
  404. // horizon_duration to "10800s", then we will generate 3 time
  405. // series points (from "2020-12-27T01:00:00Z" to "2020-12-27T04:00:00Z"), for
  406. // which we will return their forecasted values.
  407. //
  408. // Note: The horizon time is only used for forecasting not for anormaly
  409. // detection. To detect anomalies for multiple points of time,
  410. // simply send multiple queries with those as
  411. // [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time].
  412. google.protobuf.Duration horizon_duration = 13 [(google.api.field_behavior) = OPTIONAL];
  413. }
  414. // A point in a time series.
  415. message TimeseriesPoint {
  416. // The timestamp of this point.
  417. google.protobuf.Timestamp time = 1;
  418. // The value for this point.
  419. //
  420. // It is computed by aggregating all events in the associated slice that are
  421. // in the `[time, time + granularity]` range (see
  422. // [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]) using the specified
  423. // [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric].
  424. optional double value = 2;
  425. }
  426. // A time series.
  427. message Timeseries {
  428. // The points in this time series, ordered by their timestamp.
  429. repeated TimeseriesPoint point = 1;
  430. }
  431. // Forecast result for a given slice.
  432. message EvaluatedSlice {
  433. // Values for all categorical dimensions that uniquely identify this slice.
  434. repeated PinnedDimension dimensions = 1;
  435. // The actual value at the detection time (see
  436. // [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]).
  437. //
  438. // **NOTE**: This value can be an estimate, so it should not be used as a
  439. // source of truth.
  440. optional double detection_point_actual = 11;
  441. // The expected value at the detection time, which is obtained by forecasting
  442. // on the historical time series.
  443. optional double detection_point_forecast = 12;
  444. // How much our forecast model expects the detection point actual will
  445. // deviate from its forecasted value based on how well it fit the input time
  446. // series.
  447. //
  448. // In general, we expect the `detectionPointActual` to
  449. // be in the `[detectionPointForecast - expectedDeviation,
  450. // detectionPointForecast + expectedDeviation]` range. The more the actual
  451. // value is outside this range, the more statistically significant the
  452. // anomaly is.
  453. //
  454. // The expected deviation is always positive.
  455. optional double expected_deviation = 16;
  456. // Summarizes how significant the change between the actual and forecasted
  457. // detection points are compared with the historical patterns observed on the
  458. // [history][google.cloud.timeseriesinsights.v1.EvaluatedSlice.history] time series.
  459. //
  460. // Defined as *|a - f| / (e + nt)*, where:
  461. //
  462. // - *a* is the [detectionPointActual][google.cloud.timeseriesinsights.v1.EvaluatedSlice.detection_point_actual].
  463. // - *f* is the [detectionPointForecast][google.cloud.timeseriesinsights.v1.EvaluatedSlice.detection_point_forecast].
  464. // - *e* is the [expectedDeviation][google.cloud.timeseriesinsights.v1.EvaluatedSlice.expected_deviation].
  465. // - *nt` is the [noiseThreshold][google.cloud.timeseriesinsights.v1.ForecastParams.noise_threshold].
  466. //
  467. // Anomaly scores between different requests and datasets are comparable. As
  468. // a guideline, the risk of a slice being an anomaly based on the anomaly
  469. // score is:
  470. //
  471. // - **Very High** if `anomalyScore` > 5.
  472. // - **High** if the `anomalyScore` is in the [2, 5] range.
  473. // - **Medium** if the `anomalyScore` is in the [1, 2) range.
  474. // - **Low** if the `anomalyScore` is < 1.
  475. //
  476. // If there were issues evaluating this slice, then the anomaly score will be
  477. // set to -1.0 and the [status][google.cloud.timeseriesinsights.v1.EvaluatedSlice.status] field will contain details on what
  478. // went wrong.
  479. optional double anomaly_score = 17;
  480. // The actual values in the `[`
  481. // [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] `-`
  482. // [forecastHistory][google.cloud.timeseriesinsights.v1.TimeseriesParams.forecast_history]`,`
  483. // [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] `]` time
  484. // range.
  485. //
  486. // **NOTE**: This field is only populated if
  487. // [returnTimeseries][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.return_timeseries] is true.
  488. Timeseries history = 5;
  489. // The forecasted values in the `[`
  490. // [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] `+`
  491. // [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]`,`
  492. // [forecastParams.horizonTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.forecast_params] `]` time
  493. // range.
  494. //
  495. // **NOTE**: This field is only populated if
  496. // [returnTimeseries][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.return_timeseries] is true.
  497. Timeseries forecast = 10;
  498. // Evaluation status. Contains an error message if the `anomalyScore` is < 0.
  499. //
  500. // Possible error messages:
  501. //
  502. // - **"Time series too sparse"**: The returned time series for this slice did
  503. // not contain enough data points (we require a minimum of 10).
  504. // - **"Not enough recent time series points"**: The time series contains the
  505. // minimum of 10 points, but there are not enough close in time to the
  506. // detection point.
  507. // - **"Missing detection point data"**: There were not events to be
  508. // aggregated within the `[detectionTime, detectionTime + granularity]` time
  509. // interval, so we don't have an actual value with which we can compare our
  510. // prediction.
  511. // - **"Data retrieval error"**: We failed to retrieve the time series data
  512. // for this slice and could not evaluate it successfully. Should be a
  513. // transient error.
  514. // - **"Internal server error"**: Internal unexpected error.
  515. google.rpc.Status status = 18;
  516. }
  517. // Parameters that control how we slice the dataset and, optionally, filter
  518. // slices that have some specific values on some dimensions (pinned dimensions).
  519. message SlicingParams {
  520. // Required. Dimensions over which we will group the events in slices. The names
  521. // specified here come from the
  522. // [EventDimension.name][google.cloud.timeseriesinsights.v1.EventDimension.name] field. At least
  523. // one dimension name must be specified. All dimension names that do not exist
  524. // in the queried `DataSet` will be ignored.
  525. //
  526. // Currently only dimensions that hold string values can be specified here.
  527. repeated string dimension_names = 1 [(google.api.field_behavior) = REQUIRED];
  528. // Optional. We will only analyze slices for which
  529. // [EvaluatedSlice.dimensions][google.cloud.timeseriesinsights.v1.EvaluatedSlice.dimensions] contain all of the
  530. // following pinned dimensions. A query with a pinned dimension `{ name: "d3"
  531. // stringVal: "v3" }` will only analyze events which contain the dimension `{
  532. // name: "d3" stringVal: "v3" }`.
  533. // The [pinnedDimensions][google.cloud.timeseriesinsights.v1.SlicingParams.pinned_dimensions] and
  534. // [dimensionNames][google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names] fields can **not**
  535. // share the same dimension names.
  536. //
  537. // Example a valid specification:
  538. //
  539. // ```json
  540. // {
  541. // dimensionNames: ["d1", "d2"],
  542. // pinnedDimensions: [
  543. // { name: "d3" stringVal: "v3" },
  544. // { name: "d4" stringVal: "v4" }
  545. // ]
  546. // }
  547. // ```
  548. //
  549. // In the previous example we will slice the dataset by dimensions "d1",
  550. // "d2", "d3" and "d4", but we will only analyze slices for which "d3=v3" and
  551. // "d4=v4".
  552. //
  553. // The following example is **invalid** as "d2" is present in both
  554. // dimensionNames and pinnedDimensions:
  555. //
  556. // ```json
  557. // {
  558. // dimensionNames: ["d1", "d2"],
  559. // pinnedDimensions: [
  560. // { name: "d2" stringVal: "v2" },
  561. // { name: "d4" stringVal: "v4" }
  562. // ]
  563. // }
  564. // ```
  565. repeated PinnedDimension pinned_dimensions = 2 [(google.api.field_behavior) = OPTIONAL];
  566. }
  567. // Parameters that control how we construct the time series for each slice.
  568. message TimeseriesParams {
  569. // Methods by which we can aggregate multiple events by a given
  570. // [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric].
  571. enum AggregationMethod {
  572. // Unspecified.
  573. AGGREGATION_METHOD_UNSPECIFIED = 0;
  574. // Aggregate multiple events by summing up the values found in the
  575. // [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] dimension.
  576. SUM = 1;
  577. // Aggregate multiple events by averaging out the values found in the
  578. // [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] dimension.
  579. AVERAGE = 2;
  580. }
  581. // Required. How long should we go in the past when fetching the timeline used for
  582. // forecasting each slice.
  583. //
  584. // This is used in combination with the
  585. // [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] parameter.
  586. // The time series we construct will have the following time range:
  587. // `[detectionTime - forecastHistory, detectionTime + granularity]`.
  588. //
  589. // The forecast history might be rounded up, so that a multiple of
  590. // `granularity` is used to process the query.
  591. //
  592. // Note: If there are not enough events in the
  593. // `[detectionTime - forecastHistory, detectionTime + granularity]` time
  594. // interval, the slice evaluation can fail. For more information, see
  595. // [EvaluatedSlice.status][google.cloud.timeseriesinsights.v1.EvaluatedSlice.status].
  596. google.protobuf.Duration forecast_history = 1 [(google.api.field_behavior) = REQUIRED];
  597. // Required. The time granularity of the time series (on the x-axis). Each time series
  598. // point starting at time T will aggregate all events for a particular slice
  599. // in *[T, T + granularity)* time windows.
  600. //
  601. // Note: The aggregation is decided based on the
  602. // [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] parameter.
  603. //
  604. // This granularity defines the query-time aggregation windows and is not
  605. // necessarily related to any event time granularity in the raw data (though
  606. // we do recommend that the query-time granularity is not finer than the
  607. // ingestion-time one).
  608. //
  609. // Currently, the minimal supported granularity is 10 seconds.
  610. google.protobuf.Duration granularity = 2 [(google.api.field_behavior) = REQUIRED];
  611. // Optional. Denotes the [name][google.cloud.timeseriesinsights.v1.EventDimension.name] of a numerical
  612. // dimension that will have its values aggregated to compute the y-axis of the
  613. // time series.
  614. //
  615. // The aggregation method must also be specified by setting the
  616. // [metricAggregationMethod][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method]
  617. // field.
  618. //
  619. // Note: Currently, if the aggregation method is unspecified, we will
  620. // default to SUM for backward compatibility reasons, but new implementations
  621. // should set the
  622. // [metricAggregationMethod][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method]
  623. // explicitly.
  624. //
  625. // If the metric is unspecified, we will use the number of events that each
  626. // time series point contains as the point value.
  627. //
  628. // Example: Let's assume we have the following three events in our dataset:
  629. // ```json
  630. // {
  631. // eventTime: "2020-12-27T00:00:00Z",
  632. // dimensions: [
  633. // { name: "d1" stringVal: "v1" },
  634. // { name: "d2" stringVal: "v2" }
  635. // { name: "m1" longVal: 100 }
  636. // { name: "m2" longVal: 11 }
  637. // ]
  638. // },
  639. // {
  640. // eventTime: "2020-12-27T00:10:00Z",
  641. // dimensions: [
  642. // { name: "d1" stringVal: "v1" },
  643. // { name: "d2" stringVal: "v2" }
  644. // { name: "m1" longVal: 200 }
  645. // { name: "m2" longVal: 22 }
  646. // ]
  647. // },
  648. // {
  649. // eventTime: "2020-12-27T00:20:00Z",
  650. // dimensions: [
  651. // { name: "d1" stringVal: "v1" },
  652. // { name: "d2" stringVal: "v2" }
  653. // { name: "m1" longVal: 300 }
  654. // { name: "m2" longVal: 33 }
  655. // ]
  656. // }
  657. // ```
  658. //
  659. // These events are all within the same hour, spaced 10 minutes between each
  660. // of them. Assuming our [QueryDataSetRequest][google.cloud.timeseriesinsights.v1.QueryDataSetRequest] had set
  661. // [slicingParams.dimensionNames][google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names] to ["d1",
  662. // "d2"] and [timeseries_params.granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] to
  663. // "3600s", then all the previous events will be aggregated into the same
  664. // [timeseries point][google.cloud.timeseriesinsights.v1.TimeseriesPoint].
  665. //
  666. // The time series point that they're all part of will have the
  667. // [time][google.cloud.timeseriesinsights.v1.TimeseriesPoint.time] set to "2020-12-27T00:00:00Z" and the
  668. // [value][google.cloud.timeseriesinsights.v1.TimeseriesPoint.value] populated based on this metric field:
  669. //
  670. // - If the metric is set to "m1" and metric_aggregation_method to SUM, then
  671. // the value of the point will be 600.
  672. // - If the metric is set to "m2" and metric_aggregation_method to SUM, then
  673. // the value of the point will be 66.
  674. // - If the metric is set to "m1" and metric_aggregation_method to AVERAGE,
  675. // then the value of the point will be 200.
  676. // - If the metric is set to "m2" and metric_aggregation_method to AVERAGE,
  677. // then the value of the point will be 22.
  678. // - If the metric field is "" or unspecified, then the value of the point
  679. // will be 3, as we will simply count the events.
  680. optional string metric = 4 [(google.api.field_behavior) = OPTIONAL];
  681. // Optional. Together with the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] field, specifies how
  682. // we will aggregate multiple events to obtain the value of a time series
  683. // point. See the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] documentation for more
  684. // details.
  685. //
  686. // If the metric is not specified or "", then this field will be ignored.
  687. AggregationMethod metric_aggregation_method = 5 [(google.api.field_behavior) = OPTIONAL];
  688. }
  689. // Request for performing a query against a loaded DataSet.
  690. message QueryDataSetRequest {
  691. // Required. Loaded DataSet to be queried in the format of
  692. // "projects/{project}/datasets/{dataset}"
  693. string name = 1 [
  694. (google.api.field_behavior) = REQUIRED,
  695. (google.api.resource_reference) = {
  696. type: "timeseriesinsights.googleapis.com/Dataset"
  697. }
  698. ];
  699. // Required. This is the point in time that we want to probe for anomalies.
  700. //
  701. // The corresponding [TimeseriesPoint][google.cloud.timeseriesinsights.v1.TimeseriesPoint] is referred to as the
  702. // detection point.
  703. //
  704. // **NOTE**: As with any other time series point, the value is given by
  705. // aggregating all events in the slice that are in the
  706. // [detectionTime, detectionTime + granularity) time interval, where
  707. // the granularity is specified in the
  708. // [timeseriesParams.granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] field.
  709. google.protobuf.Timestamp detection_time = 11 [(google.api.field_behavior) = REQUIRED];
  710. // How many slices are returned in
  711. // [QueryDataSetResponse.slices][google.cloud.timeseriesinsights.v1.QueryDataSetResponse.slices].
  712. //
  713. // The returned slices are tentatively the ones with the highest
  714. // [anomaly scores][google.cloud.timeseriesinsights.v1.EvaluatedSlice.anomaly_score] in the dataset that match
  715. // the query, but it is not guaranteed.
  716. //
  717. // Reducing this number will improve query performance, both in terms of
  718. // latency and resource usage.
  719. //
  720. // Defaults to 50.
  721. optional int32 num_returned_slices = 13;
  722. // Parameters controlling how we will split the dataset into the slices that
  723. // we will analyze.
  724. SlicingParams slicing_params = 9;
  725. // Parameters controlling how we will build the time series used to predict
  726. // the [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] value for each slice.
  727. TimeseriesParams timeseries_params = 10;
  728. // Parameters that control the time series forecasting models, such as the
  729. // sensitivity of the anomaly detection.
  730. ForecastParams forecast_params = 5;
  731. // If specified, we will return the actual and forecasted time for all
  732. // returned slices.
  733. //
  734. // The time series are returned in the
  735. // [EvaluatedSlice.history][google.cloud.timeseriesinsights.v1.EvaluatedSlice.history] and
  736. // [EvaluatedSlice.forecast][google.cloud.timeseriesinsights.v1.EvaluatedSlice.forecast] fields.
  737. bool return_timeseries = 8;
  738. }
  739. // Response for a query executed by the system.
  740. message QueryDataSetResponse {
  741. // Loaded DataSet that was queried.
  742. string name = 1;
  743. // Slices sorted in descending order by their
  744. // [anomalyScore][google.cloud.timeseriesinsights.v1.EvaluatedSlice.anomaly_score].
  745. //
  746. // At most [numReturnedSlices][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.num_returned_slices]
  747. // slices are present in this field.
  748. repeated EvaluatedSlice slices = 3;
  749. }
  750. // Request for evaluateSlice.
  751. message EvaluateSliceRequest {
  752. // Required. Loaded DataSet to be queried in the format of
  753. // "projects/{project}/datasets/{dataset}"
  754. string dataset = 1 [
  755. (google.api.field_behavior) = REQUIRED,
  756. (google.api.resource_reference) = {
  757. type: "timeseriesinsights.googleapis.com/Dataset"
  758. }
  759. ];
  760. // Required. Dimensions with pinned values that specify the slice for which we will
  761. // fetch the time series.
  762. repeated PinnedDimension pinned_dimensions = 2 [(google.api.field_behavior) = REQUIRED];
  763. // Required. This is the point in time that we want to probe for anomalies.
  764. //
  765. // See documentation for
  766. // [QueryDataSetRequest.detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time].
  767. google.protobuf.Timestamp detection_time = 3 [(google.api.field_behavior) = REQUIRED];
  768. // Parameters controlling how we will build the time series used to predict
  769. // the [detectionTime][google.cloud.timeseriesinsights.v1.EvaluateSliceRequest.detection_time] value for this slice.
  770. TimeseriesParams timeseries_params = 4;
  771. // Parameters that control the time series forecasting models, such as the
  772. // sensitivity of the anomaly detection.
  773. ForecastParams forecast_params = 5;
  774. }
  775. // Request for evaluateTimeseries.
  776. message EvaluateTimeseriesRequest {
  777. // Required. Client project name in the format of 'projects/{project}'.
  778. string parent = 1 [
  779. (google.api.field_behavior) = REQUIRED,
  780. (google.api.resource_reference) = {
  781. type: "cloudresourcemanager.googleapis.com/Project"
  782. }
  783. ];
  784. // Evaluate this time series without requiring it was previously loaded in
  785. // a data set.
  786. //
  787. // The evaluated time series point is the last one, analogous to calling
  788. // evaluateSlice or query with
  789. // [detectionTime][google.cloud.timeseriesinsights.v1.EvaluateSliceRequest.detection_time] set to
  790. // `timeseries.point(timeseries.point_size() - 1).time`.
  791. //
  792. // The length of the time series must be at least 10.
  793. //
  794. // All points must have the same time offset relative to the granularity. For
  795. // example, if the [granularity][google.cloud.timeseriesinsights.v1.EvaluateTimeseriesRequest.granularity] is "5s", then the following
  796. // point.time sequences are valid:
  797. // - "100s", "105s", "120s", "125s" (no offset)
  798. // - "102s", "107s", "122s", "127s" (offset is "2s")
  799. // However, the following sequence is invalid as it has inconsistent offsets:
  800. // - "100s", "105s", "122s", "127s" (offsets are either "0s" or "2s")
  801. Timeseries timeseries = 2;
  802. // The granularity of the time series (time distance between two consecutive
  803. // points).
  804. google.protobuf.Duration granularity = 3;
  805. // The forecast parameters.
  806. ForecastParams forecast_params = 4;
  807. }