Documentation ¶
Index ¶
- Constants
- func ConvertGroupAddresses(src string, target string) error
- type Config
- type Connection
- type ConnectionType
- type DPT
- type Duration
- type GroupAddress
- type GroupAddressConfig
- type GroupAddressConfigSet
- type GroupClient
- type Listener
- type MetricSnapshotHandler
- type MetricsExporter
- type PhysicalAddress
- type Poller
- type Snapshot
- type SnapshotKey
Constants ¶
const InvalidGroupAddress = GroupAddress(0)
InvalidGroupAddress defines the nil group address.
const InvalidPhysicalAddress = PhysicalAddress(0)
const Router = ConnectionType("Router")
const Tunnel = ConnectionType("Tunnel")
Variables ¶
This section is empty.
Functions ¶
func ConvertGroupAddresses ¶
Types ¶
type Config ¶
type Config struct { Connection Connection `json:",omitempty"` // MetricsPrefix is a short prefix which will be added in front of the actual metric name. MetricsPrefix string AddressConfigs GroupAddressConfigSet }
Config defines the structure of the configuration file which defines which KNX Group Addresses were mapped into prometheus metrics.
func ReadConfig ¶ added in v0.2.0
ReadConfig reads the given configuration file and returns the parsed Config object.
func (*Config) NameFor ¶
func (c *Config) NameFor(gaConfig GroupAddressConfig) string
NameFor return s the full metric name for the given GroupAddressConfig.
func (*Config) NameForGa ¶
func (c *Config) NameForGa(address GroupAddress) string
NameForGa returns the full metric name for the given GroupAddress.
type Connection ¶
type Connection struct { // Type of the actual connection. Can be either Tunnel or Router Type ConnectionType // Endpoint defines the IP address or hostname and port to where it should connect. Endpoint string // PhysicalAddress defines how the knx-exporter should identify itself within the KNX system. PhysicalAddress PhysicalAddress }
Connection contains the information about how to connect to the KNX system and how to identify itself.
type ConnectionType ¶
type ConnectionType string
func (ConnectionType) MarshalJSON ¶
func (t ConnectionType) MarshalJSON() ([]byte, error)
func (*ConnectionType) UnmarshalJSON ¶
func (t *ConnectionType) UnmarshalJSON(data []byte) error
type DPT ¶
DPT is wrapper interface for all types under github.com/vapourismo/knx-go/knx/dpt to simplifies working with them.
type GroupAddress ¶
GroupAddress defines a single group address. It do not contain any additional information about purpose, data types or allowed telegram types.
func NewGroupAddress ¶
func NewGroupAddress(str string) (GroupAddress, error)
NewGroupAddress creates a new GroupAddress by parsing the given string. It either returns the parsed GroupAddress or an error if it is not possible to parse the string.
func (GroupAddress) MarshalJSON ¶
func (g GroupAddress) MarshalJSON() ([]byte, error)
func (GroupAddress) MarshalText ¶
func (g GroupAddress) MarshalText() ([]byte, error)
func (GroupAddress) String ¶
func (g GroupAddress) String() string
func (*GroupAddress) UnmarshalJSON ¶
func (g *GroupAddress) UnmarshalJSON(data []byte) error
func (*GroupAddress) UnmarshalText ¶
func (g *GroupAddress) UnmarshalText(data []byte) error
type GroupAddressConfig ¶
type GroupAddressConfig struct { // Name defines the prometheus metric name without the MetricsPrefix. Name string // Comment to identify the group address. Comment string `json:",omitempty"` // DPT defines the DPT at the knx bus. This is required to parse the values correctly. DPT string // MetricType is the type that prometheus uses when exporting it. i.e. gauge or counter MetricType string // Export the metric to prometheus Export bool // ReadActive allows the exporter to actively send `GroupValueRead` telegrams to actively poll the value instead waiting for it. ReadActive bool `json:",omitempty"` // MaxAge of a value until it will actively send a `GroupValueRead` telegram to read the value if ReadActive is set to true. MaxAge Duration `json:",omitempty"` // Labels defines static labels that should be set when exporting the metric using prometheus. Labels map[string]string `json:",omitempty"` }
GroupAddressConfig defines all information to map a KNX group address to a prometheus metric.
type GroupAddressConfigSet ¶
type GroupAddressConfigSet map[GroupAddress]GroupAddressConfig
GroupAddressConfigSet is a shortcut type for the group address config map.
type GroupClient ¶
type GroupClient interface { Send(event knx.GroupEvent) error Inbound() <-chan knx.GroupEvent Close() }
GroupClient is a super interface for the knx.GroupClient interface to also export the Close() function.
type Listener ¶ added in v0.2.0
type Listener interface { Run() IsActive() bool }
func NewListener ¶ added in v0.2.0
func NewListener(config *Config, inbound <-chan knx.GroupEvent, metricsChan chan *Snapshot, messageCounter *prometheus.CounterVec) Listener
type MetricSnapshotHandler ¶ added in v0.2.0
type MetricSnapshotHandler interface { // AddSnapshot adds a new snapshot that should be exported as metric. AddSnapshot(snapshot *Snapshot) // FindSnapshot finds a given snapshot by the snapshots key. FindSnapshot(key SnapshotKey) (*Snapshot, error) // FindYoungestSnapshot finds the youngest snapshot with the given metric name. // It don't matter from which device the snapshot was received. FindYoungestSnapshot(name string) *Snapshot // GetValueFunc returns a function that returns the current value for the given snapshot key. GetValueFunc(key SnapshotKey) func() float64 // Run let the MetricSnapshotHandler listen for new snapshots on the Snapshot channel. Run() // GetMetricsChannel returns the channel to send new snapshots to this MetricSnapshotHandler. GetMetricsChannel() chan *Snapshot // Close stops listening for new Snapshots and closes the Snapshot channel. Close() // IsActive indicates that this handler is active and waits for new metric snapshots IsActive() bool }
MetricSnapshotHandler holds and manages all the snapshots of metrics.
func NewMetricsSnapshotHandler ¶ added in v0.2.0
func NewMetricsSnapshotHandler(registerer prometheus.Registerer) MetricSnapshotHandler
type MetricsExporter ¶
func NewMetricsExporter ¶
func NewMetricsExporter(configFile string, registerer prometheus.Registerer) (MetricsExporter, error)
type PhysicalAddress ¶
type PhysicalAddress cemi.IndividualAddr
PhysicalAddress defines an individual address of a knx device.
func NewPhysicalAddress ¶
func NewPhysicalAddress(str string) (PhysicalAddress, error)
NewPhysicalAddress creates a new knx device PhysicalAddress by parsing the given string. It either returns the parsed PhysicalAddress or an error if it is not possible to parse the string.
func (PhysicalAddress) MarshalJSON ¶
func (g PhysicalAddress) MarshalJSON() ([]byte, error)
func (PhysicalAddress) MarshalText ¶
func (g PhysicalAddress) MarshalText() ([]byte, error)
func (PhysicalAddress) String ¶
func (g PhysicalAddress) String() string
func (*PhysicalAddress) UnmarshalJSON ¶
func (g *PhysicalAddress) UnmarshalJSON(data []byte) error
func (*PhysicalAddress) UnmarshalText ¶
func (g *PhysicalAddress) UnmarshalText(data []byte) error
type Poller ¶
type Poller interface { // Run starts the polling. Run() // Close stops the polling. Close() }
Poller defines the interface for active polling for metrics values against the knx system.
func NewPoller ¶
func NewPoller(config *Config, client GroupClient, metricsHandler MetricSnapshotHandler, messageCounter *prometheus.CounterVec) Poller
NewPoller creates a new Poller instance using the given MetricsExporter for connection handling and metrics observing.
type Snapshot ¶ added in v0.2.0
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot stores all information about a single metric snapshot.
func (*Snapshot) GetKey ¶ added in v0.2.0
func (s *Snapshot) GetKey() SnapshotKey
type SnapshotKey ¶ added in v0.2.0
type SnapshotKey struct {
// contains filtered or unexported fields
}
SnapshotKey identifies all the snapshots that were received from a specific device and exported with the specific name.