metrics

package module
v0.0.0-...-fb66375 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: MIT Imports: 7 Imported by: 0

README

clickhouse-metrics

Documentation Go Report Card Coverage Status CircleCI Codacy Badge

Implementation of metric storage over ClickHouse

Installing

First, you should have installed ClickHouse. To make it an easy way, you can get Docker image of ClickHouse

Then, install this package

go get github.com/saromanov/clickhouse-metrics
Examples

see examples directory

Built With

Authors

Licence

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateQuery

type AggregateQuery struct {
	Action   string
	Entities []string
	Label    string
	Range    string
	ActionIf string
}

AggregateQuery defines struct for making aggregation

func (*AggregateQuery) GetAction

func (q *AggregateQuery) GetAction() string

GetAction returns action

func (*AggregateQuery) GetActionIf

func (q *AggregateQuery) GetActionIf() string

GetActionIf returns action if

func (*AggregateQuery) GetEntities

func (q *AggregateQuery) GetEntities() []string

GetEntities returns slice of entities

func (*AggregateQuery) GetLabel

func (q *AggregateQuery) GetLabel() string

GetLabel returns label

func (*AggregateQuery) GetRange

func (q *AggregateQuery) GetRange() string

GetRange returns range

func (*AggregateQuery) GetTsEqual

func (q *AggregateQuery) GetTsEqual() uint32

GetTsEqual returns timestamp equal param

func (*AggregateQuery) GetTsGreater

func (q *AggregateQuery) GetTsGreater() uint32

GetTsGreater returns timestamp greater param

func (*AggregateQuery) GetTsLess

func (q *AggregateQuery) GetTsLess() uint32

GetTsLess returns timestamp Less param

func (*AggregateQuery) Type

func (q *AggregateQuery) Type() QueryType

Type returns type of the query

type ClickHouseMetrics

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

ClickHouseMetrics implements the main app

func New

func New(c *Config) (*ClickHouseMetrics, error)

New provides initialization of the project

func (*ClickHouseMetrics) Aggregate

func (c *ClickHouseMetrics) Aggregate(q *AggregateQuery) (interface{}, error)

Aggregate provides operations for aggregation

func (*ClickHouseMetrics) Client

func (c *ClickHouseMetrics) Client() *sql.DB

Client returns current ClickHouse client

func (*ClickHouseMetrics) Insert

func (c *ClickHouseMetrics) Insert(m *Metric) error

Insert provides inserting of the metrics data

func (*ClickHouseMetrics) List

func (c *ClickHouseMetrics) List(q *ListQuery) ([]interface{}, error)

List retruns list of the metrics by the query

func (*ClickHouseMetrics) Query

func (c *ClickHouseMetrics) Query(q string) ([]*Metric, error)

Query provides query of the data by the request

type Config

type Config struct {
	// DBName is a name for metrics database
	DBName string
	// Address is a connection address to ClickHouse
	Address string
}

Config applies specification to the app start

type ListQuery

type ListQuery struct {
	Entities  []string
	Label     string
	TsEqual   uint32
	TsGreater uint32
	TsLess    uint32
	Range     string
}

ListQuery provides struct for the query definition

func (*ListQuery) GetAction

func (q *ListQuery) GetAction() string

GetAction returns action

func (*ListQuery) GetActionIf

func (q *ListQuery) GetActionIf() string

GetActionIf returns action if

func (*ListQuery) GetEntities

func (q *ListQuery) GetEntities() []string

GetEntities returns slice of entities

func (*ListQuery) GetLabel

func (q *ListQuery) GetLabel() string

GetLabel returns label

func (*ListQuery) GetRange

func (q *ListQuery) GetRange() string

GetRange returns range

func (*ListQuery) GetTsEqual

func (q *ListQuery) GetTsEqual() uint32

GetTsEqual returns timestamp equal param

func (*ListQuery) GetTsGreater

func (q *ListQuery) GetTsGreater() uint32

GetTsGreater returns timestamp greater param

func (*ListQuery) GetTsLess

func (q *ListQuery) GetTsLess() uint32

GetTsLess returns timestamp Less param

func (*ListQuery) Type

func (q *ListQuery) Type() QueryType

Type returns type of the query

type Metric

type Metric struct {
	Entity   string    `json:"entity"`
	Names    []string  `json:"names"`
	Values   []float32 `json:"values"`
	DateTime time.Time `json:"datetime"`
}

Metric defines structure for metrics representation

type QueryType

type QueryType string

QueryType provides definition for the type of the query

const (
	// ListQueryType defines query for the list
	ListQueryType QueryType = "listQuery"

	// AggregationQueryType defines query for aggregation
	AggregationQueryType QueryType = "aggregationQuery"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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