Documentation ¶
Index ¶
- Variables
- func EscapeIdentifier(identifier string) string
- type Clock
- type ConversionError
- type ConversionErrorCode
- type GraphiteConverter
- type GraphiteConverterConfig
- type GraphiteMetric
- type RawRule
- type RawRules
- type RealClock
- type Rule
- func (rule *Rule) AddMatch(matchedResult string)
- func (rule Rule) Description() string
- func (rule *Rule) DisableStats()
- func (rule *Rule) EnableStats()
- func (rule Rule) GraphitePatternTags() []string
- func (rule *Rule) MatchRule(input string) (api.TaggedMetric, bool)
- func (rule Rule) ToGraphiteName(taggedMetric api.TaggedMetric) (GraphiteMetric, error)
- type RuleBasedGraphiteConverter
- type RuleError
- type RuleErrorCode
- type RuleSet
- type RuleStatistics
Constants ¶
This section is empty.
Variables ¶
var OrdinaryIdentifierRegex = regexp.MustCompile(`^[A-Za-z_][A-Za-z_0-9]*(\.[A-Za-z_][A-Za-z_0-9]*)*$`)
Functions ¶
func EscapeIdentifier ¶
Types ¶
type ConversionError ¶
type ConversionError interface { Code() ConversionErrorCode error }
ConversionError is the actual error object, wrapping ConversionErrorCode and related metadata.
type ConversionErrorCode ¶
type ConversionErrorCode int
ConversionErrorCode is the error enum raised while the metrics are converted between the graphite format to tagged metrics format.
const ( // MissingTag is returned during the reverse mapping, when a pattern required in the graphite key is not provided. MissingTag ConversionErrorCode = iota + 1 // CannotInterpolate is returned when the tag interpolation fails. CannotInterpolate // NoMatch is returned when no rule can reverse the given tagged metric. NoMatch // UnusedTag is returned during the reverse mapping, when a tag is present in the taglist but is not used UnusedTag )
type GraphiteConverter ¶
type GraphiteConverter interface { // Convert the given tag-based metric name to graphite metric name, // using the configured rules. May error out. ToGraphiteName(metric api.TaggedMetric) (GraphiteMetric, error) // Converts the given graphite metric to the tag-based meric, // using the configured rules. May error out. ToTaggedName(metric GraphiteMetric) (api.TaggedMetric, error) }
type GraphiteConverterConfig ¶
type GraphiteConverterConfig struct {
ConversionRulesPath string `yaml:"conversion_rules_path"`
}
type GraphiteMetric ¶
type GraphiteMetric string
GraphiteMetric is a flat, dot-separated identifier to a series of metric.
type RawRule ¶
type RawRule struct { Pattern string `yaml:"pattern"` MetricKeyPattern string `yaml:"metric_key"` Regex map[string]string `yaml:"regex,omitempty"` DoNotMatch map[string]string `yaml:"do_not_match,omitempty"` }
RawRule is the input provided by the YAML file to specify the rul.
type RawRules ¶
type RawRules struct {
RawRules []RawRule `yaml:"rules"`
}
RawRules is list of RawRule
type Rule ¶
type Rule struct { MetricKeyRegex *regexp.Regexp Statistics RuleStatistics // contains filtered or unexported fields }
Rule is a sanitized version of RawRule. Only valid rules can be converted to Rule.
func Compile ¶
Compile a given RawRule into a regex and exposed tagset. error is an instance of RuleError.
func (Rule) Description ¶
func (*Rule) DisableStats ¶
func (rule *Rule) DisableStats()
func (*Rule) EnableStats ¶
func (rule *Rule) EnableStats()
func (Rule) GraphitePatternTags ¶
GraphitePatternTags return a list of tags available in the original metric.
func (*Rule) MatchRule ¶
func (rule *Rule) MatchRule(input string) (api.TaggedMetric, bool)
MatchRule sees if a given graphite string matches the rule, and if so, returns the generated tag.
func (Rule) ToGraphiteName ¶
func (rule Rule) ToGraphiteName(taggedMetric api.TaggedMetric) (GraphiteMetric, error)
ToGraphiteName transforms the given tagged metric back to its graphite metric.
type RuleBasedGraphiteConverter ¶
type RuleBasedGraphiteConverter struct {
Ruleset RuleSet
}
func (*RuleBasedGraphiteConverter) EnableStats ¶
func (g *RuleBasedGraphiteConverter) EnableStats()
func (*RuleBasedGraphiteConverter) ToGraphiteName ¶
func (g *RuleBasedGraphiteConverter) ToGraphiteName(metric api.TaggedMetric) (GraphiteMetric, error)
func (*RuleBasedGraphiteConverter) ToTaggedName ¶
func (g *RuleBasedGraphiteConverter) ToTaggedName(metric GraphiteMetric) (api.TaggedMetric, error)
type RuleError ¶
type RuleError interface { // Error code describing the error. Code() RuleErrorCode // Rule Metric Key, if applicable MetricKey() string error }
RuleError is the actual error object, wrapping RuleErrorCode and related metadata.
type RuleErrorCode ¶
type RuleErrorCode int
RuleErrorCode is the error enum raised while YAML rule files is being compiled.
const ( // InvalidYaml is returned when the given YAML file fails to parse InvalidYaml RuleErrorCode = iota + 1 // InvalidPattern is returned when an invalid rule pattern is provided. InvalidPattern // InvalidMetricKey is retruned when an invalid metric key is provided. InvalidMetricKey // InvalidCustomRegex is retruned when the custom regex is invalid. InvalidCustomRegex )
type RuleSet ¶
type RuleSet struct { Rules []Rule // contains filtered or unexported fields }
RuleSet is a sanitized version of RawRules. Rules are matched sequentially until a correct one is matched.
func LoadYAML ¶
LoadYAML loads a RuleSet from the byte array of the YAML file. error is an interface of RuleError.
func (*RuleSet) DisableStats ¶
func (ruleSet *RuleSet) DisableStats()
func (*RuleSet) EnableStats ¶
func (ruleSet *RuleSet) EnableStats()
func (*RuleSet) MatchRule ¶
func (ruleSet *RuleSet) MatchRule(input string) (api.TaggedMetric, bool)
MatchRule sees if a given graphite string matches any of the specified rules.
func (RuleSet) ToGraphiteName ¶
func (ruleSet RuleSet) ToGraphiteName(taggedMetric api.TaggedMetric) (GraphiteMetric, error)
ToGraphiteName transforms the given tagged metric back to its graphite name, checking against all the rules.
type RuleStatistics ¶
type RuleStatistics struct { Matches int SuccessfulMatches []string // contains filtered or unexported fields }
func (*RuleStatistics) AddMatch ¶
func (ruleStat *RuleStatistics) AddMatch(matchedResult string)