platon

package
v0.0.0-...-28857fc Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRange time.Duration = 1 * time.Hour

Functions

func DeleteCubes

func DeleteCubes(clickhouse clickhouse.Clickhouse, cubes Cubes) error

func PrintDimensions

func PrintDimensions(metricsFilter []string, prometheusUrl string)

func PrintMetrics

func PrintMetrics(dimensionFilter []string, prometheusUrl string)

func ValueHelp

func ValueHelp(metric, dimension, prometheusUrl string) error

func WatchCubes

func WatchCubes(clickhouse clickhouse.Clickhouse, cubes Cubes, prometheusUrl string)

Types

type Column

type Column struct {
	Name       string
	DataType   string
	ColumnType string
}

type Cube

type Cube struct {
	Name           string        `yaml:"name"`
	Description    string        `yaml:"description"`
	Ttl            time.Duration `yaml:"ttl"`
	ScrapeInterval time.Duration `yaml:"scrape-interval"`
	Queries        []Query       `yaml:"queries"`
	JoinedLabels   []string      `yaml:"joined-labels"`
	LastUpdate     time.Time
}

func (*Cube) GetAggregation

func (c *Cube) GetAggregation(query string) string

func (*Cube) GetMetricColumns

func (c *Cube) GetMetricColumns() []string

type Cubes

type Cubes struct {
	Cubes []Cube `yaml:"cubes"`
}

func GenerateCube

func GenerateCube(cubeName string, metricNames []string, prometheusUrl string) Cubes

type Metric

type Metric struct {
	Name       string
	Dimensions []string
}

type Platon

type Platon struct {
	Cubes         Cubes
	Database      clickhouse.Clickhouse
	StartTime     time.Time
	EndTime       time.Time
	Client        api.Client
	PrometheusUrl string
	// contains filtered or unexported fields
}

func NewPlaton

func NewPlaton(prometheusUrl string) *Platon

func (*Platon) CreateTable

func (p *Platon) CreateTable(table Table) error

func (*Platon) EnsureColumns

func (p *Platon) EnsureColumns(table Table) error

func (*Platon) EnsureTable

func (p *Platon) EnsureTable(table Table) error

func (*Platon) GetMetrics

func (p *Platon) GetMetrics(metricsFilter ...string) ([]Metric, error)

func (*Platon) GetSamples

func (p *Platon) GetSamples(metric string, start, end time.Time) (model.Value, error)

func (*Platon) InsertData

func (p *Platon) InsertData(table Table) error

func (*Platon) TableExists

func (p *Platon) TableExists(table Table) (bool, error)

func (*Platon) UpdateCube

func (p *Platon) UpdateCube(cube Cube)

type Query

type Query struct {
	Name        string `yaml:"name"`
	PromQL      string `yaml:"promql"`
	Value       string `yaml:"value"`
	Aggregation string `yaml:"aggregation"`
}

type Row

type Row struct {
	Dimensions map[string]string
	Metrics    map[string]float64
	Time       time.Time
}

func NewRow

func NewRow(time time.Time) *Row

func (Row) GetOrderedValues

func (r Row) GetOrderedValues(order []Column) []interface{}

type Table

type Table struct {
	Name       string
	Dimensions []string
	Metrics    []string
	Rows       []*Row
}

func MetricsToTable

func MetricsToTable(query Query, queryResult model.Value) (Table, error)

func (*Table) CountMatches

func (t *Table) CountMatches(dimensions []string, otherRow *Row) (count uint64, err error)

func (Table) GetColumns

func (t Table) GetColumns() []Column

func (*Table) GetDimension

func (t *Table) GetDimension(dimension string) string

func (*Table) GetFirstMatchingRow

func (t *Table) GetFirstMatchingRow(dimensions []string, otherRow *Row) (*Row, error)

func (*Table) GetMetric

func (t *Table) GetMetric(metric string) string

func (Table) GetQuotedColumnNames

func (t Table) GetQuotedColumnNames() []string

func (*Table) InsertRow

func (t *Table) InsertRow(rowInput *Row)

func (*Table) PrettyPrint

func (t *Table) PrettyPrint(limit int)

Jump to

Keyboard shortcuts

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