Laravel Library for Interacting with NewRelic's Insight
buonzz/l4-newrelic-insight is a Laravel package for laravel library for interacting with newrelic's insight.
It currently has 0 GitHub stars and 35 downloads on Packagist (latest version v1.0.2).
Install it with composer require buonzz/l4-newrelic-insight.
Discover more Laravel packages by buonzz
or browse all Laravel packages to compare alternatives.
Last updated
This is a Laravel Library for Interacting with NewRelic's Insight. This tries to make you define simple events in Laravel-way and make it appear in the NewRelic Insights dashboards.
Require the package in your composer.json file
composer require buonzz/l4-newrelic-insight
Add the service provider and facade in your config/app.php Service Provider
Buonzz\NewRelic\Insight\Laravel4\ServiceProviders\InsightServiceProvider
Facade
'Insight' => 'Buonzz\NewRelic\Insight\Laravel4\Facades\Insight',
Pubish the configuration file
php artisan config:publish buonzz/l4-newrelic-insight
Edit the config file in app/config/packages/buonzz/l4-newrelic-insight/config.php
Execute Queries
$nrql = "SELECT uniquecount(session) FROM PageView";
$nrql .= "WHERE appName='PHP Application' SINCE 1 hour ago COMPARE WITH 1 hour ago";
$result = Insight::query($nrql);
Send Custom Events
$events = array();
$events[] = array('eventType'=> 'Event Name', 'atrribute1'=> 'attribute value 1', 'attribute2'=> 'atrribute value 2');
Insight::insertCustomEvents($events);
You can also dynamically set the config settings in runtime:
Insight::setAccountID('<put your account id here>'); // used to associate your account to calls
Insight::setQueryKey('<put your query key here>'); // required to query data
Insight::setInsertKey('<put your insert key here>'); // this is when you need to send custom events
List PageViews within the last hour
use Buonzz\NewRelic\Insight\Aggregates\PageView;
Route::get('pageviews', function()
{
$pv = new PageView();
$pageviews = $pv->all();
return $pageviews;
});