graphite

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 11 Imported by: 10

Documentation

Index

Constants

View Source
const MIMETypeApplicationPickle = "application/pickle"

MIMETypeApplicationPickle defines the MIME type for application/pickle content

View Source
const (

	// MatchAllPattern that is used to match all metrics.
	MatchAllPattern = ".*"
)
View Source
const (
	// ValidIdentifierRunes contains all the runes allowed in a graphite identifier
	ValidIdentifierRunes = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
		"abcdefghijklmnopqrstuvwxyz" +
		"0123456789" +
		"$-_'|<>%#/:"
)

Variables

This section is empty.

Functions

func CountMetricParts

func CountMetricParts(metric string) int

CountMetricParts counts the number of segments in the given metric string.

func DropLastMetricPart

func DropLastMetricPart(metric string) string

DropLastMetricPart returns the metric string without the last segment.

func ExtendedGlobToRegexPattern

func ExtendedGlobToRegexPattern(glob string, opts GlobOptions) ([]byte, bool, error)

ExtendedGlobToRegexPattern converts a graphite-style glob into a regex pattern with extended options

func ExtractNthMetricPart

func ExtractNthMetricPart(metric string, n int) string

ExtractNthMetricPart returns the nth part of the metric string. Index starts from 0 and assumes metrics are delimited by '.'. If n is negative or bigger than the number of parts, returns an empty string.

func ExtractNthStringPart

func ExtractNthStringPart(target string, n int, delim rune) string

ExtractNthStringPart returns the nth part of the metric string. Index starts from 0. If n is negative or bigger than the number of parts, returns an empty string.

func FormatTime

func FormatTime(t time.Time) string

FormatTime translates a time.Time until a Graphite from/until string

func GlobToRegexPattern

func GlobToRegexPattern(glob string) ([]byte, bool, error)

GlobToRegexPattern converts a graphite-style glob into a regex pattern, with a boolean indicating if the glob is regexed or not

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration

func ParseTime

func ParseTime(s string, now time.Time, absoluteOffset time.Duration) (time.Time, error)

ParseTime translates a Graphite from/until string into a timestamp relative to the provide time

func RespondWithPickle

func RespondWithPickle(w http.ResponseWriter, data interface{}) error

RespondWithPickle sends a python pickle response

func TagName

func TagName(idx int) []byte

TagName gets a preallocated or generate a tag name for the given graphite path index.

Types

type Datapoint

type Datapoint struct {
	Timestamp Timestamp `json:"t"`
	Value     Datavalue `json:"v"`
}

A Datapoint is a Timestamp/Value pair representing a single value in a target

type Datavalue

type Datavalue float64

A Datavalue is a float64 which knows how to marshal and unmarshal itself as Graphite expects (NaNs becomes nulls)

func (Datavalue) MarshalJSON

func (v Datavalue) MarshalJSON() ([]byte, error)

MarshalJSON marshals the value as JSON, writing NaNs as nulls

func (*Datavalue) UnmarshalJSON

func (v *Datavalue) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the value as JSON, converting nulls into NaNs

type FindResultsCompleterJSON

type FindResultsCompleterJSON struct {
	Metrics []MetricsPathMetadata `json:"metrics"`
}

FindResultsCompleterJSON is graphite's "completer" format for /metrics/find results sample: {"metrics": [...]}

type FindResultsPickle

type FindResultsPickle struct {
	Path   string `pickle:"path" json:"path"`
	IsLeaf bool   `pickle:"is_leaf" json:"is_leaf"`
}

FindResultsPickle is graphite's pickle format for /metrics/find results

type FindResultsTreeJSON

type FindResultsTreeJSON struct {
	ID            string `json:"id"`            // =path
	Text          string `json:"text"`          // =name
	Leaf          int    `json:"leaf"`          // =isLeaf
	Expandable    int    `json:"expandable"`    // =!isLeaf
	AllowChildren int    `json:"allowChildren"` // =!isLeaf
}

FindResultsTreeJSON is graphite's "treeJSON" format for /metrics/find results. sample: {"text": "quz", "expandable": 1, "leaf": 0, "id": "foo.bar-baz.qux.quz", "allowChildren": 1}

type GlobOptions

type GlobOptions struct {
	// AllowMatchAll allows for matching all text
	// including hierarchy separators with "**"
	AllowMatchAll bool `yaml:"allowMatchAll"`
}

GlobOptions allows for matching everything

type MetricsPathMetadata

type MetricsPathMetadata struct {
	Path   string `json:"path"`
	Name   string `json:"name"`
	IsLeaf int    `json:"is_leaf,string"` // UGLY(jayp): should be a bool, int due to encoding/json
}

MetricsPathMetadata is an internal element of graphite's "completer" format for /metrics/find results. sample: {"is_leaf": "1", "path": "servers.foo-bar.baz.qux_qaz", "name": "qux_qaz"}

type RenderDatapoints

type RenderDatapoints [][]interface{}

RenderDatapoints are the set of datapoints returned from Graphite rendering

func (*RenderDatapoints) Add

func (dp *RenderDatapoints) Add(timestamp time.Time, value float64)

Add adds a new datapoint to the set of datapoints

func (RenderDatapoints) Get

func (dp RenderDatapoints) Get(i int) (time.Time, float64)

Get returns the timestamp and value at the given index

type RenderResults

type RenderResults []RenderTarget

RenderResults are the results from a render API call

type RenderResultsPickle

type RenderResultsPickle struct {
	Name   string        `pickle:"name"`
	Start  uint32        `pickle:"start"`
	End    uint32        `pickle:"end"`
	Step   uint32        `pickle:"step"`
	Values []interface{} `pickle:"values"` // value can be nil (python 'None')
}

RenderResultsPickle is an alternate form of graphite result, consisting of a start time, an end time, a step size (in seconds), and values for each step. Steps that do not have a value will be NaN

func ParseRenderResultsPickle

func ParseRenderResultsPickle(b []byte) ([]RenderResultsPickle, error)

ParseRenderResultsPickle parses a byte stream containing a pickle render response

func (RenderResultsPickle) Get

func (p RenderResultsPickle) Get(i int) (time.Time, float64)

Get returns the timestamp and value at the given index

func (RenderResultsPickle) Len

func (p RenderResultsPickle) Len() int

Len returns the number of results

func (RenderResultsPickle) ValueAt

func (p RenderResultsPickle) ValueAt(n int) float64

ValueAt returns the value at the given step

type RenderTarget

type RenderTarget struct {
	Target     string           `json:"target"`
	Datapoints RenderDatapoints `json:"datapoints"`
}

A RenderTarget is the result of rendering a given target

type Results

type Results map[string][]Datapoint

Results are a map of graphite target names to their corresponding datapoints

func ParseJSONResponse

func ParseJSONResponse(b []byte) (Results, error)

ParseJSONResponse takes a byteBuffer and returns Results

type Timestamp

type Timestamp time.Time

A Timestamp is a time.Time that knows how to marshal and unmarshal itself as Graphite expects (as seconds since Unix epoch)

func (Timestamp) MarshalJSON

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

MarshalJSON marshals the timestamp as JSON

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the timestamp from JSON

Jump to

Keyboard shortcuts

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