More and more attention has been paid to the concept of devops in recent years, and more and more software is available in addition to the traditional Splunk,zabbix external open source field. From , time series database, graphic display and other major aspects have a variety of extensible software to build a data monitoring platform ( Detailed list ), Logstash+elasticsearch+kibana is written more, this article will focus on business data and performance monitoring rather than traditional machine parameters monitoring, so this article to statsd+ Graphite+grafana the installation configuration on the CENTOS6 as an example.
Description of three components (https://blog.pkhamre.com/understanding-statsd-and-graphite/):
statsd: A NODEJS client that sends data to a graphite collector, and a client using various programming languages sends statistics such as Timer,counter, It sends data to the graphite via UDP timing. C # client
Graphite: Divided into listener carbon+ time series Database whisper+ graphical display Django-webapp. Because the installation is to configure the database and other suggestions for Django have a certain understanding
Grafana: A graphical display that is more powerful and flexible than the graphite comes with. When you add a new Dashbord when you configure Grafana, note that the green bar is clickable, and the configuration item settings appear after you click.
The first two installations on CentOS are referenced ( installed ), which also includes instructions for installing COLLECTD to collect system performance data, and for Graphana installation please refer to the official documentation. Need to explain that I follow the article configured to use the Django-admin startup program can be normal access, but through the Apache front-end landing in the graphite management interface can not see the metrics display finally used Docker way. Please refer to the GitHub instructions for Docker release notes.
The client mainly sends counter and timer two kinds of data for monitoring and analysis, counter is mainly used for real-time display of the key business is running normally. The timer is primarily used to show whether the application's invocation performance is normal.
The integration of counter is mainly the developer writing code sending count information (exception information count and normal count):
Metrics.configure (new metricsconfig{ statsdservername = "x.x.x.x", Prefix = "Mallordercmd"}); Metrics.counter ("Syncorderinfo.error");
Timer tracking can be considered using POSTSHARP or fody plug-ins to implement
[Serializable]public sealed class graphitetimingattribute:onmethodboundaryaspect{[nonserialized] Private STOPWATC H _stopwatch; public override void OnEntry (Methodexecutionargs args) {_stopwatch = Stopwatch.startnew (); Base. OnEntry (args); } public override void OnExit (Methodexecutionargs args) {StatsdClient.Metrics.Timer (stri Ng. Format ("{0}.{ 1}. {2}. {3} "," ApplicationName ", System.Environment.MachineName, args. Method.DeclaringType.Name, args. Method.name), (int) _stopwatch. Elapsed.totalmilliseconds); Base. OnExit (args); } public override void Onexception (Methodexecutionargs args) {StatsdClient.Metrics.Counter (Strin G.format ("{0}.{ 1}.error ", args. Method.DeclaringType.Name, args. Method.name), (int) _stopwatch. Elapsed.totalmilliseconds); Base. Onexception (args); }}
Building business and performance monitoring modules using Statsd+graphite+grafana