-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdemographic.juttle
More file actions
63 lines (57 loc) · 2.81 KB
/
Copy pathdemographic.juttle
File metadata and controls
63 lines (57 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This program displays AWS aggregate metrics (e.g. Number of EC2
// instances, # EBS volumes, etc.) and demographic metrics (breakdown
// by EC2 instance type, EBS volume type, etc) for a given product.
// Input controls let you choose the product, aggregate metric, and
// demographic metric, and display timecharts and piecharts with the
// values of the metric for the given product.
// Optionally, the timecharts also overlay events such as
// additions/removals/changes to the set of items (i.e. EC2 instances,
// etc).
import "examples/aws-cloudwatch/common/aws_control_product.juttle" as control_product;
import "examples/aws-cloudwatch/common/aws_control_aggregate.juttle" as control_agg;
import "examples/aws-cloudwatch/common/aws_control_demographic.juttle" as control_demo;
import "examples/aws-cloudwatch/common/aws_control_events.juttle" as control_events;
// Take categories contributing less than x percent to the total and
// group them together in an "Other" category.
sub threshold(thresh) {
(reduce total=sum(value); pass)
| join
| put pct = 100.0*value/total
| put name=(pct >= thresh ? name : 'other')
| reduce value=sum(value) by name
| sort name
}
read mysql -table 'aws_aggregation' -from :1 hour ago: -to :end: -lag :20s:
| ( filter metric_type='AWS Aggregate' and aggregate=control_agg.agg_in
| view timechart -keyField "aggregate"
-valueField "value"
-title "AWS Totals (${control_product.product_in})"
-yScales.primary.label "Total"
-markerSize 2
-id 'agg_timechart';
filter event_type =~ control_events.show_events_in
| put icon='fa-cloud'
| view events -on 'agg_timechart'
-nameField "event_type"
-messageField "item"
-typeField "icon";
filter metric_type='AWS Demographic' AND demographic=control_demo.demo_in
| batch -every :1s:
| threshold -thresh 2
| view piechart -categoryField "name"
-valueField "value"
-title "AWS Demographics (${control_demo.demo_in})";
filter metric_type='AWS Demographic' AND demographic=control_demo.demo_in
| view timechart -keyField "name"
-valueField "value"
-title "AWS Demographics (${control_demo.demo_in})"
-yScales.primary.label "Count"
-markerSize 2
-id 'demo_timechart';
filter event_type =~ control_events.show_events_in
| put icon='fa-cloud'
| view events -on 'demo_timechart'
-nameField "event_type"
-messageField "item"
-typeField "icon";
);