Documentation ¶
Index ¶
- Constants
- func CountMetricParts(metric string) int
- func DropLastMetricPart(metric string) string
- func ExtendedGlobToRegexPattern(glob string, opts GlobOptions) ([]byte, bool, error)
- func ExtractNthMetricPart(metric string, n int) string
- func ExtractNthStringPart(target string, n int, delim rune) string
- func FormatTime(t time.Time) string
- func GlobToRegexPattern(glob string) ([]byte, bool, error)
- func ParseDuration(s string) (time.Duration, error)
- func ParseTime(s string, now time.Time, absoluteOffset time.Duration) (time.Time, error)
- func RespondWithPickle(w http.ResponseWriter, data interface{}) error
- func TagName(idx int) []byte
- type Datapoint
- type Datavalue
- type FindResultsCompleterJSON
- type FindResultsPickle
- type FindResultsTreeJSON
- type GlobOptions
- type MetricsPathMetadata
- type RenderDatapoints
- type RenderResults
- type RenderResultsPickle
- type RenderTarget
- type Results
- type Timestamp
Constants ¶
const MIMETypeApplicationPickle = "application/pickle"
MIMETypeApplicationPickle defines the MIME type for application/pickle content
const (
// MatchAllPattern that is used to match all metrics.
MatchAllPattern = ".*"
)
const (
// ValidIdentifierRunes contains all the runes allowed in a graphite identifier
ValidIdentifierRunes = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklmnopqrstuvwxyz" +
"0123456789" +
"$-_'|<>%#/"
)
Variables ¶
This section is empty.
Functions ¶
func CountMetricParts ¶
CountMetricParts counts the number of segments in the given metric string.
func DropLastMetricPart ¶
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 ¶
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 ¶
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 ¶
FormatTime translates a time.Time until a Graphite from/until string
func GlobToRegexPattern ¶
GlobToRegexPattern converts a graphite-style glob into a regex pattern, with a boolean indicating if the glob is regexed or not
func ParseDuration ¶
ParseDuration parses a duration
func ParseTime ¶
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
Types ¶
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 ¶
MarshalJSON marshals the value as JSON, writing NaNs as nulls
func (*Datavalue) UnmarshalJSON ¶
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
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 ¶
Results are a map of graphite target names to their corresponding datapoints
func ParseJSONResponse ¶
ParseJSONResponse takes a byteBuffer and returns Results
type Timestamp ¶
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 ¶
MarshalJSON marshals the timestamp as JSON
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON unmarshals the timestamp from JSON