update comment in the template
[heat-templates.git] / staging / monitoring.yaml
blob20c7142f967466a545e45be2e917522093780ad3
1 heat_template_version: 2013-05-23
3 description: |
4   Test template using Cloud Monitoring
6 resources:
8   server:
9     type: OS::Nova::Server
10     properties:
11       image: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
12       flavor: 2 GB Performance
13       name: { get_param: "OS::stack_name" }
14       user_data_format: RAW
15       config_drive: true
16       user_data:
17         str_replace:
18           template: |
19             #!/bin/bash
20             echo "deb http://stable.packages.cloudmonitoring.rackspace.com/ubuntu-14.04-x86_64 cloudmonitoring main" > /etc/apt/sources.list.d/rackspace-monitoring-agent.list
21             curl https://monitoring.api.rackspacecloud.com/pki/agent/linux.asc | sudo apt-key add -
22             apt-get -y update
23             apt-get -y install rackspace-monitoring-agent apache2
24             echo "monitoring_token {{token}}" > /etc/rackspace-monitoring-agent.cfg
25             service rackspace-monitoring-agent restart
26           params:
27             "{{token}}": { get_resource: token }
28       metadata:
29         rax-heat: { get_param: "OS::stack_id" }
30         stack-name: { get_param: "OS::stack_name" }
32   ######################################################################################
33   # THIS TEMPLATE USES THE SERVERMILL CREATED ENTITY FOR CHECKS AND STUFF. JUST CREATE #
34   # THIS ENTITY TO ENSURE THAT THE ENTITY RESOURCE WORKS.                              #
35   ######################################################################################
36   entity:
37     type: Rackspace::CloudMonitoring::Entity
38     properties:
39       label: { get_param: "OS::stack_name" }
40       metadata:
41         rax-heat: { get_param: "OS::stack_id" }
42         stack-name: { get_param: "OS::stack_name" }
43       ip_addresses:
44         web_server: { get_attr: [ server, accessIPv4 ] }
46   token:
47     type: Rackspace::CloudMonitoring::AgentToken
48     properties:
49       label: { get_param: "OS::stack_name" }
51   webcheck:
52     type: Rackspace::CloudMonitoring::Check
53     properties:
54       entity: { get_resource: server }
55       type: remote.http
56       details:
57         url:
58           str_replace:
59             template: http://server_ip/
60             params:
61               server_ip: { get_attr: [ server, accessIPv4 ] }
62       label: webcheck
63       metadata:
64         rax-heat: { get_param: "OS::stack_id" }
65         stack-name: { get_param: "OS::stack_name" }
66       period: 120
67       timeout: 10
68       monitoring_zones_poll:
69       - Northern Virginia (IAD)
70       - Chicago (ORD)
71       target_hostname: { get_attr: [ server, accessIPv4 ] }
72       target_receiver: IPv4
74   cpucheck:
75     type: Rackspace::CloudMonitoring::Check
76     properties:
77       entity: { get_resource: server }
78       type: agent.cpu
79       label: cpu_check
80       details: {}
81       metadata:
82         rax-heat: { get_param: "OS::stack_id" }
83         stack-name: { get_param: "OS::stack_name" }
84       period: 30
85       timeout: 10
87   email_notification:
88     type: Rackspace::CloudMonitoring::Notification
89     properties:
90       label: email_heat_team
91       type: email
92       details:
93         address: "admin@example.com"
94   
95   email_notification_2:
96     type: Rackspace::CloudMonitoring::Notification
97     properties:
98       label: email_heat_team_2
99       type: email
100       details:
101         address: "allclear@example.com"
103   notify_heat_team:
104     type: Rackspace::CloudMonitoring::NotificationPlan
105     properties:
106       label: { get_param: "OS::stack_name" }
107       warning_state:
108       - { get_resource: email_notification }
109       critical_state:
110       - { get_resource: email_notification }
112   add_ok_notification:
113     type: Rackspace::CloudMonitoring::PlanNotifications
114     properties:
115       plan: { get_resource: notify_heat_team }
116       ok_state:
117       - { get_resource: email_notification_2 }
119   alert_randall:
120     type: Rackspace::CloudMonitoring::Alarm
121     properties:
122       label: test_cpu_alarm
123       check: { get_resource: cpucheck }
124       plan: { get_resource: notify_heat_team }
125       criteria: |
126         :set consecutiveCount=5
127         if (metric['usage_average'] > 95) {
128             return new AlarmStatus(CRITICAL, 'CPU usage is #{usage_average}%');
129         }
130         if (metric['usage_average'] > 85) {
131             return new AlarmStatus(WARNING, 'CPU usage is #{usage_average}%');
132         }
133         return new AlarmStatus(OK);
134       metadata:
135         rax-heat: { get_param: "OS::stack_id" }
136         stack-name: { get_param: "OS::stack_name" }
138       
141       
142       
143