Documentation ¶
Index ¶
- func CreatePrefix(prefix, target string) (*gnmi.Path, error)
- func ParsePath(p string) (*gnmi.Path, error)
- func TagsFromGNMIPath(p *gnmi.Path) (string, map[string]string)
- type Collector
- func (c *Collector) InitTarget(tc *TargetConfig)
- func (c *Collector) PolledSubscriptionsTargets() map[string][]string
- func (c *Collector) Start(ctx context.Context)
- func (c *Collector) Subscribe(ctx context.Context, tName string) error
- func (c *Collector) TargetPoll(targetName, subscriptionName string) (*gnmi.SubscribeResponse, error)
- type Config
- type EventMsg
- type MarshalOptions
- type NotificationRspMsg
- type SubscribeResponse
- type SubscriptionConfig
- type Target
- func (t *Target) Capabilities(ctx context.Context, ext ...*gnmi_ext.Extension) (*gnmi.CapabilityResponse, error)
- func (t *Target) CreateGNMIClient(ctx context.Context, opts ...grpc.DialOption) error
- func (t *Target) Export(rsp *gnmi.SubscribeResponse, m outputs.Meta)
- func (t *Target) Get(ctx context.Context, req *gnmi.GetRequest) (*gnmi.GetResponse, error)
- func (t *Target) Set(ctx context.Context, req *gnmi.SetRequest) (*gnmi.SetResponse, error)
- func (t *Target) Subscribe(ctx context.Context, req *gnmi.SubscribeRequest, subscriptionName string)
- type TargetConfig
- type TargetError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collector ¶
type Collector struct { Config *Config Subscriptions map[string]*SubscriptionConfig Outputs map[string][]outputs.Output DialOpts []grpc.DialOption Targets map[string]*Target Logger *log.Logger // contains filtered or unexported fields }
Collector //
func NewCollector ¶
func NewCollector( config *Config, targetConfigs map[string]*TargetConfig, subscriptions map[string]*SubscriptionConfig, outputs map[string][]outputs.Output, dialOpts []grpc.DialOption, logger *log.Logger, ) *Collector
NewCollector //
func (*Collector) InitTarget ¶
func (c *Collector) InitTarget(tc *TargetConfig)
InitTarget initializes a target based on *TargetConfig
func (*Collector) PolledSubscriptionsTargets ¶
PolledSubscriptionsTargets returns a map of target name to a list of subscription names that have Mode == POLL
func (*Collector) Start ¶
Start start the prometheus server as well as a goroutine per target selecting on the response chan, the error chan and the ctx.Done() chan
func (*Collector) TargetPoll ¶
func (c *Collector) TargetPoll(targetName, subscriptionName string) (*gnmi.SubscribeResponse, error)
TargetPoll sends a gnmi.SubscribeRequest_Poll to targetName and returns the response and an error, it uses the targetName and the subscriptionName strings to find the gnmi.GNMI_SubscribeClient
type Config ¶
type Config struct { PrometheusAddress string Debug bool Format string TargetReceiveBuffer uint RetryTimer time.Duration }
Config is the collector config
type EventMsg ¶ added in v0.2.0
type EventMsg struct { Name string `json:"name,omitempty"` // measurement name Timestamp int64 `json:"timestamp,omitempty"` Tags map[string]string `json:"tags,omitempty"` Values map[string]interface{} `json:"values,omitempty"` Deletes []string `json:"deletes,omitempty"` }
EventMsg //
func ResponseToEventMsgs ¶ added in v0.2.0
func ResponseToEventMsgs(name string, rsp *gnmi.SubscribeResponse, meta map[string]string) ([]*EventMsg, error)
ResponseToEventMsgs //
type MarshalOptions ¶ added in v0.2.0
type MarshalOptions struct { Multiline bool // could get rid of this and deduct it from len(Indent) Indent string Format string }
func (*MarshalOptions) FormatJSON ¶ added in v0.2.0
FormatJSON formats a proto.Message and returns a []byte and an error
type NotificationRspMsg ¶ added in v0.2.0
type NotificationRspMsg struct { Meta map[string]interface{} `json:"meta,omitempty"` Source string `json:"source,omitempty"` SystemName string `json:"system-name,omitempty"` SubscriptionName string `json:"subscription-name,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` Time *time.Time `json:"time,omitempty"` Prefix string `json:"prefix,omitempty"` Target string `json:"target,omitempty"` Updates []update `json:"updates,omitempty"` Deletes []string `json:"deletes,omitempty"` }
type SubscribeResponse ¶
type SubscribeResponse struct { SubscriptionName string Response *gnmi.SubscribeResponse }
SubscribeResponse //
type SubscriptionConfig ¶
type SubscriptionConfig struct { Name string `mapstructure:"name,omitempty"` Models []string `mapstructure:"models,omitempty"` Prefix string `mapstructure:"prefix,omitempty"` Target string `mapstructure:"target,omitempty"` Paths []string `mapstructure:"paths,omitempty"` Mode string `mapstructure:"mode,omitempty"` StreamMode string `mapstructure:"stream-mode,omitempty"` Encoding string `mapstructure:"encoding,omitempty"` Qos *uint32 `mapstructure:"qos,omitempty"` SampleInterval *time.Duration `mapstructure:"sample-interval,omitempty"` HeartbeatInterval *time.Duration `mapstructure:"heartbeat-interval,omitempty"` SuppressRedundant bool `mapstructure:"suppress-redundant,omitempty"` UpdatesOnly bool `mapstructure:"updates-only,omitempty"` }
SubscriptionConfig //
func (*SubscriptionConfig) CreateSubscribeRequest ¶
func (sc *SubscriptionConfig) CreateSubscribeRequest() (*gnmi.SubscribeRequest, error)
CreateSubscribeRequest validates the SubscriptionConfig and creates gnmi.SubscribeRequest
type Target ¶
type Target struct { Config *TargetConfig Subscriptions []*SubscriptionConfig Outputs []outputs.Output Client gnmi.GNMIClient SubscribeClients map[string]gnmi.GNMI_SubscribeClient // subscription name to subscribeClient PollChan chan string // subscription name to be polled SubscribeResponses chan *SubscribeResponse Errors chan *TargetError // contains filtered or unexported fields }
Target represents a gNMI enabled box
func (*Target) Capabilities ¶
func (t *Target) Capabilities(ctx context.Context, ext ...*gnmi_ext.Extension) (*gnmi.CapabilityResponse, error)
Capabilities sends a gnmi.CapabilitiesRequest to the target *t and returns a gnmi.CapabilitiesResponse and an error
func (*Target) CreateGNMIClient ¶
CreateGNMIClient //
func (*Target) Export ¶
func (t *Target) Export(rsp *gnmi.SubscribeResponse, m outputs.Meta)
Export //
func (*Target) Get ¶
func (t *Target) Get(ctx context.Context, req *gnmi.GetRequest) (*gnmi.GetResponse, error)
Get sends a gnmi.GetRequest to the target *t and returns a gnmi.GetResponse and an error
func (*Target) Set ¶
func (t *Target) Set(ctx context.Context, req *gnmi.SetRequest) (*gnmi.SetResponse, error)
Set sends a gnmi.SetRequest to the target *t and returns a gnmi.SetResponse and an error
type TargetConfig ¶
type TargetConfig struct { Name string `mapstructure:"name,omitempty"` Address string `mapstructure:"address,omitempty"` Username *string `mapstructure:"username,omitempty"` Password *string `mapstructure:"password,omitempty"` Timeout time.Duration `mapstructure:"timeout,omitempty"` Insecure *bool `mapstructure:"insecure,omitempty"` TLSCA *string `mapstructure:"tls-ca,omitempty"` TLSCert *string `mapstructure:"tls-cert,omitempty"` TLSKey *string `mapstructure:"tls-key,omitempty"` SkipVerify *bool `mapstructure:"skip-verify,omitempty"` Subscriptions []string `mapstructure:"subscriptions,omitempty"` Outputs []string `mapstructure:"outputs,omitempty"` BufferSize uint `mapstructure:"buffer-size,omitempty"` RetryTimer time.Duration `mapstructure:"retry,omitempty"` }
TargetConfig //
func (*TargetConfig) String ¶
func (tc *TargetConfig) String() string