core

package
v0.0.0-...-82de52e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2022 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Earliest is the earliest Time representable. Handy for
	// initializing a high watermark.
	Earliest = model.Time(math.MinInt64)
	// Latest is the latest Time representable. Handy for initializing
	// a low watermark.
	Latest = model.Time(math.MaxInt64)
)

Most of this code is taken from original time.go in Prometheus repo https://github.com/prometheus/common/blob/master/model/time.go

View Source
const ShouldRemoveNameLabel = "SHOULD_REMOVE_NAME_LABEL"

ShouldRemoveNameLabel WarpScript attribute key to remove name label

Variables

This section is empty.

Functions

func IsValid

func IsValid(labelName string) bool

IsValid check if a label name string is Valid

func IsoTime

func IsoTime(t time.Time) string

IsoTime is returning the right format for Warp

func NewSimpleMacroMapper

func NewSimpleMacroMapper(op string) string

NewSimpleMacroMapper is creating a macromapper that is only modifying the value.

func ParseDuration

func ParseDuration(durationStr string) (string, error)

ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.

func ParsePromDuration

func ParsePromDuration(s string) (string, error)

ParsePromDuration parses a duration as a string and returns a string.

func RetrieveToken

func RetrieveToken(req *http.Request) string

RetrieveToken from multiple sources

Types

type AddValuePayload

type AddValuePayload struct {
	Timestamp string
	Latitude  string
	Longitude string
	Elevation string
	Value     string
}

AddValuePayload is the payload to add a value to a GTS

type AggregatePayload

type AggregatePayload struct {
	Op               string   // The used aggregation operation.
	Param            string   // Parameter used by some aggregators.
	Grouping         []string // The labels by which to group the vector.
	Without          bool     // Whether to drop the given labels rather than keep them.
	KeepCommonLabels bool     // Whether to keep common labels among result elements.
}

AggregatePayload represents an aggregation operation on a vector.

type BinaryExprPayload

type BinaryExprPayload struct {
	Op             string
	IsOn           bool
	IsIgnoring     bool
	FilteredLabels []string
	IncludeLabels  []string
	Card           string
	ReturnBool     bool
}

BinaryExprPayload is hodling an Op

type BucketizePayload

type BucketizePayload struct {
	LastBucket   string
	BucketSpan   string
	BucketCount  string
	PreBucketize string
	Filler       string
	Op           string
	Step         string
	Absent       bool
}

BucketizePayload is the payload for the bucketize function

type Context

type Context struct {
	Query string
	Start Time
	End   Time
	Step  string
}

Context is holding the informations like token, start, end, and so on

type Duration

type Duration time.Duration

Duration wraps time.Duration. It is used to parse the custom duration format from YAML. This type should not propagate beyond the scope of input/output processing.

func ParseStringDuration

func ParseStringDuration(durationStr string) (Duration, error)

ParseStringDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*Duration) Set

func (d *Duration) Set(s string) error

Set implements pflag/flag.Value

func (Duration) String

func (d Duration) String() string

func (*Duration) Type

func (d *Duration) Type() string

Type implements pflag.Value

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type FetchPayload

type FetchPayload struct {
	ClassName   string
	Labels      map[string]string
	End         string
	Start       string
	Step        string
	Offset      string
	BucketRange string
	Absent      bool
	Instant     bool
}

FetchPayload is the payload for the fetch function

type FillValuePayload

type FillValuePayload struct {
	Latitude  string
	Longitude string
	Elevation string
	Value     string
}

FillValuePayload is the payload to fill empty value of a GTS

type FindPayload

type FindPayload struct {
	ClassName string
	Labels    map[string]string
}

FindPayload is the payload for the find function

type FunctionPayload

type FunctionPayload struct {
	Name         string
	ArgTypes     []model.ValueType
	Args         []string
	OptionalArgs int
	Prefix       string
}

FunctionPayload represents a function of the expression language and is used by function nodes.

type GeoTimeSeries

type GeoTimeSeries struct {
	// This is the class name of the Geo Time Serie. This may be present in only
	// one chunk of a given Geo Time Serie in the output.
	Class string `json:"c"`

	Labels map[string]string `json:"l"`

	Attrs map[string]string `json:"a"`

	ID string `json:"i"`

	Values [][]interface{} `json:"v"`
}

