cmd

package
v0.0.0-...-fde1fad Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const LatestIndicator = "RUMINANT_LAST_RUN"

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "ruminant",
	Short: "Feed data from ElasticSearch to InfluxDB",
}

Functions

func DefaultPoopTime

func DefaultPoopTime() (start string, end string)

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func SetupLogger

func SetupLogger()

func ToEsTimestamp

func ToEsTimestamp(t time.Time) int64

Types

type Config

type Config struct {
	Regurgitate RegurgitateConf `yaml:"regurgitate"`
	Ruminate    RuminateConf    `yaml:"ruminate"`
	Gulp        GulpConf        `yaml:"gulp"`
	Poop        PoopConf        `yaml:"poop"`
}

func Conf

func Conf(mustExist bool) (Config, error)

func (Config) String

func (c Config) String() string

type ElasticSearch

type ElasticSearch struct {
	Proto string
	Host  string
	Port  int
}

func NewElasticSearch

func NewElasticSearch(proto, host string, port int) ElasticSearch

func (ElasticSearch) Query

func (es ElasticSearch) Query(index, kind, jsonQuery string) (EsResponse, error)

type EsError

type EsError struct {
	Error struct {
		RootCause []struct {
			Type   string `json:"type"`
			Reason string `json:"reason"`
			Line   int    `json:"line"`
			Col    int    `json:"col"`
		} `json:"root_cause"`
		Type   string `json:"type"`
		Reason string `json:"reason"`
		Line   int    `json:"line"`
		Col    int    `json:"col"`
	} `json:"error"`
	Status int `json:"status"`
}

type EsResponse

type EsResponse struct {
	Took     float64 `json:"took"`
	TimedOut bool    `json:"timed_out"`
	Shards   struct {
		Total   float64 `json:"total"`
		Success float64 `json:"success"`
		Failed  float64 `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total    float64     `json:"total"`
		MaxScore float64     `json:"max_score"`
		Hits     interface{} `json:"hits"`
	} `json:"hits"`
	Aggregations interface{} `json:"aggregations"`
	Error        string      `json:"error"`
}

func NewEsResponse

func NewEsResponse(in io.Reader) (EsResponse, error)

func (EsResponse) AggsAsJson

func (esr EsResponse) AggsAsJson() ([]byte, error)

type GulpConf

type GulpConf struct {
	Host      string `yaml:"host"`
	Port      int    `yaml:"port"`
	Db        string `yaml:"db"`
	Proto     string `yaml:"proto"`
	Series    string `yaml:"series"`
	User      string `yaml:"user"`
	Pass      string `yaml:"pass"`
	Indicator string `yaml:"indicator"`
}

type Influx

type Influx struct {
	DB        string
	Client    client.Client
	Series    string
	Indicator string
}

func NewInflux

func NewInflux(host, proto, db, user, pass, series, indicator string, port int) (Influx, error)

func (Influx) DeleteLatestMarker

func (i Influx) DeleteLatestMarker() error

func (Influx) GetLatestMarker

func (i Influx) GetLatestMarker() (t time.Time, err error)

func (Influx) LatestMarker

func (i Influx) LatestMarker(t time.Time, note string) *client.Point

func (Influx) Query

func (i Influx) Query(cmd string) (res []client.Result, err error)

func (Influx) Write

func (i Influx) Write(points []Point) error

type Iterator

type Iterator struct {
	Selector    string            `yaml:"selector"`
	Time        string            `yaml:"time"`
	Tags        map[string]string `yaml:"tags"`
	FixedTags   map[string]string `yaml:"fixed_tags"`
	Values      map[string]string `yaml:"values"`
	FixedValues map[string]string `yaml:"fixed_values"`
	Iterators   []Iterator        `yaml:"iterators"`
}

func (Iterator) GetStructure

func (i Iterator) GetStructure() (tags []string, values []string)

type Point

type Point struct {
	Timestamp time.Time
	Tags      map[string]string
	Values    map[string]interface{}
}

func Avg

func Avg(points []Point, samples int) []Point

func Burp

func Burp(j []byte, i Iterator, inherited Point) ([]Point, string, error)

func Chew

func Chew(j []byte, i Iterator, inherited Point) ([]Point, error)

func Ruminate

func Ruminate(c Config, burp bool) []Point

func (Point) Copy

func (p Point) Copy() Point

func (Point) String

func (p Point) String() string

type PoopConf

type PoopConf struct {
	Query      string   `yaml:"query"`
	Fields     []string `yaml:"fields"`
	Start      string   `yaml:"start"`
	End        string   `yaml:"end"`
	Format     string   `yaml:"format"`
	Separator  string   `yaml:"separator"`
	ReplaceNil string   `yaml:"replace_nil"`
}

type RegurgitateConf

type RegurgitateConf struct {
	Host    string        `yaml:"host"`
	Port    int           `yaml:"port"`
	Proto   string        `yaml:"proto"`
	Index   string        `yaml:"index"`
	Type    string        `yaml:"type"`
	Query   string        `yaml:"query"`
	Sampler SamplerConfig `yaml:"sampler"`
}

type RuminateConf

type RuminateConf struct {
	Iterator Iterator `yaml:"iterator"`
}

type Sampler

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

func NewSampler

func NewSampler(c SamplerConfig) (Sampler, error)

func (Sampler) BuildQueries

func (s Sampler) BuildQueries(templ string, start time.Time) map[time.Time][]string

func (Sampler) Iterate

func (s Sampler) Iterate(from time.Time) []time.Time

type SamplerConfig

type SamplerConfig struct {
	Offset       time.Duration `yaml:"offset"`
	Samples      int           `yaml:"samples"`
	SampleOffset time.Duration `yaml:"sample_offset"`
	Interval     string        `yaml:"interval"`
}

Jump to

Keyboard shortcuts

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