integration

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 16 Imported by: 7

Documentation

Index

Constants

View Source
const (
	CustomAttrPrefix = "NRI_"
)

Custom attribute keys:

Variables

This section is empty.

Functions

func Count

func Count(timestamp time.Time, metricName string, value float64) (metric.Metric, error)

Count creates a metric of type count

func CumulativeCount

func CumulativeCount(timestamp time.Time, metricName string, value float64) (metric.Metric, error)

CumulativeCount creates metric of type cumulative count

func CumulativeRate

func CumulativeRate(timestamp time.Time, metricName string, value float64) (metric.Metric, error)

CumulativeRate creates a metric of type cumulative rate

func Gauge

func Gauge(timestamp time.Time, metricName string, value float64) (metric.Metric, error)

Gauge creates a metric of type gauge

func PrometheusHistogram

func PrometheusHistogram(timestamp time.Time, metricName string, sampleCount uint64, sampleSum float64) (*metric.PrometheusHistogram, error)

PrometheusHistogram creates a metric of type prometheus histogram

func PrometheusSummary

func PrometheusSummary(timestamp time.Time, metricName string, sampleCount uint64, sampleSum float64) (*metric.PrometheusSummary, error)

PrometheusSummary creates a metric of type prometheus summary

func Rate

func Rate(timestamp time.Time, metricName string, value float64) (metric.Metric, error)

Rate creates a metric of type rate

func Summary

func Summary(timestamp time.Time, metricName string, count float64,
	average float64, sum float64, min float64, max float64) (metric.Metric, error)

Summary creates a metric of type summary

Types

type Common

type Common struct {
	Timestamp *int64 `json:"timestamp,omitempty"`
	Interval  *int64 `json:"interval.ms,omitempty"`
	// Attributes are optional, they represent additional information that
	// can be attached to an event.
	Attributes map[string]interface{} `json:"attributes,omitempty"`
}

Common is the producer of the common dimensions/attributes.

type Entity

type Entity struct {
	CommonDimensions Common               `json:"common"` // dimensions common to every entity metric
	Metadata         *metadata.Metadata   `json:"entity,omitempty"`
	Metrics          metric.Metrics       `json:"metrics"`
	Inventory        *inventory.Inventory `json:"inventory"`
	Events           event.Events         `json:"events"`
	// IgnoreEntity defines if the Entity should be registered within the infra agent, if true
	// the Entity will not be attached to the infra agent entity neither registered.
	IgnoreEntity bool `json:"ignore_entity"`
	// contains filtered or unexported fields
}

Entity is the producer of the data. Entity could be a host, a container, a pod, or whatever unit of meaning.

func (*Entity) AddCommonDimension added in v4.1.0

func (e *Entity) AddCommonDimension(key string, value string)

AddCommonDimension adds a new dimension to every metric within the entity.

func (*Entity) AddCommonInterval added in v4.1.1

func (e *Entity) AddCommonInterval(timestamp time.Duration)

AddCommonInterval adds a common interval in milliseconds from a time.Duration (nanoseconds).

func (*Entity) AddCommonTimestamp added in v4.1.1

func (e *Entity) AddCommonTimestamp(timestamp time.Time)

AddCommonTimestamp adds a new common timestamp to the entity.

func (*Entity) AddEvent

func (e *Entity) AddEvent(event *event.Event)

AddEvent method adds a new Event.

func (*Entity) AddInventoryItem

func (e *Entity) AddInventoryItem(key string, field string, value interface{}) error

AddInventoryItem method sets the inventory item (only one allowed).

func (*Entity) AddMetadata

func (e *Entity) AddMetadata(key string, value interface{}) error

AddMetadata adds a new metadata to the entity

func (*Entity) AddMetric

func (e *Entity) AddMetric(metric metric.Metric)

AddMetric adds a new metric to the entity metrics list

func (*Entity) AddTag

func (e *Entity) AddTag(key string, value interface{}) error

AddTag adds a new tag to the entity

func (*Entity) GetMetadata

func (e *Entity) GetMetadata() metadata.Map

GetMetadata returns all the Entity's metadata

func (*Entity) Name

func (e *Entity) Name() string

Name is the unique entity identifier within a New Relic customer account.

func (*Entity) SameAs

func (e *Entity) SameAs(b *Entity) bool

SameAs return true when is same entity

func (*Entity) SetIgnoreEntity added in v4.2.0

func (e *Entity) SetIgnoreEntity(value bool)

SetIgnoreEntity set if the infra agent should register the entity

type Integration

type Integration struct {
	ProtocolVersion string    `json:"protocol_version"`
	Metadata        Metadata  `json:"integration"`
	Entities        []*Entity `json:"data"`
	// HostEntity is an "entity" that serves as dumping ground for metrics not associated with a specific entity
	HostEntity *Entity `json:"-"` //skip json serializing
	// contains filtered or unexported fields
}

Integration defines the format of the output JSON that integrations will return for protocol 2.

func New

func New(name, version string, opts ...Option) (i *Integration, err error)

New creates new integration with sane default values.

func (*Integration) AddEntity

func (i *Integration) AddEntity(e *Entity)

AddEntity adds an entity to the list of entities. No check for "duplicates" is performed

func (*Integration) Clear

func (i *Integration) Clear()

Clear re-initializes the Inventory, Metrics and Events for this integration. Used after publishing so the object can be reused.

func (*Integration) FindEntity

func (i *Integration) FindEntity(name string) (*Entity, bool)

FindEntity finds ad return an entity by name. returns false if entity does not exist in the integration

func (*Integration) GetHostID added in v4.2.0

func (i *Integration) GetHostID() string

GetHostID returns NriHostID or an empty string if not set

func (*Integration) Logger

func (i *Integration) Logger() log.Logger

Logger returns the integration logger instance.

func (*Integration) MarshalJSON

func (i *Integration) MarshalJSON() (output []byte, err error)

MarshalJSON serializes integration to JSON, fulfilling Marshaler interface.

func (*Integration) NewEntity

func (i *Integration) NewEntity(name string, entityType string, displayName string) (e *Entity, err error)

NewEntity method creates a new (uniquely named) Entity. The `name` of the Entity must be unique for the account otherwise it will cause conflicts

func (*Integration) Publish

func (i *Integration) Publish() error

Publish writes the data to output (stdout) and resets the integration "object"

type Metadata

type Metadata struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Metadata describes the integration

type Option

type Option func(*Integration) error

Option sets an option on integration level.

func Args

func Args(a interface{}) Option

Args sets the destination struct (pointer) where the command-line flags will be parsed to.

func Logger

func Logger(l log.Logger) Option

Logger replaces the logger.

func Writer

func Writer(w io.Writer) Option

Writer replaces the output writer.

Jump to

Keyboard shortcuts

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