promiot

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

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

Go to latest
Published: Dec 20, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

Promiot

Promiot is an experimental library to allow devices to use Prometheus client library instrumentation locally on device, and convey the metrics over telemetry via Google Cloud IoT Core to be scraped by a Cloud hosted instance of Prometheus for IoT Remote Monitoring.

In golang this can be achieved by directly integrating promiot into your code.

For other languages, a side-car process scrapes metrics locally before sending over MQTT.

See examples folder for demonstration of these patterns.

Promiot provides a built in metric to track the latency of mqtt ack latency: promiot_mqtt_telemetry_puback_latency

As well as latency of publishing to the cloud: promiot_receive_latency_seconds

This is not an official Google Product.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchMetricFamilies

func FetchMetricFamilies(
	url string,
) (mfs []*dto.MetricFamily, err error)

FetchMetricFamilies retrieves metrics from the provided URL, decodes them into MetricFamily proto messages, and sends them to the provided channel. It returns after all MetricFamilies have been sent.

Types

type MetricBundle

type MetricBundle struct {
	// unix UTC time in nanoseconds
	// note that while nanosecond resolution is not needed or likely to be accurate
	// it is the easiest way to pass time around as single value in go
	// time.Now().UnixNano()
	BundleTimestamp int64               `protobuf:"varint,1,opt,name=bundle_timestamp" json:"bundle_timestamp,omitempty"`
	Families        []*dto.MetricFamily `protobuf:"bytes,2,rep,name=families" json:"families,omitempty"`
}

definition of a simple array proto

func (*MetricBundle) ProtoMessage

func (*MetricBundle) ProtoMessage()

func (*MetricBundle) Reset

func (m *MetricBundle) Reset()

func (*MetricBundle) String

func (m *MetricBundle) String() string

type Promiot

type Promiot struct {
	Gatherer prometheus.Gatherer

	PublishDelay int64
	// contains filtered or unexported fields
}

func NewPromiot

func NewPromiot(client mqtt.Client, topic string, defaultLabels map[string]string) (p *Promiot, err error)

func (*Promiot) MustRegister

func (p *Promiot) MustRegister(cs ...prometheus.Collector)

func (*Promiot) Publish

func (p *Promiot) Publish() (err error)

type PromiotReceiver

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

PromiotReceiver combines pubsub topic with a gatherable cache of received metrics implements the prometheus.Gatherer interface

func NewPromiotReceiver

func NewPromiotReceiver(project string, subscription string) *PromiotReceiver

NewPromiotReceiver - constructor

func (*PromiotReceiver) Gather

func (r *PromiotReceiver) Gather() ([]*dto.MetricFamily, error)

Gather : Implement the prometheus "Gather" interface

func (*PromiotReceiver) Receive

func (r *PromiotReceiver) Receive()

Receive - uses cloud pubsub streaming pull to receive metrics over telemetry and decode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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