Documentation ¶
Overview ¶
Package scotty collects endpoint health metrics asynchronously.
Package scotty collects endpoint health metrics asynchronously. The scotty code and the REST API that the scotty application provides are subject to change.
Fetching metrics from scotty using REST API ¶
REST urls (always use GET)
http://scottyhostname.com:6980/api/hosts/someHostName/someAppName Returns every metric from someAppName on someHostName along with values for the last hour. http://scottyhostname.com:6980/api/hosts/someHostName/someAppName/a/path Returns every metric under /a/path from someAppName on someHostName along with values for the last hour. If no metrics match, returns an empty list. http://scottyhostname.com:6980/api/latest/a/path Returns the latest values of all metrics under /a/path on all endpoints sorted by hostname first, appname second, and path third. http://scottyhostname.com:6980/api/errors Returns a list of every endpoint that scotty cannot currently reach along with the timestamp of the last attempt and the error encountered. If no errors, returns an empty list.
Global optional REST Query Parameters
format=text Adds indentation and line feeds to JSON to make it human readable.
Optional REST Query parameters for /api/hosts calls.
singleton=true For the second api/hosts URL listed, returned metrics must match the specified metric path exactly. Use if you want a particular metric rather than all the metrics under a particular path. history=123 Shows values for the last 123 minutes. history=0 shows only the most recent values. If omitted, default is 60 minutes.
Sample JSON for api/hosts calls.
[ { "path": "/proc/args", "description": "Program args", "unit": "None", "kind": "string", "values": [ { "timestamp": "1450810183.939569234", "value": "-r -t -n", "active": true } ] }, { "path": "/proc/cpu/sys", "description": "User CPU time used", "unit": "Seconds", "kind": "duration", "values": [ { "timestamp": "1450812042.050224065", "value": "579.000432200" "active": true }, { "timestamp": "1450811980.899730682", "value": "579.000167902" "active": true }, { "timestamp": "1450811923.538924217", "value": "579.000008265" "active": true } } } ]
Sample JSON for api/error call
[ { "hostName": "b-imserv-r07e14-prod.ash1.symcpe.net*1037", "timestamp": "1450812819.791744615", "error": "dial tcp 10.119.150.73:7776: getsockopt: connection refused" }, { "hostName": "b-imserv-r07e14-prod.ash1.symcpe.net*2037", "timestamp": "1450812819.807774730", "error": "dial tcp 10.119.150.73:7776: getsockopt: connection refused" } ]
Sample JSON for api/latest call
[ { "hostName": "first.net", "appName": "My App", "path": "/proc/args", "description": "Program args", "unit": "None", "kind": "string", "timestamp": "1476307345.592506885", "value": "-f --size=1000" }, { "hostName": "second.net", "appName": "My App", "path": "/proc/args", "description": "Program args", "unit": "None", "kind": "string", "timestamp": "1476307345.554426431", "value": "--size=2000" }, ... ]
For more information on the json schema, see the scotty/messages package
Scotty GO RPC ¶
Scotty GO RPC is available on the same port as the REST API, usually 6980. You can see these methods by visiting http://scottyhostname.com:6980/debug/rpc
Scotty.Latest ¶
Gets the latest available metrics under a given path for all active endpoints. Pass the absolute path as the input. Empty string ("") means get all the latest available metrics. "/foo" means get the metric "/foo" from each endpoint or any metric underneath "/foo" from each endpoint. The output are the latest metrics as []*messages.LatestMetric. The output are sorted first by hostname then by application name and then by metric path.
GO RPC scotty.Latest Example code:
import "fmt" import "github.com/Symantec/scotty/messages" import "log" import "net/rpc" client, _ := rpc.DialHTTP("tcp", "a.hostname.net:6980") defer client.Close() var latest []*messages.LatestMetric if err := client.Call("Scotty.Latest", "/path/to/metrics", &latest); err != nil { log.Fatal(err) } for _, m := range latest { fmt.Println("Path: ", m.Path) fmt.Println("Timestamp: ", m.Timestamp) fmt.Println("Value: ", m.Value) }
Index ¶
- func ConcurrentConnects() uint
- func ConcurrentPolls() uint
- func SetConcurrentConnects(x uint)
- func SetConcurrentPolls(x uint)
- type Endpoint
- type Logger
- type State
- func (s *State) ConnectorName() string
- func (s *State) Status() Status
- func (s *State) SweepStartTime() time.Time
- func (s *State) TimeSpentConnecting() time.Duration
- func (s *State) TimeSpentPolling() time.Duration
- func (s *State) TimeSpentWaitingToConnect() time.Duration
- func (s *State) TimeSpentWaitingToPoll() time.Duration
- func (s *State) Timestamp() time.Time
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcurrentConnects ¶
func ConcurrentConnects() uint
ConcurrentConnects returns the maximum number of concurrent connects.
func ConcurrentPolls ¶
func ConcurrentPolls() uint
ConcurrentPolls returns the maximum number of concurrent polls. Default is 2 * number of CPUs. A return of 0 means no limit.
func SetConcurrentConnects ¶
func SetConcurrentConnects(x uint)
SetConcurrentConnects sets the maximum number of concurrent connects. Call SetConcurrentConnects at the beginning of the main() function before calling Endpoint.Poll
func SetConcurrentPolls ¶
func SetConcurrentPolls(x uint)
SetConcurrentPolls sets the maximum number of concurrent polls. Zero means no limit. Call SetConcurrentPolls at the beginning of the main() function before calling Endpoint.Poll
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint represents a particular endpoint with health metrics. Endpoint instances are safe to use with multiple goroutines.
func NewEndpointWithConnector ¶
func NewEndpointWithConnector( hostId *hostid.HostID, appName string, connector sources.Connector) *Endpoint
NewEndpointWithConnector creates a new endpoint for given host, port and connector.
func (*Endpoint) ConnectorName ¶
ConnectorName returns the name of the underlying connector in this endpoint.
func (*Endpoint) IpAddress ¶
IpAddress returns the IP Address if known or the empty string if not known.
func (*Endpoint) Poll ¶
Poll polls for metrics for this endpoint asynchronously. However, Poll may block while it waits to begin connecting if too many requests for metrics are in progress. Poll returns immediately if this instance is already in the process of collecting metrics. sweepStartTime is the start time of the current collection of metrics. isTls indicates whether or not TLS should be used port is the port to use to connect. logger logs collection events for this polling
type Logger ¶
type Logger interface { // Called when new metrics come in from a given endpoint. If // implementation returns a non-nil error, state goes to // FailedtoPoll. Otherwise, state goes to Synced. LogResponse( e *Endpoint, response metrics.List, timestamp time.Time) error // Called when error happens collecting metrics from a given // endpoint. // Also called when an error clears. In such a case both err and // state are nil. LogError(e *Endpoint, err error, state *State) // Called when collection status changes on a given endpoint LogStateChange(e *Endpoint, oldState, newState *State) }
Logger is the interface for instances that log metric collection events. Endpoint instances call Logger methods immediately after updating themselves. Logger instances must be safe to use among multiple goroutines.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state of collecting metrics from a endpoint. State instances are immutable.
func (*State) ConnectorName ¶
ConnectorName returns the name of the connector
func (*State) SweepStartTime ¶
SweepStartTime returns the start time of the sweep.
func (*State) TimeSpentConnecting ¶
TimeSpentConnecting returns the time spent establishing a connection.
func (*State) TimeSpentPolling ¶
TimeSpentPolling returns the time spent downloading the metrics.
func (*State) TimeSpentWaitingToConnect ¶
TimeSpentWaitingToConnect returns the time elapsed from the start of the sweep until establishing a connection first commences.
func (*State) TimeSpentWaitingToPoll ¶
TimeSpentWaitingToPoll returns time elpased from when the connection was established to when downloading metrics first commences.
Directories ¶
Path | Synopsis |
---|---|
Package application manages individual applications for scotty.
|
Package application manages individual applications for scotty. |
apps
|
|
cloudhealthtestserver
cloudhealthtestserver This application is a fake cloudhealth endpoint.
|
cloudhealthtestserver This application is a fake cloudhealth endpoint. |
Package awsinfo contains routines to extract from AWS metadata
|
Package awsinfo contains routines to extract from AWS metadata |
Package chpipeline manages collecting data for cloudhealth and other systems
|
Package chpipeline manages collecting data for cloudhealth and other systems |
The cis package handles sending data to CIS.
|
The cis package handles sending data to CIS. |
Package cloudhealth contains routines for writing to cloud health
|
Package cloudhealth contains routines for writing to cloud health |
cloudhealthlmm contains routines for writing cloudhealth data to lmm.
|
cloudhealthlmm contains routines for writing cloudhealth data to lmm. |
The cloudwatch package writes data to aws cloudwatch
|
The cloudwatch package writes data to aws cloudwatch |
Package consul integrates scotty with Consul.
|
Package consul integrates scotty with Consul. |
Package endpointdata contains a data structure for collecting data from endpoints.
|
Package endpointdata contains a data structure for collecting data from endpoints. |
Package hostid contains types to identify hosts
|
Package hostid contains types to identify hosts |
influx
|
|
qlutils
Package qlutils contains utilities for handling influx ql queries.
|
Package qlutils contains utilities for handling influx ql queries. |
responses
Package responses contains routines for handling influx ql result sets.
|
Package responses contains routines for handling influx ql result sets. |
lib
|
|
apiutil
Package apiutil contains routines for creating API endpoints.
|
Package apiutil contains routines for creating API endpoints. |
dynconfig
Package dynconfig provides routines for implementing dynamic configuration files.
|
Package dynconfig provides routines for implementing dynamic configuration files. |
gate
Package gate provides management of critical sections
|
Package gate provides management of critical sections |
httputil
Package httputil contains various http utilities.
|
Package httputil contains various http utilities. |
jsonutil
Package jsonutil provides utilities for reading and unmarshaling JSON including strict unmarshaling of JSON into go structs.
|
Package jsonutil provides utilities for reading and unmarshaling JSON including strict unmarshaling of JSON into go structs. |
keyedqueue
Package keyedqueue provides a queue with keyed elements allowing elements already on the queue to be easily replaced.
|
Package keyedqueue provides a queue with keyed elements allowing elements already on the queue to be easily replaced. |
pool
Package pool provides pools for io.Closer instances.
|
Package pool provides pools for io.Closer instances. |
preference
Package preference contains routines for maintaining order of preference for expensive processes such as RPC methods.
|
Package preference contains routines for maintaining order of preference for expensive processes such as RPC methods. |
queuesender
Package queuesender implements asynchronous http.
|
Package queuesender implements asynchronous http. |
retry
Package retry allows multiple goroutines to function until it succeeds.
|
Package retry allows multiple goroutines to function until it succeeds. |
synchttp
Package synchttp writes JSON to an endpoint and waits for a response.
|
Package synchttp writes JSON to an endpoint and waits for a response. |
trimetrics
Package trimetrics contains routines to facilitate exposing metrics in tricorder.
|
Package trimetrics contains routines to facilitate exposing metrics in tricorder. |
yamlutil
Package yamlutil provides utilities for reading and unmarshaling YAML including strict unmarshaling of YAML into go structs.
|
Package yamlutil provides utilities for reading and unmarshaling YAML including strict unmarshaling of YAML into go structs. |
Package machine keeps track of machines and applications for scotty.
|
Package machine keeps track of machines and applications for scotty. |
Package messages provides types for JSON and go rpc.
|
Package messages provides types for JSON and go rpc. |
Package metrics provides a view of metrics that is independent of source.
|
Package metrics provides a view of metrics that is independent of source. |
Package namesandports contains the NamesAndPorts datastructure.
|
Package namesandports contains the NamesAndPorts datastructure. |
Packge pstore and sub packages handle writing metrics to persistent storage.
|
Packge pstore and sub packages handle writing metrics to persistent storage. |
config
Package config includes utilities for handling configuration files.
|
Package config includes utilities for handling configuration files. |
config/influx
Package influx enables writing metric values to influxdb.
|
Package influx enables writing metric values to influxdb. |
config/kafka
Package kafka enables writing metric values to kafka.
|
Package kafka enables writing metric values to kafka. |
config/lmm
Package lmm enables writing metric values to lmm.
|
Package lmm enables writing metric values to lmm. |
config/mock
Package mock enables writing metric values to a mockdb for testing.
|
Package mock enables writing metric values to a mockdb for testing. |
config/tsdb
Package tsdb enables writing metric values to tsdb.
|
Package tsdb enables writing metric values to tsdb. |
Package sources provides the interfaces for metric sources.
|
Package sources provides the interfaces for metric sources. |
jsonsource
Package jsonsource connects to sources using tricorder json.
|
Package jsonsource connects to sources using tricorder json. |
loadsource
Package loadsource provides bogus metrics for load testing.
|
Package loadsource provides bogus metrics for load testing. |
selfsource
Package selfsource get metrics for current process
|
Package selfsource get metrics for current process |
snmpsource
Package snmpsource connects to sources using snmp
|
Package snmpsource connects to sources using snmp |
trisource
Package trisource connects to sources using tricorder.
|
Package trisource connects to sources using tricorder. |
Package store handles storing metric values in memory.
|
Package store handles storing metric values in memory. |
btreepq
Package btreepq implements a queue of pages for scotty based on btrees.
|
Package btreepq implements a queue of pages for scotty based on btrees. |
Package suggest contains routines to implement a suggest engine Package suggest contains routines to implement a suggest engine
|
Package suggest contains routines to implement a suggest engine Package suggest contains routines to implement a suggest engine |
Package sysmemory tells scotty how much memory to use.
|
Package sysmemory tells scotty how much memory to use. |
package tsdb contains the data structures for emulating the TSDB API.
|
package tsdb contains the data structures for emulating the TSDB API. |
aggregators
Package aggregators contains aggregator factory methods.
|
Package aggregators contains aggregator factory methods. |
Package tsdbexec is the top level package for serving tsdb requests.
|
Package tsdbexec is the top level package for serving tsdb requests. |
package tsdbimpl contains routines for internally fulfilling tsdb APi requests.
|
package tsdbimpl contains routines for internally fulfilling tsdb APi requests. |
Package tsdbjson handles tsdb JSON requests and responses.
|
Package tsdbjson handles tsdb JSON requests and responses. |