Created
March 11, 2014 02:14
-
-
Save iwai/9478249 to your computer and use it in GitHub Desktop.
Added fluentd metrics for CloudWatchMonitoringScripts v1.1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- mon-put-instance-data.pl.orig 2014-03-09 20:42:45.106610966 +0900 | |
+++ mon-put-instance-data.pl 2014-03-09 23:26:34.075877884 +0900 | |
@@ -31,6 +31,7 @@ | |
--disk-space-util Reports disk space utilization in percentages. | |
--disk-space-used Reports allocated disk space in gigabytes. | |
--disk-space-avail Reports available disk space in gigabytes. | |
+ --fluentd=HOST:PORT Reports output buffer_queue_length, buffer_total_queued_size, retry_count. | |
--aggregated[=only] Adds aggregated metrics for instance type, AMI id, and overall. | |
--auto-scaling[=only] Adds aggregated metrics for Auto Scaling group. | |
@@ -104,6 +105,7 @@ | |
my $report_disk_util; | |
my $report_disk_used; | |
my $report_disk_avail; | |
+my $report_fluentd; | |
my $mem_used_incl_cache_buff; | |
my @mount_path; | |
my $mem_units; | |
@@ -142,6 +144,7 @@ | |
'disk-space-util' => \$report_disk_util, | |
'disk-space-used' => \$report_disk_used, | |
'disk-space-avail' => \$report_disk_avail, | |
+ 'fluentd:s' => \$report_fluentd, | |
'auto-scaling:s' => \$auto_scaling, | |
'aggregated:s' => \$aggregated, | |
'memory-units:s' => \$mem_units, | |
@@ -446,6 +449,31 @@ | |
} | |
} | |
+# collect fluentd metrics | |
+ | |
+if ($report_fluentd) | |
+{ | |
+ use JSON; | |
+ my $fluent_plugins = `curl -s http://$report_fluentd/api/plugins.json`; | |
+ $fluent_plugins = decode_json($fluent_plugins); | |
+ | |
+ foreach my $plugin (@{ $fluent_plugins->{'plugins'} }) { | |
+ next if !exists($plugin->{'buffer_queue_length'}); | |
+ | |
+ add_metric( | |
+ 'BufferQueueLength', 'Count', $plugin->{'buffer_queue_length'}, '', '', $plugin->{'type'} | |
+ ); | |
+ add_metric( | |
+ 'RetryCount', 'Count', $plugin->{'retry_count'}, '', '', $plugin->{'type'} | |
+ ); | |
+ add_metric( | |
+ 'BufferTotalQueuedSize', 'Megabytes', $plugin->{'buffer_total_queued_size'} / MEGA, '', '', $plugin->{'type'} | |
+ ); | |
+ } | |
+ | |
+} | |
+ | |
+ | |
# send metrics over to CloudWatch if any | |
if ($mcount > 0) | |
@@ -561,12 +589,14 @@ | |
my $value = shift; | |
my $filesystem = shift; | |
my $mount = shift; | |
+ my $plugin = shift; | |
my $dcount = 0; | |
my %dims = (); | |
my %xdims = (); | |
$xdims{'MountPath'} = $mount if $mount; | |
$xdims{'Filesystem'} = $filesystem if $filesystem; | |
+ $xdims{'Plugin'} = $plugin if $plugin; | |
my $auto_scaling_only = defined($auto_scaling) && $auto_scaling == 2; | |
my $aggregated_only = defined($aggregated) && $aggregated == 2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment