utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: Apache-2.0 Imports: 18 Imported by: 47

Documentation

Overview

Copyright 2017 The Prometheus Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	MetricName   = "__name__"
	AlertName    = "alertname"
	BucketLabel  = "le"
	InstanceName = "instance"
)

Well-known label names used by Prometheus components.

View Source
const (
	OneMinuteMs = 60 * 1000
	OneHourMs   = 3600 * 1000
	OneDayMs    = 24 * 3600 * 1000
)

Variables

This section is empty.

Functions

func AsInt64Array

func AsInt64Array(val []byte) []uint64

Convert a V3IO blob to an integers array

func Compare

func Compare(a, b Labels) int

Compare compares the two label sets. The result will be 0 if a==b, <0 if a < b, and >0 if a > b.

func CreateContainer

func CreateContainer(logger logger.Logger, cfg *config.V3ioConfig) (*v3io.Container, error)

func CurrentTimeInMillis added in v0.0.12

func CurrentTimeInMillis() int64

func DeleteTable

func DeleteTable(logger logger.Logger, container *v3io.Container, path, filter string, workers int) error

func Equal

func Equal(ls, o Labels) bool

Equal returns whether the two label sets are equal.

func FloatToNormalizedScientificStr added in v0.0.4

func FloatToNormalizedScientificStr(val float64) string

func GetTimeFromRange

func GetTimeFromRange(from, to, last, step string) (f int64, t int64, s int64, err error)

func IsDefined added in v0.0.4

func IsDefined(value float64) bool

func IsNotExistsError added in v0.0.12

func IsNotExistsError(err error) bool

func IsUndefined added in v0.0.4

func IsUndefined(value float64) bool

func IsValidLabelName added in v0.0.5

func IsValidLabelName(labelName string) error

func IsValidMetricName added in v0.0.5

func IsValidMetricName(name string) error

func NewLogger

func NewLogger(level string) (logger.Logger, error)

func Str2duration

func Str2duration(duration string) (int64, error)

Convert a "[0-9]+[mhd]" duration string (for example, "24h") to a Unix timestamp in milliseconds integer

func Str2unixTime

func Str2unixTime(timeString string) (int64, error)

Convert a time string to a Unix timestamp in milliseconds integer. The input time string can be of the format "now", "now-[0-9]+[mdh]" (for example, "now-2h"), "<Unix timestamp in milliseconds>", or "<RFC 3339 time>" (for example, "2018-09-26T14:10:20Z").

Types

type AsyncItemsCursor

type AsyncItemsCursor struct {
	Cnt int
	// contains filtered or unexported fields
}

func NewAsyncItemsCursor

func NewAsyncItemsCursor(
	container *v3io.Container, input *v3io.GetItemsInput,
	workers int, shardingKeys []string, logger logger.Logger) (*AsyncItemsCursor, error)

func (*AsyncItemsCursor) All

func (ic *AsyncItemsCursor) All() ([]v3io.Item, error)

gets all items

func (*AsyncItemsCursor) Err

func (ic *AsyncItemsCursor) Err() error

error returns the last error

func (*AsyncItemsCursor) GetField

func (ic *AsyncItemsCursor) GetField(name string) interface{}

func (*AsyncItemsCursor) GetFieldInt

func (ic *AsyncItemsCursor) GetFieldInt(name string) (int, error)

func (*AsyncItemsCursor) GetFieldString

func (ic *AsyncItemsCursor) GetFieldString(name string) (string, error)

func (*AsyncItemsCursor) GetFields

func (ic *AsyncItemsCursor) GetFields() map[string]interface{}

func (*AsyncItemsCursor) GetItem

func (ic *AsyncItemsCursor) GetItem() v3io.Item

func (*AsyncItemsCursor) Next

func (ic *AsyncItemsCursor) Next() bool

Next gets the next matching item. this may potentially block as this lazy loads items from the collection

func (*AsyncItemsCursor) NextItem

func (ic *AsyncItemsCursor) NextItem() (v3io.Item, error)

NextItem gets the next matching item. this may potentially block as this lazy loads items from the collection

func (*AsyncItemsCursor) Release

func (ic *AsyncItemsCursor) Release()

Release releases a cursor and its underlying resources

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder allows modifiying Labels.

func NewBuilder

func NewBuilder(base Labels) *Builder

NewBuilder returns a new LabelsBuilder

func (*Builder) Del

func (b *Builder) Del(ns ...string) *Builder

Del deletes the label of the given name.

func (*Builder) Labels

func (b *Builder) Labels() Labels

Labels returns the labels from the builder. If no modifications were made, the original labels are returned.

func (*Builder) Set

func (b *Builder) Set(n, v string) *Builder

Set the name/value pair as a label.

type ItemsCursor

type ItemsCursor interface {
	Err() error
	Next() bool
	GetField(name string) interface{}
	GetFields() map[string]interface{}
}

type Label

type Label struct {
	Name, Value string
}

Label is a key/value pair of strings.

type Labels

type Labels []Label

Labels is a sorted set of labels. Order has to be guaranteed upon instantiation.

func LabelsFromMap added in v0.0.13

func LabelsFromMap(m map[string]string) Labels

LabelsFromMap returns new sorted Labels from the given map.

func LabelsFromStrings added in v0.0.13

func LabelsFromStrings(ss ...string) Labels

LabelsFromStrings creates new labels from pairs of strings.

func ToLabels added in v0.0.13

func ToLabels(ls ...Label) Labels

ToLabels returns a sorted Labels from the given labels. The caller has to guarantee that all label names are unique.

func (Labels) Copy

func (ls Labels) Copy() Labels

Copy returns a copy of the labels.

func (Labels) Get

func (ls Labels) Get(name string) string

Get returns the value for the label with the given name. Returns an empty string if the label doesn't exist.

func (Labels) GetExpr

func (ls Labels) GetExpr() string

create update expression

func (Labels) GetKey

func (ls Labels) GetKey() (string, string, uint64)

convert Label set to a string in the form key1=v1,key2=v2.. + name + hash

func (Labels) Has

func (ls Labels) Has(name string) bool

Has returns true if the label with the given name is present.

func (Labels) Hash

func (ls Labels) Hash() uint64

Hash returns a hash value for the label set.

func (Labels) Len

func (ls Labels) Len() int

func (Labels) Less

func (ls Labels) Less(i, j int) bool

func (Labels) Map

func (ls Labels) Map() map[string]string

Map returns a string map of the labels.

func (Labels) MarshalJSON

func (ls Labels) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Labels) String

func (ls Labels) String() string

func (Labels) Swap

func (ls Labels) Swap(i, j int)

func (*Labels) UnmarshalJSON

func (ls *Labels) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type LabelsIfc

type LabelsIfc interface {
	GetKey() (string, string, uint64)
	GetExpr() string
}

Jump to

Keyboard shortcuts

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