A GeoTimeSeries as returned by Warp10 (https://warp10.io/) WarpScript returns a JSON array: Format defined at https://www.warp10.io/content/03_Documentation/03_Interacting_with_Warp_10/04_Fetching_data/02_GTS_JSON_output_format

func (*GeoTimeSeries) TimeAndValue

func (series *GeoTimeSeries) TimeAndValue(i int) (bool, time.Time, float64)

TimeAndValue Get the time and value at a given position

type HTTPWarp10Server

type HTTPWarp10Server struct {
	Endpoint string
	Protocol string
	// contains filtered or unexported fields
}

HTTPWarp10Server Concrete implementation

func NewWarpServer

func NewWarpServer(endpoint string, protocol string) *HTTPWarp10Server

NewWarpServer is returning a new Warp server

func (*HTTPWarp10Server) Delete

func (server *HTTPWarp10Server) Delete(token string, query string) error

Delete is handling /api/v0/delete in Warp

func (*HTTPWarp10Server) Find

func (server *HTTPWarp10Server) Find(token string, selector string) (*http.Response, error)

Find is Simple Find, given the metric name and tags, and the start/end timestamps

func (*HTTPWarp10Server) FindGTS

func (server *HTTPWarp10Server) FindGTS(token string, selector string) (*QueryResult, error)

FindGTS is find, given the metric name and tags, and the start/end timestamps

func (*HTTPWarp10Server) Query

func (server *HTTPWarp10Server) Query(body string, txn string) (*http.Response, error)

Query is performing a simple query, given the metric name and tags, and the start/end timestamps

func (*HTTPWarp10Server) QueryGTS

func (server *HTTPWarp10Server) QueryGTS(body, txn string) (*QueryResult, error)

QueryGTS is a simple query, given the metric name and tags, and the start/end timestamps

func (*HTTPWarp10Server) QueryGTSs

func (server *HTTPWarp10Server) QueryGTSs(body, txn string) ([][]GeoTimeSeries, error)

QueryGTSs is multiple query, given the metric name and tags, and the start/end timestamps

type Interval

type Interval struct {
	Start, End Time
}

Interval describes and interval between two timestamps.

type MapperPayload

type MapperPayload struct {
	Mapper      string
	Constant    string
	PreWindow   string
	PostWindow  string
	Occurrences string
	Suffix      string
}

MapperPayload is the payload to map GTS' value in the tree

type Node

type Node struct {
	Level       int
	Left        *Node
	Right       *Node
	Payload     payload
	ChildLabels []string
}

Node is the struct holding the query tree. Needed for promql, it served also for Graphite protocol

func NewEmptyNode

func NewEmptyNode() *Node

NewEmptyNode is a constructor

func NewNode

func NewNode(payload payload) *Node

NewNode is creating a new node with a specific type and Payload

func (*Node) InternalToWarpScript

func (n *Node) InternalToWarpScript(query string) string

InternalToWarpScript translate an internal Node to WarpScript

func (*Node) PrintNode

func (n *Node) PrintNode(level int)

PrintNode is printing a tree

func (*Node) ToWarpScript

func (n *Node) ToWarpScript(token string, query string, step string) string

ToWarpScript translate a node to a WarpScript

func (*Node) ToWarpScriptWithTime

func (n *Node) ToWarpScriptWithTime(token string, query string, step string, start Time, end Time) string

ToWarpScriptWithTime translate a node to a WarpScript with start and end prefix

func (*Node) Write

func (n *Node) Write(b *bytes.Buffer)

Write write node content nolint: gocyclo

type NumberLiteralPayload

type NumberLiteralPayload struct {
	Value string
}

NumberLiteralPayload is holding a number

type QueryResult

type QueryResult struct {
	Count   int             `json:"count"`
	Fetched int             `json:"fetched"`
	GTS     []GeoTimeSeries `json:"gts"`
}

QueryResult The result of a Warp10 query

type ReducerPayload

type ReducerPayload struct {
	Reducer string
	Value   string
	Labels  []string
}

ReducerPayload is the payload to reduce GTS' value in the tree

type StorePayload

type StorePayload struct {
	Name  string
	Value string
}

StorePayload is the payload to store variable in the tree

type Time

type Time int64

Time is the number of milliseconds since the epoch (1970-01-01 00:00 UTC) excluding leap seconds.

func Now

func Now() Time

Now returns the current time as a Time.

func ParsePromTime

func ParsePromTime(s string) (Time, error)

ParsePromTime returns a core.Time from string

func TimeFromUnix

func TimeFromUnix(t int64) Time

TimeFromUnix returns the Time equivalent to the Unixmodel.Timet provided in seconds.

func TimeFromUnixMicro

func TimeFromUnixMicro(t int64) Time

TimeFromUnixMicro returns the Time equivalent to the Unix Time t provided in nanoseconds.

func TimeFromUnixNano

func TimeFromUnixNano(t int64) Time

TimeFromUnixNano returns the Time equivalent to the Unix Time t provided in nanoseconds.

func (Time) Add

func (t Time) Add(d time.Duration) Time

Add returns the Time t + d.

func (Time) After

func (t Time) After(o Time) bool

After reports whether the Time t is after o.

func (Time) Before

func (t Time) Before(o Time) bool

Before reports whether the Time t is before o.

func (Time) Equal

func (t Time) Equal(o Time) bool

Equal reports whether two Times represent the same instant.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Time) String

func (t Time) String() string

String returns a string representation of the Time.

func (Time) Sub

func (t Time) Sub(o Time) time.Duration

Sub returns the Duration t - o.

func (Time) Time

func (t Time) Time() time.Time

Time returns the time.Time representation of t.

func (Time) Unix

func (t Time) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.

func (Time) UnixNano

func (t Time) UnixNano() int64

UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type UnaryExprPayload

type UnaryExprPayload struct {
	Op string
}

UnaryExprPayload inverse data

type Warp10Server

type Warp10Server interface {
	QueryGTS(body string) (*QueryResult, error)
	Query(body string) (*http.Response, error)
}

Warp10Server is the abstraction of Warp10

type WarpScriptPayload

type WarpScriptPayload struct {
	WarpScript string
}

WarpScriptPayload is the payload to push WarpScript directly in the tree

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL