prometheus

package
v0.0.0-...-ffa1b64 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedSyncers = map[string]syncerFunc{
	"vrops_host_metric":                     newSyncerOfType[VROpsHostMetric],
	"vrops_vm_metric":                       newSyncerOfType[VROpsVMMetric],
	"node_exporter_metric":                  newSyncerOfType[NodeExporterMetric],
	"netapp_aggregate_labels_metric":        newSyncerOfType[NetAppAggregateLabelsMetric],
	"netapp_node_metric":                    newSyncerOfType[NetAppNodeMetric],
	"netapp_volume_aggregate_labels_metric": newSyncerOfType[NetAppVolumeAggrLabelsMetric],
}

List of supported metric types that can be specified in the yaml config.

Functions

func NewCombinedSyncer

func NewCombinedSyncer(
	supportedSyncers map[string]syncerFunc,
	config conf.SyncPrometheusConfig,
	db db.DB,
	monitor sync.Monitor,
	mqttClient mqtt.Client,
) sync.Datasource

Create multiple syncers configured by the external service configuration.

func TriggerMetricAliasSynced

func TriggerMetricAliasSynced(metricAlias string) string

Trigger executed when the prometheus metric with this alias has finished syncing.

func TriggerMetricTypeSynced

func TriggerMetricTypeSynced(metricType string) string

Trigger executed when the prometheus metric with this type has finished syncing.

Types

type CombinedSyncer

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

Syncer that syncs all configured metrics.

func (CombinedSyncer) Init

func (s CombinedSyncer) Init(ctx context.Context)

Initialize all nested syncers.

func (CombinedSyncer) Sync

func (s CombinedSyncer) Sync(context context.Context)

Sync all metrics in parallel and publish triggers.

type NetAppAggregateLabelsMetric

type NetAppAggregateLabelsMetric struct {
	// The name of the metric.
	Name string `db:"name"`

	// The name of the aggregate as included in the Manila field `pool`.
	Aggregate string `json:"aggr" db:"aggr"`
	// One host can host multiple aggregates.
	Host string `json:"host" db:"host"`
	// One aggregate can include multiple nodes.
	Node string `json:"node" db:"node"`

	Filer string `json:"filer" db:"filer"`

	// State (e.g., "online", "offline").
	State string `json:"state" db:"state"`
	// Type, such as `ssd_cap`.
	Type string `json:"type" db:"type"`
	// If the storage is encrypted.
	IsEncrypted string `json:"is_encrypted" db:"is_encrypted"`

	// Timestamp of the metric value.
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
	// The value of the metric (always 1).
	Value float64 `json:"value" db:"value"`
}

Metric exported by NetApp harvest exporter. Some additional fields are omitted. See: https://github.com/NetApp/harvest

func (NetAppAggregateLabelsMetric) GetName

func (m NetAppAggregateLabelsMetric) GetName() string

func (NetAppAggregateLabelsMetric) GetTimestamp

func (m NetAppAggregateLabelsMetric) GetTimestamp() time.Time

func (NetAppAggregateLabelsMetric) GetValue

func (m NetAppAggregateLabelsMetric) GetValue() float64

func (NetAppAggregateLabelsMetric) Indexes

func (m NetAppAggregateLabelsMetric) Indexes() []db.Index

func (NetAppAggregateLabelsMetric) TableName

func (m NetAppAggregateLabelsMetric) TableName() string

func (NetAppAggregateLabelsMetric) With

type NetAppNodeMetric

type NetAppNodeMetric struct {
	// The name of the metric.
	Name string `db:"name"`

	Filer string `json:"filer" db:"filer"`
	// One host can host multiple nodes.
	Host string `json:"host" db:"host"`
	// One node can include multiple filers.
	Node string `json:"node" db:"node"`

	// Timestamp of the metric value.
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
	// The value of the metric.
	Value float64 `json:"value" db:"value"`
}

Metric exported by NetApp harvest exporter. Some additional fields are omitted. See: https://github.com/NetApp/harvest

func (NetAppNodeMetric) GetName

func (m NetAppNodeMetric) GetName() string

func (NetAppNodeMetric) GetTimestamp

func (m NetAppNodeMetric) GetTimestamp() time.Time

func (NetAppNodeMetric) GetValue

func (m NetAppNodeMetric) GetValue() float64

func (NetAppNodeMetric) Indexes

func (m NetAppNodeMetric) Indexes() []db.Index

func (NetAppNodeMetric) TableName

func (m NetAppNodeMetric) TableName() string

func (NetAppNodeMetric) With

type NetAppVolumeAggrLabelsMetric

type NetAppVolumeAggrLabelsMetric struct {
	// The name of the metric.
	Name string `db:"name"`

	// The name of the aggregate as included in the Manila field `pool`.
	Aggregate string `json:"aggr" db:"aggr"`
	// Application name
	App string `json:"app" db:"app"`
	// Filer name
	Filer string `json:"filer" db:"filer"`
	// Host name
	Host string `json:"host" db:"host"`
	// Node name
	Node string `json:"node" db:"node"`
	// UUID
	UUID string `json:"uuid" db:"uuid"`
	// Volume name
	Volume string `json:"volume" db:"volume"`

	// Timestamp of the metric value.
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
	// The value of the metric (usually 1 for label metrics).
	Value float64 `json:"value" db:"value"`
}

Metric exported by NetApp harvest exporter for volume aggregate labels. Some additional fields are omitted. See: https://github.com/NetApp/harvest

func (NetAppVolumeAggrLabelsMetric) GetName

func (NetAppVolumeAggrLabelsMetric) GetTimestamp

func (m NetAppVolumeAggrLabelsMetric) GetTimestamp() time.Time

func (NetAppVolumeAggrLabelsMetric) GetValue

func (NetAppVolumeAggrLabelsMetric) Indexes

func (m NetAppVolumeAggrLabelsMetric) Indexes() []db.Index

func (NetAppVolumeAggrLabelsMetric) TableName

func (m NetAppVolumeAggrLabelsMetric) TableName() string

func (NetAppVolumeAggrLabelsMetric) With

type NodeExporterMetric

type NodeExporterMetric struct {
	// The name of the metric.
	Name string `db:"name"`
	// Name of the kubernetes node.
	Node string `json:"node" db:"node"`
	// Timestamp of the metric value.
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
	// The value of the metric.
	Value float64 `json:"value" db:"value"`
}

Metric exported by node exporter. See: https://github.com/prometheus/node_exporter

func (NodeExporterMetric) GetName

func (m NodeExporterMetric) GetName() string

func (NodeExporterMetric) GetTimestamp

func (m NodeExporterMetric) GetTimestamp() time.Time

func (NodeExporterMetric) GetValue

func (m NodeExporterMetric) GetValue() float64

func (NodeExporterMetric) Indexes

func (m NodeExporterMetric) Indexes() []db.Index

func (NodeExporterMetric) TableName

func (m NodeExporterMetric) TableName() string

func (NodeExporterMetric) With

type PrometheusAPI

type PrometheusAPI[M PrometheusMetric] interface {
	FetchMetrics(
		query string,
		start time.Time,
		end time.Time,
		resolutionSeconds int,
	) (*prometheusTimelineData[M], error)
}

Prometheus API to fetch metrics from Prometheus.

func NewPrometheusAPI

func NewPrometheusAPI[M PrometheusMetric](
	hostConf conf.SyncPrometheusHostConfig,
	metricConf conf.SyncPrometheusMetricConfig,
	monitor sync.Monitor,
) PrometheusAPI[M]

Create a new Prometheus API with the given Prometheus metric type.

type PrometheusMetric

type PrometheusMetric interface {
	db.Table
	// Name of the metric.
	GetName() string
	// Value of this metric datapoint.
	GetValue() float64
	// Timestamp of this metric datapoint.
	GetTimestamp() time.Time
	// Create a new instance of this metric with time and value set
	// from a prometheus range metric query. Also pass a name attribute
	// so that multiple different metrics stored in the same table can
	// be distinguished.
	With(name string, time time.Time, value float64) PrometheusMetric
}

One metric datapoint in the Prometheus timeline.

type Syncer

type Syncer interface {
	sync.Datasource
	// Get triggers produced by this syncer.
	Triggers() []string
}

type VROpsHostMetric

type VROpsHostMetric struct {
	// The name of the metric.
	Name string `db:"name"`
	// Kubernetes cluster name in which the metrics exporter is running.
	Cluster string `json:"cluster" db:"cluster"`
	// Kubernetes cluster type in which the metrics exporter is running.
	ClusterType string `json:"cluster_type" db:"cluster_type"`
	// The name of the metrics collector.
	Collector string `json:"collector" db:"collector"`
	// Datacenter / availability zone of the hostsystem.
	Datacenter string `json:"datacenter" db:"datacenter"`
	// Host system name.
	// Note: this value does not necessarily correspond to the
	// hypervisor service host contained in OpenStack.
	HostSystem string `json:"hostsystem" db:"hostsystem"`
	// Internal name of the hostsystem.
	InternalName string `json:"internal_name" db:"internal_name"`
	// Exporter job name (usually "vrops-exporter").
	Job string `json:"job" db:"job"`
	// Prometheus instance from which the metric was fetched.
	Prometheus string `json:"prometheus" db:"prometheus"`
	// Datacenter region (one level above availability zone).
	Region string `json:"region" db:"region"`
	// VMware vCenter cluster name in which the hostsystem is running.
	VCCluster string `json:"vccluster" db:"vccluster"`
	// VMware vCenter name in which the hostsystem is running.
	VCenter string `json:"vcenter" db:"vcenter"`
	// Timestamp of the metric value.
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
	// The value of the metric.
	Value float64 `json:"value" db:"value"`
}

VROpsHostMetric represents a single metric value from Prometheus that was generated the VMware vROps exporter for a specific hostsystem. See: https://github.com/sapcc/vrops-exporter

func (VROpsHostMetric) GetName

func (m VROpsHostMetric) GetName() string

func (VROpsHostMetric) GetTimestamp

func (m VROpsHostMetric) GetTimestamp() time.Time

func (VROpsHostMetric) GetValue

func (m VROpsHostMetric) GetValue() float64

func (VROpsHostMetric) Indexes

func (m VROpsHostMetric) Indexes() []db.Index

func (VROpsHostMetric) TableName

func (m VROpsHostMetric) TableName() string

func (VROpsHostMetric) With

type VROpsVMMetric

type VROpsVMMetric struct {
	// The name of the metric.
	Name string `db:"name"`
	// Kubernetes cluster name in which the metrics exporter is running.
	Cluster string `json:"cluster" db:"cluster"`
	// Kubernetes cluster type in which the metrics exporter is running.
	ClusterType string `json:"cluster_type" db:"cluster_type"`
	// The name of the metrics collector.
	Collector string `json:"collector" db:"collector"`
	// Datacenter / availability zone of the virtual machine.
	Datacenter string `json:"datacenter" db:"datacenter"`
	// Host system of the virtual machine.
	// Note: this value does not necessarily correspond to the
	// hypervisor service host contained in OpenStack.
	HostSystem string `json:"hostsystem" db:"hostsystem"`
	// Internal name of the virtual machine.
	InternalName string `json:"internal_name" db:"internal_name"`
	// Exporter job name (usually "vrops-exporter").
	Job string `json:"job" db:"job"`
	// OpenStack project ID of the virtual machine.
	Project string `json:"project" db:"project"`
	// Prometheus instance from which the metric was fetched.
	Prometheus string `json:"prometheus" db:"prometheus"`
	// Datacenter region (one level above availability zone).
	Region string `json:"region" db:"region"`
	// VMware vCenter cluster name in which the virtual machine is running.
	VCCluster string `json:"vccluster" db:"vccluster"`
	// VMware vCenter name in which the virtual machine is running.
	VCenter string `json:"vcenter" db:"vcenter"`
	// Name of the virtual machine specified by the OpenStack user.
	VirtualMachine string `json:"virtualmachine" db:"virtualmachine"`
	// OpenStack UUID of the virtual machine instance.
	// Note: not all instances may be seen in the current OpenStack environment.
	InstanceUUID string `json:"instance_uuid" db:"instance_uuid"`
	// Timestamp of the metric value.
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
	// The value of the metric.
	Value float64 `json:"value" db:"value"`
}

VROpsVMMetric represents a single metric value from Prometheus that was generated the VMware vROps exporter for a specific virtual machine. See: https://github.com/sapcc/vrops-exporter

func (VROpsVMMetric) GetName

func (m VROpsVMMetric) GetName() string

func (VROpsVMMetric) GetTimestamp

func (m VROpsVMMetric) GetTimestamp() time.Time

func (VROpsVMMetric) GetValue

func (m VROpsVMMetric) GetValue() float64

func (VROpsVMMetric) Indexes

func (m VROpsVMMetric) Indexes() []db.Index

func (VROpsVMMetric) TableName

func (m VROpsVMMetric) TableName() string

func (VROpsVMMetric) With

Jump to

Keyboard shortcuts

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