Fix issue about dbi plugin that sends duplicate datapoints

This change renames the queries used by cinder and nova in order to be
different. It seems that under some circumstances, if the name of the
queries is the same then the plugin uses the query twice and then
duplicates metrics.

Change-Id: I09b867d4ce90bf9838c5d32452308da5d137ff17
Closes-Bug: #1543670
This commit is contained in:
Guillaume Thouvenin 2016-02-12 09:39:41 +01:00
parent 38e02489bc
commit b591df06d5
1 changed files with 12 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<Plugin dbi>
<% if @type == 'services' %>
<Query "services">
<Query "<%= @dbname %>_<%= @type %>">
Statement "select concat_ws('.', 'services', replace(replace(s.binary, 'nova-', ''), 'cinder-', ''), 'down', s.host) as metric, 1 as value from (select * from services where deleted=0) s where s.disabled=0 and timestampdiff(SECOND,s.updated_at,utc_timestamp())><%= @downtime %> group by s.binary, s.host UNION select concat_ws('.', 'services', replace(replace(s.binary, 'nova-', ''), 'cinder-', ''), 'up', s.host) as metric, 0 as value from (select * from services where deleted=0) s where s.disabled=0 and timestampdiff(SECOND,s.updated_at,utc_timestamp())<=<%= @downtime %> group by s.binary, s.host UNION select concat_ws('.', 'services', replace(replace(s.binary, 'nova-', ''), 'cinder-', ''), 'disabled', s.host) as metric, 2 as value from (select * from services where deleted=0) s where s.disabled=1 group by s.binary, s.host;"
MinVersion 50000
<Result>
@ -9,7 +9,7 @@
ValuesFrom "value"
</Result>
</Query>
<Query "services_down">
<Query "<%= @dbname %>_<%= @type %>_down">
Statement "select concat_ws('.', 'services', replace(replace(s1.binary, 'nova-', ''), 'cinder-', ''), 'down') as metric, count(s2.id) as value from (select * from services where deleted=0) s1 left outer join services s2 on s1.id = s2.id and s1.disabled=0 and timestampdiff(SECOND,s1.updated_at,utc_timestamp())><%= @downtime %> group by s1.binary;"
MinVersion 50000
<Result>
@ -18,7 +18,7 @@
ValuesFrom "value"
</Result>
</Query>
<Query "services_up">
<Query "<%= @dbname %>_<%= @type %>_up">
Statement "select concat_ws('.', 'services', replace(replace(s1.binary, 'nova-', ''), 'cinder-', ''), 'up') as metric, count(s2.id) as value from (select * from services where deleted=0) s1 left outer join services s2 on s1.id = s2.id and s1.disabled=0 and timestampdiff(SECOND,s1.updated_at,utc_timestamp())<=<%= @downtime %> group by s1.binary;"
MinVersion 50000
<Result>
@ -27,7 +27,7 @@
ValuesFrom "value"
</Result>
</Query>
<Query "services_disabled">
<Query "<%= @dbname %>_<%= @type %>_disabled">
Statement "select concat_ws('.', 'services', replace(replace(s1.binary, 'nova-', ''), 'cinder-', ''), 'disabled') as metric, count(s2.id) as value from (select * from services where deleted=0) s1 left outer join services s2 on s1.id = s2.id and s2.disabled = 1 group by s1.binary;"
MinVersion 50000
<Result>
@ -38,7 +38,7 @@
</Query>
<% end %>
<% if @type == 'agents' %>
<Query "agents">
<Query "<%= @dbname %>_<%= @type %>">
Statement "select concat_ws('.', 'agents', replace(replace(a.binary, '-agent', ''), 'neutron-', ''), 'down', a.host) as metric, 1 as value from agents a where a.admin_state_up=1 and timestampdiff(SECOND,a.heartbeat_timestamp,utc_timestamp())><%= @downtime %> group by a.binary, a.host UNION select concat_ws('.', 'agents', replace(replace(a.binary, '-agent', ''), 'neutron-', ''), 'up', a.host) as metric, 0 as value from agents a where a.admin_state_up=1 and timestampdiff(SECOND,a.heartbeat_timestamp,utc_timestamp())<=<%= @downtime %> group by a.binary, a.host UNION select concat_ws('.', 'agents', replace(replace(a.binary, '-agent', ''), 'neutron-', ''), 'disabled', a.host) as metric, 2 as value from agents a where a.admin_state_up=0 group by a.binary, a.host;"
MinVersion 50000
<Result>
@ -47,7 +47,7 @@
ValuesFrom "value"
</Result>
</Query>
<Query "agents_down">
<Query "<%= @dbname %>_<%= @type %>_down">
Statement "select concat_ws('.', 'agents', replace(replace(a1.binary, '-agent', ''), 'neutron-', ''), 'down') as metric, count(a2.id) as value from agents a1 left outer join agents a2 on a1.id = a2.id and a1.admin_state_up=1 and timestampdiff(SECOND,a1.heartbeat_timestamp,utc_timestamp())><%= @downtime %> group by a1.binary;"
MinVersion 50000
<Result>
@ -56,7 +56,7 @@
ValuesFrom "value"
</Result>
</Query>
<Query "agents_up">
<Query "<%= @dbname %>_<%= @type %>_up">
Statement "select concat_ws('.', 'agents', replace(replace(a1.binary, '-agent', ''), 'neutron-', ''), 'up') as metric, count(a2.id) as value from agents a1 left outer join agents a2 on a1.id = a2.id and a1.admin_state_up=1 and timestampdiff(SECOND,a1.heartbeat_timestamp,utc_timestamp())<=<%= @downtime %> group by a1.binary;"
MinVersion 50000
<Result>
@ -65,7 +65,7 @@
ValuesFrom "value"
</Result>
</Query>
<Query "agents_disabled">
<Query "<%= @dbname %>_<%= @type %>_disabled">
Statement "select concat_ws('.', 'agents', replace(replace(a1.binary, '-agent', ''), 'neutron-', ''), 'disabled') as metric, count(a2.id) as value from agents a1 left outer join agents a2 on a1.id = a2.id and a1.admin_state_up=0 group by a1.binary;"
MinVersion 50000
<Result>
@ -82,9 +82,9 @@
DriverOption "password" "<%= @password %>"
DriverOption "dbname" "<%= @dbname %>"
SelectDB "<%= @dbname %>"
Query "<%= @type %>_disabled"
Query "<%= @type %>_up"
Query "<%= @type %>_down"
Query "<%= @type %>"
Query "<%= @dbname %>_<%= @type %>_disabled"
Query "<%= @dbname %>_<%= @type %>_up"
Query "<%= @dbname %>_<%= @type %>_down"
Query "<%= @dbname %>_<%= @type %>"
</Database>
</Plugin>