pub struct TimeseriesParams {
    pub forecast_history: Option<Duration>,
    pub granularity: Option<Duration>,
    pub metric: Option<String>,
    pub metric_aggregation_method: i32,
}
Expand description

Parameters that control how we construct the time series for each slice.

Fields§

§forecast_history: Option<Duration>

Required. How long should we go in the past when fetching the timeline used for forecasting each slice.

This is used in combination with the [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] parameter. The time series we construct will have the following time range: \[detectionTime - forecastHistory, detectionTime + granularity\].

The forecast history might be rounded up, so that a multiple of granularity is used to process the query.

Note: If there are not enough events in the \[detectionTime - forecastHistory, detectionTime + granularity\] time interval, the slice evaluation can fail. For more information, see [EvaluatedSlice.status][google.cloud.timeseriesinsights.v1.EvaluatedSlice.status].

§granularity: Option<Duration>

Required. The time granularity of the time series (on the x-axis). Each time series point starting at time T will aggregate all events for a particular slice in [T, T + granularity) time windows.

Note: The aggregation is decided based on the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] parameter.

This granularity defines the query-time aggregation windows and is not necessarily related to any event time granularity in the raw data (though we do recommend that the query-time granularity is not finer than the ingestion-time one).

Currently, the minimal supported granularity is 10 seconds.

§metric: Option<String>

Optional. Denotes the [name][google.cloud.timeseriesinsights.v1.EventDimension.name] of a numerical dimension that will have its values aggregated to compute the y-axis of the time series.

The aggregation method must also be specified by setting the [metricAggregationMethod][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method] field.

Note: Currently, if the aggregation method is unspecified, we will default to SUM for backward compatibility reasons, but new implementations should set the [metricAggregationMethod][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method] explicitly.

If the metric is unspecified, we will use the number of events that each time series point contains as the point value.

Example: Let’s assume we have the following three events in our dataset:

{
   eventTime: "2020-12-27T00:00:00Z",
   dimensions: [
     { name: "d1" stringVal: "v1" },
     { name: "d2" stringVal: "v2" }
     { name: "m1" longVal: 100 }
     { name: "m2" longVal: 11 }
   ]
},
{
   eventTime: "2020-12-27T00:10:00Z",
   dimensions: [
     { name: "d1" stringVal: "v1" },
     { name: "d2" stringVal: "v2" }
     { name: "m1" longVal: 200 }
     { name: "m2" longVal: 22 }
   ]
},
{
   eventTime: "2020-12-27T00:20:00Z",
   dimensions: [
     { name: "d1" stringVal: "v1" },
     { name: "d2" stringVal: "v2" }
     { name: "m1" longVal: 300 }
     { name: "m2" longVal: 33 }
   ]
}

These events are all within the same hour, spaced 10 minutes between each of them. Assuming our [QueryDataSetRequest][google.cloud.timeseriesinsights.v1.QueryDataSetRequest] had set [slicingParams.dimensionNames][google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names] to [“d1”, “d2”] and [timeseries_params.granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] to “3600s”, then all the previous events will be aggregated into the same [timeseries point][google.cloud.timeseriesinsights.v1.TimeseriesPoint].

The time series point that they’re all part of will have the [time][google.cloud.timeseriesinsights.v1.TimeseriesPoint.time] set to “2020-12-27T00:00:00Z” and the [value][google.cloud.timeseriesinsights.v1.TimeseriesPoint.value] populated based on this metric field:

  • If the metric is set to “m1” and metric_aggregation_method to SUM, then the value of the point will be 600.
  • If the metric is set to “m2” and metric_aggregation_method to SUM, then the value of the point will be 66.
  • If the metric is set to “m1” and metric_aggregation_method to AVERAGE, then the value of the point will be 200.
  • If the metric is set to “m2” and metric_aggregation_method to AVERAGE, then the value of the point will be 22.
  • If the metric field is “” or unspecified, then the value of the point will be 3, as we will simply count the events.
§metric_aggregation_method: i32

Optional. Together with the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] field, specifies how we will aggregate multiple events to obtain the value of a time series point. See the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] documentation for more details.

If the metric is not specified or “”, then this field will be ignored.

Implementations§

source§

impl TimeseriesParams

source

pub fn metric(&self) -> &str

Returns the value of metric, or the default value if metric is unset.

source

pub fn metric_aggregation_method(&self) -> AggregationMethod

Returns the enum value of metric_aggregation_method, or the default if the field is set to an invalid enum value.

source

pub fn set_metric_aggregation_method(&mut self, value: AggregationMethod)

Sets metric_aggregation_method to the provided enum value.

Trait Implementations§

source§

impl Clone for TimeseriesParams

source§

fn clone(&self) -> TimeseriesParams

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TimeseriesParams

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TimeseriesParams

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Message for TimeseriesParams

source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
source§

impl PartialEq for TimeseriesParams

source§

fn eq(&self, other: &TimeseriesParams) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for TimeseriesParams

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more