Documentation ¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func GenerateUserAgent(what, version string) string
- func NewContext(cfg *config.Config, buildVersion string, ...) *context
- func NewIdLookup(resolver hostname.Resolver, cloudHarvester cloud.Harvester, displayName string) host.IDLookup
- func NewIdentityConnectService(client identityapi.IdentityConnectClient, ...) *identityConnectService
- type Agent
- func (a *Agent) DeprecatePlugin(plugin ids.PluginID)
- func (a *Agent) ExternalPluginsHealthCheck()
- func (a *Agent) GetCloudHarvester() cloud.Harvester
- func (a *Agent) GetContext() AgentContext
- func (a *Agent) LogExternalPluginsInfo()
- func (a *Agent) Plugins() []Plugin
- func (a *Agent) RegisterMetricsSender(s registerableSender)
- func (a *Agent) RegisterPlugin(p Plugin)
- func (a *Agent) Run() (err error)
- func (a *Agent) Terminate()
- type AgentContext
- type Inventories
- type Killable
- type MetricPost
- type MetricPostBatch
- type MetricVortexPost
- type MetricVortexPostBatch
- type Plugin
- type PluginCommon
- func (pc *PluginCommon) EmitEvent(eventData map[string]interface{}, entityKey entity.Key)
- func (pc *PluginCommon) EmitInventory(data PluginInventoryDataset, entity entity.Entity)
- func (pc *PluginCommon) GetExternalPluginName() string
- func (pc *PluginCommon) Id() ids.PluginID
- func (pc *PluginCommon) IsExternal() bool
- func (pc *PluginCommon) LogInfo()
- func (pc *PluginCommon) ScheduleHealthCheck()
- func (pc *PluginCommon) Unregister()
- type PluginEmitter
- type PluginInventoryDataset
- type PluginOutput
- type ProvideIDs
- type Sortable
Constants ¶
const ( EVENT_QUEUE_CAPACITY = 1000 BATCH_QUEUE_CAPACITY = 200 // Queue memory consumption cCould be a MAX of config.MaxMetricsBatchSizeBytes * BATCH_QUEUE_CAPACITY in size MAX_EVENT_BATCH_COUNT = 500 EVENT_BATCH_TIMER_DURATION = 1 // seconds, How often we will queue batches of events even if we haven't hit max batch size )
Variables ¶
var ErrEmptyEntityID = errors.New("the agentID provided is empty. make sure you have connected if this is not expected")
ErrEmptyEntityID is returned when the entityID is empty.
Functions ¶
func GenerateUserAgent ¶
func NewContext ¶
func NewContext( cfg *config.Config, buildVersion string, resolver hostname.ResolverChangeNotifier, lookup host.IDLookup, sampleMatchFn sampler.IncludeSampleMatchFn, ) *context
NewContext creates a new context.
func NewIdLookup ¶
func NewIdLookup(resolver hostname.Resolver, cloudHarvester cloud.Harvester, displayName string) host.IDLookup
NewIdLookup creates a new agent ID lookup table.
func NewIdentityConnectService ¶
func NewIdentityConnectService(client identityapi.IdentityConnectClient, fingerprintHarvest fingerprint.Harvester) *identityConnectService
Types ¶
type Agent ¶
type Agent struct { Context *context // Agent context data that is passed around the place // contains filtered or unexported fields }
func New ¶
func New( cfg *config.Config, ctx *context, userAgent string, idLookupTable host.IDLookup, s *delta.Store, connectSrv *identityConnectService, provideIDs ProvideIDs, dataClient backendhttp.Client, transport http.RoundTripper, cloudHarvester cloud.Harvester, fpHarvester fingerprint.Harvester, notificationHandler *ctl.NotificationHandlerWithCancellation, ) (*Agent, error)
New creates a new agent using given context and services.
func NewAgent ¶
func NewAgent( cfg *config.Config, buildVersion string, userAgent string, ffRetriever feature_flags.Retriever) (a *Agent, err error)
NewAgent returns a new instance of an agent built from the config.
func (*Agent) DeprecatePlugin ¶
DeprecatePlugin builds the list of deprecated plugins
func (*Agent) ExternalPluginsHealthCheck ¶
func (a *Agent) ExternalPluginsHealthCheck()
ExternalPluginsHealthCheck schedules the plugins health checks.
func (*Agent) GetCloudHarvester ¶
GetCloudHarvester will return the CloudHarvester service.
func (*Agent) GetContext ¶
func (a *Agent) GetContext() AgentContext
func (*Agent) LogExternalPluginsInfo ¶
func (a *Agent) LogExternalPluginsInfo()
LogExternalPluginsInfo iterates over the list of plugins and logs the information of the external plugins only.
func (*Agent) RegisterMetricsSender ¶
func (a *Agent) RegisterMetricsSender(s registerableSender)
func (*Agent) RegisterPlugin ¶
RegisterPlugin takes a Plugin instance and registers it in the agent's plugin map
type AgentContext ¶
type AgentContext interface { Context() context2.Context SendData(PluginOutput) SendEvent(event sample.Event, entityKey entity.Key) Unregister(ids.PluginID) // Reconnecting tells the agent that this plugin must be re-executed when the agent reconnects after long time // disconnected (> 24 hours). AddReconnecting(Plugin) // Reconnect invokes again all the plugins that have been registered with the AddReconnecting function Reconnect() Config() *config.Config // EntityKey stores agent entity key (name), value may change in runtime. EntityKey() string Version() string // Service -> PID cache. This is used so we can translate between PIDs and service names easily. // The cache is populated by all plugins which produce lists of services, and used by metrics // which get processes and want to determine which service each process is for. CacheServicePids(source string, pidMap map[int]string) GetServiceForPid(pid int) (service string, ok bool) ActiveEntitiesChannel() chan string // HostnameResolver returns the host name resolver associated to the agent context HostnameResolver() hostname.Resolver IDLookup() host.IDLookup // Identity returns the entity ID of the infra agent Identity() entity.Identity }
AgentContext defines the interfaces between plugins and the agent
type Inventories ¶
type Inventories struct {
// contains filtered or unexported fields
}
Inventories processes inventories from multiple entities and splits them if they are too big for the limited sizes imposed by the inventory ingest API
func NewInventories ¶
func NewInventories(store *delta.Store, ctx AgentContext, client *inventoryapi.IngestClient, inventories *map[string]*inventory, agentIdentifier string, compactEnabled bool, compactThreshold uint64, maxDataSize int) Inventories
NewInventories instantiates and returns a new Inventories object given the configuration passed as arguments
func (*Inventories) BulkPatchProcess ¶
func (i *Inventories) BulkPatchProcess() error
BulkPatchProcess processes the deltas from all the entities in the Delta Store and submits them to the ingest service, splitting them if necessary into multiple requests. This function is not thread-safe. This function is blocking.
type Killable ¶
type Killable interface {
// Kill terminates the receiver of the function.
Kill()
}
Killable defines the behaviour of a plugin that can be externally terminated.
type MetricPost ¶
type MetricPost struct { ExternalKeys []string `json:"ExternalKeys,omitempty"` EntityID entity.ID `json:"EntityID,omitempty"` IsAgent bool `json:"IsAgent"` Events []json.RawMessage `json:"Events"` // Entity ID of the reporting agent, which will = EntityID when IsAgent == true. // The field is required in the backend for host metadata matching of the remote entities ReportingAgentID entity.ID `json:"ReportingAgentID,omitempty"` }
MetricPost entity item for the HTTP post to be sent to the ingest service.
type MetricPostBatch ¶
type MetricPostBatch []*MetricPost
MetricPostBatch HTTP post batching all the MetricPost per entity to be sent to the ingest service.
type MetricVortexPost ¶
type MetricVortexPost struct { EntityID entity.ID `json:"EntityID"` EntityKey entity.Key `json:"EntityKey"` IsAgent bool `json:"IsAgent"` Events []json.RawMessage `json:"Events"` // Entity ID of the reporting agent, which will = EntityID when IsAgent == true. // The field is required in the backend for host metadata matching of the remote entities ReportingAgentID entity.ID `json:"ReportingAgentID"` }
MetricPost entity item for the HTTP post to be sent to the ingest service.
type MetricVortexPostBatch ¶
type MetricVortexPostBatch []*MetricVortexPost
MetricPostBatch HTTP post batching all the MetricPost per entity to be sent to the ingest service.
type Plugin ¶
type Plugin interface { Run() Id() ids.PluginID IsExternal() bool GetExternalPluginName() string LogInfo() ScheduleHealthCheck() }
Plugin describes the interface all agent plugins implement
type PluginCommon ¶
type PluginCommon struct { ID ids.PluginID // the "ID" is the path we write the json to Context AgentContext // a reference to the calling agent context External bool // If the plugin is an external plugin ExternalPluginName string // The external plugin name. Ex: com.newrelic.nginx // Returns all the information related to the plugin, including // runtime environment variables DetailedLogFields func() logrus.Fields LogFields logrus.Fields // fields to include when logging about the plugin HealthCheckCh chan struct{} // notifies the plugin to execute a health check // contains filtered or unexported fields }
PluginCommon contains attributes and methods available to all plugins
func NewExternalPluginCommon ¶
func NewExternalPluginCommon(id ids.PluginID, ctx AgentContext, name string) PluginCommon
func (*PluginCommon) EmitEvent ¶
func (pc *PluginCommon) EmitEvent(eventData map[string]interface{}, entityKey entity.Key)
func (*PluginCommon) EmitInventory ¶
func (pc *PluginCommon) EmitInventory(data PluginInventoryDataset, entity entity.Entity)
EmitInventory sends data collected by the plugin to the agent
func (*PluginCommon) GetExternalPluginName ¶
func (pc *PluginCommon) GetExternalPluginName() string
GetExternalPluginName is the accessor for the ExternalPluginName field
func (*PluginCommon) Id ¶
func (pc *PluginCommon) Id() ids.PluginID
Id is the accessor for the id field
func (*PluginCommon) IsExternal ¶
func (pc *PluginCommon) IsExternal() bool
IsExternal is the accessor for the External field
func (*PluginCommon) LogInfo ¶
func (pc *PluginCommon) LogInfo()
LogInfo retrieves logs the plugin name for internal plugins, and for the external plugins it logs the data specified in the log fields.
func (*PluginCommon) ScheduleHealthCheck ¶
func (pc *PluginCommon) ScheduleHealthCheck()
func (*PluginCommon) Unregister ¶
func (pc *PluginCommon) Unregister()
Unregister tells the agent that this plugin cannot run
type PluginEmitter ¶
type PluginInventoryDataset ¶
type PluginInventoryDataset []Sortable // PluginInventoryDataset is a slice of sortable things
func (PluginInventoryDataset) Len ¶
func (pd PluginInventoryDataset) Len() int
PluginInventoryDataset also implements the sort.Sort interface
func (PluginInventoryDataset) Less ¶
func (pd PluginInventoryDataset) Less(i, j int) bool
func (PluginInventoryDataset) Swap ¶
func (pd PluginInventoryDataset) Swap(i, j int)
type PluginOutput ¶
type PluginOutput struct { Id ids.PluginID Entity entity.Entity Data PluginInventoryDataset NotApplicable bool }
PluginOutput contains metadata about the inventory provided by Plugins, which will be used for its later addition to the delta store
func NewNotApplicableOutput ¶
func NewNotApplicableOutput(id ids.PluginID) PluginOutput
func NewPluginOutput ¶
func NewPluginOutput(id ids.PluginID, entity entity.Entity, data PluginInventoryDataset) PluginOutput
type ProvideIDs ¶
type ProvideIDs func(agentIdn entity.Identity, entities []identityapi.RegisterEntity) ([]identityapi.RegisterEntityResponse, error)
ProvideIDs provides remote entity IDs. Waits for next retry if register endpoint status is not healthy.
func NewProvideIDs ¶
func NewProvideIDs( client identityapi.RegisterClient, sm state.RegisterSM, ) ProvideIDs
NewProvideIDs creates a new remote entity IDs provider.