cloudhealth

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 9 Imported by: 9

Documentation

Overview

Package cloudhealth contains routines for writing to cloud health

Index

Constants

View Source
const (
	// Default endpoint for cloudhealth service.
	DefaultEndpoint = "https://chapi.cloudhealthtech.com/metrics/v1"
)
View Source
const FsDataPointCount = 9 // 3 variables * (min,max,avg)
View Source
const InstanceDataPointCount = 12 // 4 variables * (min,max,avg)
View Source
const MaxDataPoints = 1000

Maximum datapoints that can be written to cloudhealth at once

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer buffers data to add to cloudhealth

func NewBuffer

func NewBuffer() *Buffer

NewBuffer returns a new, empty buffer

func (*Buffer) Add

func (b *Buffer) Add(instance InstanceData, fss []FsData) bool

Add adds an instance and its file systems returning true if the add succeeded. Add returns false if adding the instance and the filesystem would cause the number of data points to exceed the cloudhealth limit.

func (*Buffer) Clear

func (b *Buffer) Clear()

Clear clears this buffer so that IsEmpty returns true

func (*Buffer) Get

func (b *Buffer) Get() ([]InstanceData, []FsData)

Get returns a defensive copy of what is in this buffer

func (*Buffer) IsEmpty

func (b *Buffer) IsEmpty() bool

IsEmpty returns true if this buffer is empty

type Config

type Config struct {
	ApiKey        string `yaml:"apiKey"`
	DataCenter    string `yaml:"dataCenter"`    // e.g us-east-1
	AccountNumber string `yaml:"accountNumber"` // default account number
	DryRun        bool   `yaml:"dryRun"`        // If true, runs in dry run mode

	// like "http://somehost.com:1234/endpoint" If omitted, defaults to
	// standard endpoint for cloudhealth.
	Endpoint string `yaml:"endpoint"`
}

Config configures the writer

func (*Config) Reset

func (c *Config) Reset()

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

type FVariable

type FVariable struct {
	Count uint64
	Min   float64
	Max   float64
	Sum   float64
}

FVariable represents a floating point cloudhealth variable rolled up over some amount of time

func (*FVariable) Add

func (v *FVariable) Add(x float64)

Add adds x to this variable

func (FVariable) Avg

func (v FVariable) Avg() float64

Avg returns the average of this variable

func (*FVariable) Clear

func (v *FVariable) Clear()

Clear clears out this variable.

func (FVariable) IsEmpty

func (v FVariable) IsEmpty() bool

IsEmpty returns true if no values have been added to this variable

type FsData

type FsData struct {
	AccountNumber string    // account number if different from default
	InstanceId    string    // the aws instance ID
	MountPoint    string    // The mount point of file system
	Ts            time.Time // The timestamp at one hour granularity
	FsSizeBytes   IVariable
	FsUsedBytes   IVariable
	FsUsedPercent FVariable
}

FsData contains rolled up data for a particular file system

type IVariable

type IVariable struct {
	Count uint64
	Min   uint64
	Max   uint64
	Sum   uint64
}

IVariable represents an integer cloudhealth variable rolled up over some amount of time

func (*IVariable) Add

func (v *IVariable) Add(x uint64)

Add adds x to this variable

func (IVariable) Avg

func (v IVariable) Avg() uint64

Avg returns the average of this variable

func (*IVariable) Clear

func (v *IVariable) Clear()

Clear clears out this variable.

func (IVariable) IsEmpty

func (v IVariable) IsEmpty() bool

IsEmpty returns true if no values have been added to this variable

type InstanceData

type InstanceData struct {
	AccountNumber     string    // account number if different from default
	InstanceId        string    // The aws instance ID
	Ts                time.Time // The timestamp at one hour granularity
	CpuUsedPercent    FVariable
	MemoryFreeBytes   IVariable
	MemorySizeBytes   IVariable
	MemoryUsedPercent FVariable
}

InstanceData contains rolled up data for a particular instance

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(config Config) (*Writer, error)

NewWriter returns a new Writer instance.

func (*Writer) Write

func (w *Writer) Write(
	instances []InstanceData, fss []FsData) (
	responseCode int, err error)

Write writes the provided data in a single request. Write returns an error if the number of data points exceeds 1000. That is, len(instances)*InstanceDataPointCount + len(fss)*FsDataPointCount >= 1000. Write returns the http response code along with an error if applicable. If the write is parital success, Write returns 200 along with the error. Write will never return a 429 response. If Write receives a 429, it retries using exponential backoff internally until it receives a non 429 response and returns that.

Jump to

Keyboard shortcuts

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