Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MetricsKnown = map[MetricKnownName]struct { RenameTo string EncodedType utils.MetricType }{ CPUUsage: { RenameTo: "node_cpu_usage", EncodedType: utils.Percentage, }, DiskUsage: { RenameTo: "node_disk_usage_percentage", EncodedType: utils.Percentage, }, DiskIoRead: { RenameTo: "node_disk_io_ops_read", EncodedType: utils.Float, }, DiskIoWrites: { RenameTo: "node_disk_io_ops_write", EncodedType: utils.Float, }, LoadAverage: { RenameTo: "node_load_average", EncodedType: utils.Float, }, MemAvailable: { RenameTo: "node_memory_available_percentage", EncodedType: utils.Percentage, }, MemUsage: { RenameTo: "node_memory_used_percentage", EncodedType: utils.Percentage, }, NetReceive: { RenameTo: "node_net_receive", EncodedType: utils.Float, }, NetSend: { RenameTo: "node_net_send", EncodedType: utils.Float, }, }
I'm not confident this will always be the only set of names, nor am I confident they will always exist. ['cpu_usage', 'disk_usage', 'diskio_read', 'diskio_writes', 'load_average', 'mem_available', 'mem_usage', 'net_receive', 'net_send'] TODO(eddiebergman): I wasn't sure on the naming, as the units are missing from some of these metrics, and I tried to match pre-existing ones where possible.
Functions ¶
This section is empty.
Types ¶
type FetchMetricJSONData ¶
type FetchMetricJSONData struct {
Data struct {
Cols []Schema `json:"cols" validate:"required"`
Rows [][]any `json:"rows" validate:"required"` // 1st element is Schema, rest are values with length of Cols
} `json:"data" validate:"required"`
MaxTimestamp int64 `json:"max_timestamp" validate:"required"` // seconds since epoch
TotalSeries int64 `json:"total_series"` // How many rows there are I guess?
Hints struct {
Title string `json:"title"`
} `json:"hints"` // Additional metadata like title
}
type FetchMetricsJSONScheme ¶
type FetchMetricsJSONScheme map[string]FetchMetricJSONData
type FetchedMetricsIn ¶
type FetchedMetricsIn struct {
ProjectName string
ServiceName string
Client *aiven.Client
Logger *log.Logger
Period service.PeriodType
Metrics []MetricKnownName
}
type FetchedMetricsOut ¶
type FetchedMetricsOut map[MetricKnownName]MaybeParsedMetric
func GetFetchedMetrics ¶
func GetFetchedMetrics( ctx context.Context, in FetchedMetricsIn, ) (FetchedMetricsOut, error)
Fetches all metrics from Aiven and returns them as a map of metric name to ParsedMetric For any metrics that error, we log the error and return nil for that metric
type MaybeParsedMetric ¶
type MaybeParsedMetric struct {
ParsedMetric
Error error
}
type MetricKnownName ¶
type MetricKnownName string
const ( CPUUsage MetricKnownName = "cpu_usage" DiskUsage MetricKnownName = "disk_usage" DiskIoRead MetricKnownName = "diskio_read" DiskIoWrites MetricKnownName = "diskio_writes" LoadAverage MetricKnownName = "load_average" MemAvailable MetricKnownName = "mem_available" MemUsage MetricKnownName = "mem_usage" NetReceive MetricKnownName = "net_receive" NetSend MetricKnownName = "net_send" )
type ParsedMetric ¶
type ParsedMetric struct {
Name MetricKnownName
RenameTo string
Value any
Type utils.MetricType
Timestamp time.Time
}
FetchedHardwareMetrics is a struct that contains the latest values for each metric and the maximum known timestamp. In theory the `MaximumKnownTimestamp` is the same for all metrics, but we store it separately for each metric as this is not gauranteed.
type Schema ¶
type Schema struct {
Label string `json:"label" validate:"required"`
Type string `json:"type"` // "number" or "date", could be others
}
NOTE: The label is what's important, as we want to log the metrics of the master node.
[{'label': 'time', 'type': 'date'}, {'label': 'pg-1f3a86df-14 (standby)', 'type': 'number'}, {'label': 'pg-1f3a86df-15 (master)', 'type': 'number'}]