result_types.go
result_types.go - Overview
-
Overview This file defines the data structures used to represent query results, including vectors of samples, individual samples with metric labels and data points, and the structure of a single data point. It also includes methods for formatting these structures as strings and marshaling them into JSON format.
-
Detailed Documentation
Vector
- Purpose: Represents a slice of
Sample
structs. It's the main result type for time series queries. - Type:
[]Sample
Sample
- Purpose: Represents a single data point with associated metric labels.
- Fields:
Point
: APoint
struct containing the timestamp and value of the data point.Metric
: Alabels.Labels
object containing the metric labels for the sample.IsMissing
: A boolean indicating if the sample is missing.
- Type:
struct
Sample.String()
- Purpose: Returns a string representation of the
Sample
. - Returns:
string
- A formatted string combining the metric labels and the point data.
Sample.MarshalJSON()
- Purpose: Marshals the
Sample
struct into a JSON format. - Returns:
[]byte
- JSON representation of theSample
, error - any error during marshaling.
Point
- Purpose: Represents a single data point in a time series.
- Fields:
T
: Anint64
representing the timestamp of the data point.V
: Afloat64
representing the value of the data point.Vs
: A[]float64
representing the array of values of the data point.
- Type:
struct
Point.String()
- Purpose: Returns a string representation of the
Point
. - Returns:
string
- A formatted string containing the value and timestamp of the point.
Point.MarshalJSON()
- Purpose: Marshals the
Point
struct into a JSON format suitable for time series data. - Returns:
[]byte
- JSON representation of thePoint
, error - any error during marshaling.
Include in Getting Started: NO