metricdata

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) 2022 DKRZ All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var TestLoadDataCallback func(job *schema.Job, metrics []string, scopes []schema.MetricScope, ctx context.Context, resolution int) (schema.JobData, error) = func(job *schema.Job, metrics []string, scopes []schema.MetricScope, ctx context.Context, resolution int) (schema.JobData, error) {
	panic("TODO")
}

Functions

func DeepCopy added in v1.4.0

func DeepCopy(jd_temp schema.JobData) schema.JobData

func Init

func Init() error

func MinMaxMean

func MinMaxMean(data []schema.Float) (float64, float64, float64)

Types

type ApiMetricData

type ApiMetricData struct {
	Error      *string        `json:"error"`
	Data       []schema.Float `json:"data"`
	From       int64          `json:"from"`
	To         int64          `json:"to"`
	Resolution int            `json:"resolution"`
	Avg        schema.Float   `json:"avg"`
	Min        schema.Float   `json:"min"`
	Max        schema.Float   `json:"max"`
}

type ApiQuery

type ApiQuery struct {
	Type       *string  `json:"type,omitempty"`
	SubType    *string  `json:"subtype,omitempty"`
	Metric     string   `json:"metric"`
	Hostname   string   `json:"host"`
	Resolution int      `json:"resolution"`
	TypeIds    []string `json:"type-ids,omitempty"`
	SubTypeIds []string `json:"subtype-ids,omitempty"`
	Aggregate  bool     `json:"aggreg"`
}

type ApiQueryRequest

type ApiQueryRequest struct {
	Cluster     string     `json:"cluster"`
	Queries     []ApiQuery `json:"queries"`
	ForAllNodes []string   `json:"for-all-nodes"`
	From        int64      `json:"from"`
	To          int64      `json:"to"`
	WithStats   bool       `json:"with-stats"`
	WithData    bool       `json:"with-data"`
}

type ApiQueryResponse

type ApiQueryResponse struct {
	Queries []ApiQuery        `json:"queries,omitempty"`
	Results [][]ApiMetricData `json:"results"`
}

type CCMetricStore

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

func (*CCMetricStore) Init

func (ccms *CCMetricStore) Init(rawConfig json.RawMessage) error

func (*CCMetricStore) LoadData

func (ccms *CCMetricStore) LoadData(
	job *schema.Job,
	metrics []string,
	scopes []schema.MetricScope,
	ctx context.Context,
	resolution int,
) (schema.JobData, error)

func (*CCMetricStore) LoadNodeData

func (ccms *CCMetricStore) LoadNodeData(
	cluster string,
	metrics, nodes []string,
	scopes []schema.MetricScope,
	from, to time.Time,
	ctx context.Context,
) (map[string]map[string][]*schema.JobMetric, error)

TODO: Support sub-node-scope metrics! For this, the partition of a node needs to be known!

func (*CCMetricStore) LoadStats

func (ccms *CCMetricStore) LoadStats(
	job *schema.Job,
	metrics []string,
	ctx context.Context,
) (map[string]map[string]schema.MetricStatistics, error)

type CCMetricStoreConfig

type CCMetricStoreConfig struct {
	Kind  string `json:"kind"`
	Url   string `json:"url"`
	Token string `json:"token"`

	// If metrics are known to this MetricDataRepository under a different
	// name than in the `metricConfig` section of the 'cluster.json',
	// provide this optional mapping of local to remote name for this metric.
	Renamings map[string]string `json:"metricRenamings"`
}

type InfluxDBv2DataRepository

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

func (*InfluxDBv2DataRepository) Init

func (idb *InfluxDBv2DataRepository) Init(rawConfig json.RawMessage) error

func (*InfluxDBv2DataRepository) LoadData

func (idb *InfluxDBv2DataRepository) LoadData(
	job *schema.Job,
	metrics []string,
	scopes []schema.MetricScope,
	ctx context.Context,
	resolution int) (schema.JobData, error)

func (*InfluxDBv2DataRepository) LoadNodeData

func (idb *InfluxDBv2DataRepository) LoadNodeData(
	cluster string,
	metrics, nodes []string,
	scopes []schema.MetricScope,
	from, to time.Time,
	ctx context.Context) (map[string]map[string][]*schema.JobMetric, error)

func (*InfluxDBv2DataRepository) LoadStats

