metricchecks

package
v0.0.0-...-229c351 Latest Latest
Warning

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

Go to latest
Published: May 15, 2015 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

README

metric checker

##Dependencies Package dependency is managed by godep (https://github.com/tools/godep). Follow the docs there when adding/removing/updating package dependencies.

##example api usage

import "github.com/square/inspect/metricchecks"
import "github.com/square/inspect/metrics"

m := metrics.NewMetricContext("test")

... //Collect metrics

checker := metricchecks.New()
checker.NewScopeAndPackage() //reset scope to check new set of metrics
checker.InsertMetricValuesFromContext(m) //collect metric values

results, err := checker.CheckAll() //get check results

##example command line tool usage

./metric_checker -address localhost:12345 -cnf ./inspect.confi

configuration file format

# example comment line

#each section name should be unique
[section name]

#expr indicates the expression to be evaluated
expr = value >= 30

#true indicates the message to send if expr evaluates to true
true = check passed

#false indicates the message to send if expr evaluates to false
false = check failed

#val indicates the main metric that is being checked
val = example_metric_name_val

#tags indicates the main owners/people/services responsible for responding to this metric. csv format
tags = person@example.com,person2@example.com

[another example]
expr = mysqlstat_somemetric_value < 10
true = check failed
val = mysqlstat_somemetric_value
tags = someone@

# true or false are not required in each section, there will just
# be no output if the expr evaluates to the missing option

Currently, metric gauges' values are accessed by metric_name_value. Counter values are accessed with metric_name_current. Counter rates are accessed with metric_name_rate.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileToConfig

func FileToConfig(configFile string) (*conf.ConfigFile, error)

Types

type CheckResult

type CheckResult struct {
	Name    string  // Name of check
	Message string  // Message associated with check
	Tags    string  // Who/what should be alerted
	Value   float64 // Value of the main metric being checked
}

Results are returned in the following format

type Checker

type Checker interface {
	// User must call NewScopeAndPackage before
	// inserting metric values
	NewScopeAndPackage() error

	// Metric values mey be inserted from a json package or the
	// metric context (if available)
	// User must insert metric values before running metric check
	InsertMetricValuesFromJSON() error
	// User must insert metric values before running metric check
	InsertMetricValuesFromContext(m *metrics.MetricContext) error

	// Runs metric check
	CheckAll() ([]CheckResult, error)
}

func New

func New(hostport string, config *conf.ConfigFile) (Checker, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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