2017 © Pedro Peláez
 

library watchtower

Watchtower is a Laravel wrapper for sending custom metrics to Amazon AWS CloudWatch in a really pleasant & powerful way.

image

santiripper/watchtower

Watchtower is a Laravel wrapper for sending custom metrics to Amazon AWS CloudWatch in a really pleasant & powerful way.

  • Friday, June 9, 2017
  • by santiripper
  • Repository
  • 0 Watchers
  • 1 Stars
  • 2,934 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 10 % Grown

The README.md

Watchtower

Packagist Packagist, (*1)

Watchtower is a Laravel wrapper for sending custom metrics to Amazon AWS CloudWatch in a really pleasant & powerful way., (*2)

Be sure to read the CloudWatch docs first., (*3)

Requirements

Installation

Via Composer by running, (*4)

composer require santiripper/watchtower

Or editing composer.json, (*5)

{
    "require": {
        "santiripper/watchtower" : "dev-master"
    }
}

To use the Watchtower Service Provider, you must register the provider when bootstrapping your Laravel application., (*6)

Find the providers key in your config/app.php and register the Watchtower Service Provider., (*7)

'providers' => array(
    // ...
    Santiripper\Watchtower\WatchtowerServiceProvider::class,
)

Optional, find the aliases key in your config/app.php and register the Watchtower Service Provider., (*8)

'aliases' => array(
    // ...
    'Watchtower' => Santiripper\Watchtower\Facade::class`
)

Configuration

Publish the config file by running, (*9)

php artisan vendor:publish --tag=watchtower

It will create the file app/config/watchtower.php, (*10)

Be sure to configure the Laravel AWS PHP SDK properly (regions & credentials), (*11)

Usage

You can usage it via helper function, (*12)

cloudwatch()->on(...);

Or by facade, (*13)

Cloudwatch::on(...);

Namespaces

Watchtower supports multiple Cloudwatch namespaces. To select the namespace of the metric you have to specify it using the method on, for ex if our namespace is called AwesomeApp:, (*14)

$awesomeApp = cloudwatch()->on('AwesomeApp');

Facade way:, (*15)

$awesomeApp = Cloudwatch::on('AwesomeApp');

Also you can use the helper shortcut by passing the metric namespace as parameter to the main function:, (*16)

$awesomeApp = cloudwatch('AwesomeApp');

Adding metrics

$dimensions = [
    cloudwatch()->dimension('NameDimension1', 'ValueDimension2'),
    cloudwatch()->dimension('NameDimension1', 'ValueDimension2'),
];
$awesomeApp->newMetric('MetricName', 14, 'Count', $dimensions);

Setting default dimensions

You can configure default metric dimensions on namespaces that will be included on all related metrics., (*17)

Programatically:, (*18)

$dimension = watchtower()->dimension('name', 'value');
$awesomeApp->addDefaultDimension($dimension);

Or by config on the conig/watchtower.php file:, (*19)

'default_dimensions' => [
    'on' => [
        //Namespace
        'AwesomeApp' => [
            ['name' => 'test_name_1', 'value' => 'test_value_2'],
            ['name' => 'test_name_2', 'value' => 'test_value_2'],
        ],
    ],
],

Sending

By defaults, watchtower queues metrics on memory and sends it automatically when the scripts shutdown. You can configure this behavior on the watchtower config., (*20)

If you need to send the metrics at the moment you can do it by executing the sent method:, (*21)

cloudwatch()->send();

ToDo

  • [ ] Add StatisticValues support
  • [ ] Add support to output to aws console
  • [ ] Write tests

The Versions

09/06 2017

dev-master

9999999-dev https://github.com/santiripper/watchtower

Watchtower is a Laravel wrapper for sending custom metrics to Amazon AWS CloudWatch in a really pleasant & powerful way.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Santi Corrales

laravel aws cloudwatch watchtower