func (idb *InfluxDBv2DataRepository) LoadStats(
	job *schema.Job,
	metrics []string,
	ctx context.Context) (map[string]map[string]schema.MetricStatistics, error)

type InfluxDBv2DataRepositoryConfig

type InfluxDBv2DataRepositoryConfig struct {
	Url     string `json:"url"`
	Token   string `json:"token"`
	Bucket  string `json:"bucket"`
	Org     string `json:"org"`
	SkipTls bool   `json:"skiptls"`
}

type MetricDataRepository

type MetricDataRepository interface {
	// Initialize this MetricDataRepository. One instance of
	// this interface will only ever be responsible for one cluster.
	Init(rawConfig json.RawMessage) error

	// Return the JobData for the given job, only with the requested metrics.
	LoadData(job *schema.Job, metrics []string, scopes []schema.MetricScope, ctx context.Context, resolution int) (schema.JobData, error)

	// Return a map of metrics to a map of nodes to the metric statistics of the job. node scope assumed for now.
	LoadStats(job *schema.Job, metrics []string, ctx context.Context) (map[string]map[string]schema.MetricStatistics, error)

	// Return a map of hosts to a map of metrics at the requested scopes for that node.
	LoadNodeData(cluster string, metrics, nodes []string, scopes []schema.MetricScope, from, to time.Time, ctx context.Context) (map[string]map[string][]*schema.JobMetric, error)
}

func GetMetricDataRepo added in v1.4.0

func GetMetricDataRepo(cluster string) (MetricDataRepository, error)

type PromQLArgs

type PromQLArgs struct {
	Nodes string
}

type PrometheusDataRepository

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

func (*PrometheusDataRepository) FormatQuery

func (pdb *PrometheusDataRepository) FormatQuery(
	metric string,
	scope schema.MetricScope,
	nodes []string,
	cluster string,
) (string, error)

TODO: respect scope argument

func (*PrometheusDataRepository) Init

func (pdb *PrometheusDataRepository) Init(rawConfig json.RawMessage) error

func (*PrometheusDataRepository) LoadData

func (pdb *PrometheusDataRepository) LoadData(
	job *schema.Job,
	metrics []string,
	scopes []schema.MetricScope,
	ctx context.Context,
	resolution int,
) (schema.JobData, error)

func (*PrometheusDataRepository) LoadNodeData

func (pdb *PrometheusDataRepository) LoadNodeData(
	cluster string,
	metrics, nodes []string,
	scopes []schema.MetricScope,
	from, to time.Time,
	ctx context.Context,
) (map[string]map[string][]*schema.JobMetric, error)

func (*PrometheusDataRepository) LoadStats

func (pdb *PrometheusDataRepository) LoadStats(
	job *schema.Job,
	metrics []string,
	ctx context.Context,
) (map[string]map[string]schema.MetricStatistics, error)

TODO change implementation to precomputed/cached stats

func (*PrometheusDataRepository) RowToSeries

func (pdb *PrometheusDataRepository) RowToSeries(
	from time.Time,
	step int64,
	steps int64,
	row *promm.SampleStream,
) schema.Series

Convert PromAPI row to CC schema.Series

type PrometheusDataRepositoryConfig

type PrometheusDataRepositoryConfig struct {
	Url       string            `json:"url"`
	Username  string            `json:"username,omitempty"`
	Suffix    string            `json:"suffix,omitempty"`
	Templates map[string]string `json:"query-templates"`
}

type TestMetricDataRepository

type TestMetricDataRepository struct{}

Only a mock for unit-testing.

func (*TestMetricDataRepository) Init

func (*TestMetricDataRepository) LoadData

func (tmdr *TestMetricDataRepository) LoadData(
	job *schema.Job,
	metrics []string,
	scopes []schema.MetricScope,
	ctx context.Context,
	resolution int) (schema.JobData, error)

func (*TestMetricDataRepository) LoadNodeData

func (tmdr *TestMetricDataRepository) LoadNodeData(
	cluster string,
	metrics, nodes []string,
	scopes []schema.MetricScope,
	from, to time.Time,
	ctx context.Context) (map[string]map[string][]*schema.JobMetric, error)

func (*TestMetricDataRepository) LoadStats

func (tmdr *TestMetricDataRepository) LoadStats(
	job *schema.Job,
	metrics []string, ctx context.Context) (map[string]map[string]schema.MetricStatistics, error)

type Trie

type Trie map[rune]Trie

Jump to

Keyboard shortcuts

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