Class: Insights

Insights(config)

new Insights(config)

Insights
Parameters:
Name Type Description
config Object configuration object
Properties
Name Type Attributes Default Description
accountId string your newrelic insights account id
insertKey string your newrelic insert key
queryKey string your newrelic query key
timerInterval integer <optional>
10000 the timer interval (in milliseconds) that is used for sending data
maxPending integer <optional>
1000 the maximum number of items held in the queue before being sent
defaultEventType string <optional>
'data' when adding data, you can specify the eventType that is sent to New Relic. If you don't specify the eventType, the defaultEventType is used.
enabled boolean <optional>
true enable/disable the sending of insights data.
gzip boolean <optional>
false enable/disable the sending of insights data zipped via gzip.
Source:
Example
new Insights({
     accountId: '...',
     insertKey: '...',
     queryKey: '...',
   });

Methods

add(data, eventTypeopt)

Add insights data to the queue. It is sent when the queue reaches a max size or a period of time has elapsed
Parameters:
Name Type Attributes Description
data object data to flatten and send to insights
eventType string <optional>
event type to associate with data
Source:

finish()

Stop the timer after flushing.
Source:

nrql(params)

Build a nrql query string
Parameters:
Name Type Description
params object object containing key/values of nrql query
Source:
Example
nrql = insights.nrql({
     select: 'uniqueCount(session)',
    from: 'PageView',
    since: '1 week ago',
    until: '1 day ago',
    timeseries: '1 hour'
  });
  insights.query(nrql);

query(query, done)

Execute a nrql query
Parameters:
Name Type Description
query object | string query object to build and execute or query string to execute
done function callback
Source:

send(done)

Send accumulated insights data to new relic (if enabled)
Parameters:
Name Type Description
done function callback
Source:

start()

Start the timer that will send insights after some interval of time this is called implicitly when data is added via the add method
Source:

stop()

Stop the timer that will send insights after some interval of time this is called implicitly when the amount of data exceeds maxPending and the queue is sent
Source:

where()

nrql where clause builder
Source: