Developed with love by KnpLabs Hire us for your project!
186

StatsDClientBundle

by liuggio

Easily monitor your symfony2 production env., with ready-to-use stats.

StatsD Client Bundle

Total Downloads Latest Stable Version Build Status

This bundle helps you to monitor your application.

It uses statsd-php-client as Client for the etsy/Statsd API.

It Includes

  • a Service, a Factory and an Entity callable by the DIC
  • a Monolog Handler
  • a series of Collectors in order to aggregate your personal data.
  • a series of Commands in order to execute data also from cli.

Simple usage!

$this->get('statsd')
     ->increment('log.error')
     ->gauge('log.rate', 25)
     ->flush();

Check out the documentation

Articles

Abstract

Monitoring what is happening in your production Symfony2 application, with StatsD and Graphite.

Within this bundle you could use ready-to-go monitor for

  • Monolog

  • Amount of visitor

  • Logged vs Anonymous user

  • SQL: Verbs used (amount of select/set/update/upgrade/delete) (this feature is not suggested, please use a server monitor tool eg. nagios, munin)

  • Amount of PHP ram used

  • You could create your own using the Factory and the Service.

On dev env the data are not pushed to the socket but to syslog.

If debug mode is enabled no packet are sent over the udp socket, and you could see what's going on reading the syslog with tail -f /var/log/syslog

Mar 19 00:48:11 liuggio nginx: statsd-open
Mar 19 00:48:11 liuggio nginx: statsd-write "tvision.visitor:1|tvision.memory:43520|tvision.user.anonymous:1|tvision.query.start:1|tvision.query.insert:1|c" 118 Bytes
Mar 19 00:48:11 liuggio nginx: statsd-close

Note: by default in dev environment debug is true.

One UDP packet to rule them all

With a proper config file, your StatsD server will receive in a single upd packet:

prefix.visitor:1|c                  # Increment visitor
prefix.user.anonymous:1|c           # The visitor is not logged

prefix.log.app.error.user_action:1  # Stats by monolog with $this->get('logger')->error('user_action')

prefix.memory:4480|g                # The php memory peak was 4480 MB

prefix.exception.exception.500:1|c  # Exception occurred, the Exception code was 500

prefix.query.insert:1|c             # Query Insert
prefix.query.select:1|c             # Query Select

Short Theory and links

Vagrant StatSD and Graphite

see this blog post to install Easy install statsd graphite with vagrant.

StatsD

StatsD is a simple daemon for easy stats aggregation

Graphite

Graphite is a Scalable Realtime Graphing

The Client send data with UDP (faster)

https://www.google.com/search?q=tcp+vs+udp

Contribution

See CONTRIBUTING.md

Contributors

https://github.com/liuggio/StatsDClientBundle/graphs/contributors

Copyright (c) Giulio De Donato

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
liuggio_stats_d_client:
enable_collector: false
connection:
class: Liuggio\StatsdClient\Sender\SocketSender
debug_class: Liuggio\StatsdClient\Sender\SysLogSender
debug: ~
port: 8125
host: localhost
reduce_packet: true
protocol: udp
fail_silently: true
collectors:

# Prototype
name: []
monolog:
enable: false
prefix: log
level: warning
formatter:
class: Liuggio\StatsdClient\Monolog\Formatter\StatsDFormatter
format: ~
context_logging: false
extra_logging: false
words: 2
  • Merge pull request #78 from ClementGautier/issue-68
    By web-flow, 6 months ago
  • Remove classname parameters
    By ClementGautier, 9 months ago
  • Merge pull request #76 from jorge07/patch-1
    By web-flow, 1 year ago
  • Merge pull request #77 from jorge07/patch-2
    By web-flow, 1 year ago
  • Doc, fix list and syntax highlight
    By web-flow, 1 year ago
  • Syntax highlight in advanced doc
    By web-flow, 1 year ago
  • Fix symfony 4.2 deprecation notice #74 (#75)
    By garak, 1 year ago
  • Merge pull request #73 from ClementGautier/patch-1
    By web-flow, 1 year ago
  • Add php 7.3 test matrix
    By web-flow, 1 year ago
  • Replace "Contributing" section with a link
    By garak, 1 year ago
  • Add CONTRIBUTING.md (#71)
    By garak, 1 year ago
  • coding standard
    By garak, 1 year ago
  • allow Symfony 4
    By garak, 1 year ago
  • WIP improve CI (#64)
    By garak, 1 year ago
  • fix tests
    By garak, 1 year ago
  • Merge branch 'bryglen-version-3'
    By garak, 1 year ago
  • Merge branch 'version-3' of https://github.com/bryglen/StatsDClientBundle into bryglen-version-3
    By garak, 1 year ago
  • restrict to Symfony 2
    By garak, 1 year ago
  • Merge pull request #63 from zergu/patch-1
    By web-flow, 3 years ago
  • Quoted %-parameters to avoid deprecation notices
    By web-flow, 3 years ago
  • double exception happening
    By , 4 years ago
  • add minimum version to 3 because the security context doesnt exist on symfony 3 anymore
    By bryglen, 4 years ago
  • fix for symfony 3
    By bryglen, 4 years ago
  • Merge pull request #60 from serbancatalin/master
    By liuggio, 4 years ago
  • fix yaml non-quoted @ deprecated since Symfony 2.8
    By Catalin Serban, 4 years ago
  • Merge pull request #52 from sloba88/patch-2
    By liuggio, 4 years ago
  • Updated version of liuggio/statsd-php-client
    By sloba88, 4 years ago
  • enforce single version for client
    By dav-m85, 5 years ago
  • Merge pull request #48 from ccMatrix/master
    By liuggio, 5 years ago
  • fix case mismatch
    By ccMatrix, 5 years ago