|
|
@ -31,6 +31,28 @@ local processes_map = {
|
|
|
|
ps_vm = 'memory_virtual',
|
|
|
|
ps_vm = 'memory_virtual',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- The following table keeps a list of metrics from plugin where the
|
|
|
|
|
|
|
|
-- hostname is not relevant.
|
|
|
|
|
|
|
|
local hostname_free = {
|
|
|
|
|
|
|
|
-- Add "metric_source = true" to skip the hostname for all metrics
|
|
|
|
|
|
|
|
-- from the metric_source
|
|
|
|
|
|
|
|
-- Add "metric_source = { list of metrics } to skip hostname for a
|
|
|
|
|
|
|
|
-- subset of metrics. The list of metrics is referenced through the
|
|
|
|
|
|
|
|
-- field 'type_instance'.
|
|
|
|
|
|
|
|
hypervisor_stats = {
|
|
|
|
|
|
|
|
total_free_disk_GB = true,
|
|
|
|
|
|
|
|
total_free_ram_MB = true,
|
|
|
|
|
|
|
|
total_free_vcpus = true,
|
|
|
|
|
|
|
|
total_used_disk_GB = true,
|
|
|
|
|
|
|
|
total_used_ram_MB = true,
|
|
|
|
|
|
|
|
total_used_vcpus = true,
|
|
|
|
|
|
|
|
total_running_instances = true,
|
|
|
|
|
|
|
|
total_running_tasks = true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
check_openstack_api = true,
|
|
|
|
|
|
|
|
http_check = true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- this is needed for the libvirt metrics because in that case, collectd sends
|
|
|
|
-- this is needed for the libvirt metrics because in that case, collectd sends
|
|
|
|
-- the instance's ID instead of the hostname in the 'host' attribute
|
|
|
|
-- the instance's ID instead of the hostname in the 'host' attribute
|
|
|
|
local hostname = read_config('hostname') or error('hostname must be specified')
|
|
|
|
local hostname = read_config('hostname') or error('hostname must be specified')
|
|
|
@ -70,11 +92,11 @@ function process_message ()
|
|
|
|
Severity = 6,
|
|
|
|
Severity = 6,
|
|
|
|
Type = "metric",
|
|
|
|
Type = "metric",
|
|
|
|
Fields = {
|
|
|
|
Fields = {
|
|
|
|
hostname = sample['host'],
|
|
|
|
|
|
|
|
interval = sample['interval'],
|
|
|
|
interval = sample['interval'],
|
|
|
|
source = metric_source,
|
|
|
|
source = metric_source,
|
|
|
|
type = sample['dstypes'][i],
|
|
|
|
type = sample['dstypes'][i],
|
|
|
|
value = value,
|
|
|
|
value = value,
|
|
|
|
|
|
|
|
tag_fields = {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -82,6 +104,20 @@ function process_message ()
|
|
|
|
-- always consistent on metric namespaces so we need a few if/else
|
|
|
|
-- always consistent on metric namespaces so we need a few if/else
|
|
|
|
-- statements to cover all cases.
|
|
|
|
-- statements to cover all cases.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Check if hostname is needed or not
|
|
|
|
|
|
|
|
local add_hostname = true
|
|
|
|
|
|
|
|
if hostname_free[metric_source] == true then
|
|
|
|
|
|
|
|
add_hostname = false
|
|
|
|
|
|
|
|
elseif hostname_free[metric_source] and
|
|
|
|
|
|
|
|
hostname_free[metric_source][sample['type_instance']] then
|
|
|
|
|
|
|
|
add_hostname = false
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if add_hostname then
|
|
|
|
|
|
|
|
msg['Fields']['hostname'] = sample['host']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'hostname')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if sample['meta'] and sample['meta']['service_check'] then
|
|
|
|
if sample['meta'] and sample['meta']['service_check'] then
|
|
|
|
msg['Fields']['name'] = sample['meta']['service_check'] .. sep .. 'check'
|
|
|
|
msg['Fields']['name'] = sample['meta']['service_check'] .. sep .. 'check'
|
|
|
|
msg['Fields']['details'] = sample['meta']['failure']
|
|
|
|
msg['Fields']['details'] = sample['meta']['failure']
|
|
|
@ -106,18 +142,17 @@ function process_message ()
|
|
|
|
|
|
|
|
|
|
|
|
msg['Fields']['name'] = 'fs' .. sep .. entity .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'fs' .. sep .. entity .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['fs'] = mount
|
|
|
|
msg['Fields']['fs'] = mount
|
|
|
|
msg['Fields']['tag_fields'] = { 'fs' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'fs')
|
|
|
|
elseif metric_source == 'disk' then
|
|
|
|
elseif metric_source == 'disk' then
|
|
|
|
msg['Fields']['name'] = metric_name
|
|
|
|
msg['Fields']['name'] = metric_name
|
|
|
|
msg['Fields']['device'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['device'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'device' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'device')
|
|
|
|
elseif metric_source == 'cpu' then
|
|
|
|
elseif metric_source == 'cpu' then
|
|
|
|
msg['Fields']['name'] = 'cpu' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'cpu' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['cpu_number'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['cpu_number'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'cpu_number' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'cpu_number')
|
|
|
|
elseif metric_source == 'netlink' then
|
|
|
|
elseif metric_source == 'netlink' then
|
|
|
|
local netlink_metric = sample['type']
|
|
|
|
local netlink_metric = sample['type']
|
|
|
|
|
|
|
|
|
|
|
|
if netlink_metric == 'if_rx_errors' then
|
|
|
|
if netlink_metric == 'if_rx_errors' then
|
|
|
|
netlink_metric = 'if_errors_rx'
|
|
|
|
netlink_metric = 'if_errors_rx'
|
|
|
|
elseif netlink_metric == 'if_tx_errors' then
|
|
|
|
elseif netlink_metric == 'if_tx_errors' then
|
|
|
@ -134,12 +169,12 @@ function process_message ()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
msg['Fields']['name'] = netlink_metric
|
|
|
|
msg['Fields']['name'] = netlink_metric
|
|
|
|
msg['Fields']['interface'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['interface'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'interface' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'interface')
|
|
|
|
elseif metric_source == 'processes' then
|
|
|
|
elseif metric_source == 'processes' then
|
|
|
|
if processes_map[sample['type']] then
|
|
|
|
if processes_map[sample['type']] then
|
|
|
|
-- metrics related to a specific process
|
|
|
|
-- metrics related to a specific process
|
|
|
|
msg['Fields']['service'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['service'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'service' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'service')
|
|
|
|
msg['Fields']['name'] = 'lma_components'
|
|
|
|
msg['Fields']['name'] = 'lma_components'
|
|
|
|
if processes_map[sample['type']] ~= '' then
|
|
|
|
if processes_map[sample['type']] ~= '' then
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. processes_map[sample['type']]
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. processes_map[sample['type']]
|
|
|
@ -160,7 +195,7 @@ function process_message ()
|
|
|
|
if sample['type'] == 'ps_state' then
|
|
|
|
if sample['type'] == 'ps_state' then
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. 'count'
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. 'count'
|
|
|
|
msg['Fields']['state'] = sample['type_instance']
|
|
|
|
msg['Fields']['state'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'state' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
else
|
|
|
|
else
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['type']
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['type']
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -173,11 +208,11 @@ function process_message ()
|
|
|
|
elseif sample['type'] == 'mysql_commands' then
|
|
|
|
elseif sample['type'] == 'mysql_commands' then
|
|
|
|
msg['Fields']['name'] = sample['type']
|
|
|
|
msg['Fields']['name'] = sample['type']
|
|
|
|
msg['Fields']['statement'] = sample['type_instance']
|
|
|
|
msg['Fields']['statement'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'statement' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'statement')
|
|
|
|
elseif sample['type'] == 'mysql_handler' then
|
|
|
|
elseif sample['type'] == 'mysql_handler' then
|
|
|
|
msg['Fields']['name'] = sample['type']
|
|
|
|
msg['Fields']['name'] = sample['type']
|
|
|
|
msg['Fields']['handler'] = sample['type_instance']
|
|
|
|
msg['Fields']['handler'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'handler' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'handler')
|
|
|
|
else
|
|
|
|
else
|
|
|
|
msg['Fields']['name'] = metric_name
|
|
|
|
msg['Fields']['name'] = metric_name
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -185,7 +220,7 @@ function process_message ()
|
|
|
|
-- For OpenStack API metrics, plugin_instance = <service name>
|
|
|
|
-- For OpenStack API metrics, plugin_instance = <service name>
|
|
|
|
msg['Fields']['name'] = 'openstack_check_api'
|
|
|
|
msg['Fields']['name'] = 'openstack_check_api'
|
|
|
|
msg['Fields']['service'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['service'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'service' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'service')
|
|
|
|
if sample['meta'] then
|
|
|
|
if sample['meta'] then
|
|
|
|
msg['Fields']['os_region'] = sample['meta']['region']
|
|
|
|
msg['Fields']['os_region'] = sample['meta']['region']
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -205,49 +240,52 @@ function process_message ()
|
|
|
|
msg['Fields']['name'] = 'rabbitmq' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'rabbitmq' .. sep .. sample['type_instance']
|
|
|
|
if sample['meta'] and sample['meta']['queue'] then
|
|
|
|
if sample['meta'] and sample['meta']['queue'] then
|
|
|
|
msg['Fields']['queue'] = sample['meta']['queue']
|
|
|
|
msg['Fields']['queue'] = sample['meta']['queue']
|
|
|
|
msg['Fields']['tag_fields'] = { 'queue' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'queue')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'nova' then
|
|
|
|
elseif metric_source == 'nova' then
|
|
|
|
if sample['plugin_instance'] == 'nova_services' or
|
|
|
|
if sample['plugin_instance'] == 'nova_services' or
|
|
|
|
sample['plugin_instance'] == 'nova_service' then
|
|
|
|
sample['plugin_instance'] == 'nova_service' then
|
|
|
|
msg['Fields']['name'] = 'openstack_' .. sample['plugin_instance']
|
|
|
|
msg['Fields']['name'] = 'openstack_' .. sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'service', 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['service'] = sample['meta']['service']
|
|
|
|
msg['Fields']['service'] = sample['meta']['service']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'service')
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
if sample['plugin_instance'] == 'nova_service' then
|
|
|
|
if sample['plugin_instance'] == 'nova_service' then
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'nova' .. sep .. replace_dot_by_sep(sample['plugin_instance'])
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'nova' .. sep .. replace_dot_by_sep(sample['plugin_instance'])
|
|
|
|
msg['Fields']['tag_fields'] = { 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['state'] = sample['type_instance']
|
|
|
|
msg['Fields']['state'] = sample['type_instance']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'cinder' then
|
|
|
|
elseif metric_source == 'cinder' then
|
|
|
|
if sample['plugin_instance'] == 'cinder_services' or
|
|
|
|
if sample['plugin_instance'] == 'cinder_services' or
|
|
|
|
sample['plugin_instance'] == 'cinder_service' then
|
|
|
|
sample['plugin_instance'] == 'cinder_service' then
|
|
|
|
msg['Fields']['name'] = 'openstack_' .. sample['plugin_instance']
|
|
|
|
msg['Fields']['name'] = 'openstack_' .. sample['plugin_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'service', 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['service'] = sample['meta']['service']
|
|
|
|
msg['Fields']['service'] = sample['meta']['service']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'service')
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
if sample['plugin_instance'] == 'cinder_service' then
|
|
|
|
if sample['plugin_instance'] == 'cinder_service' then
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'cinder' .. sep .. replace_dot_by_sep(sample['plugin_instance'])
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'cinder' .. sep .. replace_dot_by_sep(sample['plugin_instance'])
|
|
|
|
msg['Fields']['tag_fields'] = { 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['state'] = sample['type_instance']
|
|
|
|
msg['Fields']['state'] = sample['type_instance']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'glance' then
|
|
|
|
elseif metric_source == 'glance' then
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'glance' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'glance' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'state', 'visibility' }
|
|
|
|
|
|
|
|
msg['Fields']['state'] = sample['meta']['status']
|
|
|
|
msg['Fields']['state'] = sample['meta']['status']
|
|
|
|
msg['Fields']['visibility'] = sample['meta']['visibility']
|
|
|
|
msg['Fields']['visibility'] = sample['meta']['visibility']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'visibility')
|
|
|
|
elseif metric_source == 'keystone' then
|
|
|
|
elseif metric_source == 'keystone' then
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'keystone' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'keystone' .. sep .. sample['type_instance']
|
|
|
|
if sample['meta']['state'] then
|
|
|
|
if sample['meta']['state'] then
|
|
|
|
msg['Fields']['tag_fields'] = { 'state' }
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'neutron' then
|
|
|
|
elseif metric_source == 'neutron' then
|
|
|
|
if sample['type_instance'] == 'networks' or sample['type_instance'] == 'ports' or sample['type_instance'] == 'routers' or sample['type_instance'] == 'floatingips' then
|
|
|
|
if sample['type_instance'] == 'networks' or sample['type_instance'] == 'ports' or sample['type_instance'] == 'routers' or sample['type_instance'] == 'floatingips' then
|
|
|
|
skip_it = true
|
|
|
|
skip_it = true
|
|
|
@ -256,23 +294,25 @@ function process_message ()
|
|
|
|
elseif sample['type_instance'] == 'neutron_agents' or
|
|
|
|
elseif sample['type_instance'] == 'neutron_agents' or
|
|
|
|
sample['type_instance'] == 'neutron_agent' then
|
|
|
|
sample['type_instance'] == 'neutron_agent' then
|
|
|
|
msg['Fields']['name'] = 'openstack_' .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'openstack_' .. sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'service', 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['service'] = sample['meta']['service']
|
|
|
|
msg['Fields']['service'] = sample['meta']['service']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'service')
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
if sample['type_instance'] == 'neutron_agent' then
|
|
|
|
if sample['type_instance'] == 'neutron_agent' then
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif string.match(sample['type_instance'], '^ports') then
|
|
|
|
elseif string.match(sample['type_instance'], '^ports') then
|
|
|
|
local resource, owner, state = string.match(sample['type_instance'], '^([^.]+)%.([^.]+)%.(.+)$')
|
|
|
|
local resource, owner, state = string.match(sample['type_instance'], '^([^.]+)%.([^.]+)%.(.+)$')
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'neutron' .. sep .. replace_dot_by_sep(resource)
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'neutron' .. sep .. replace_dot_by_sep(resource)
|
|
|
|
msg['Fields']['tag_fields'] = { 'owner', 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['owner'] = owner
|
|
|
|
msg['Fields']['owner'] = owner
|
|
|
|
msg['Fields']['state'] = state
|
|
|
|
msg['Fields']['state'] = state
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'owner')
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
else
|
|
|
|
else
|
|
|
|
local resource, state = string.match(sample['type_instance'], '^([^.]+)%.(.+)$')
|
|
|
|
local resource, state = string.match(sample['type_instance'], '^([^.]+)%.(.+)$')
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'neutron' .. sep .. replace_dot_by_sep(resource)
|
|
|
|
msg['Fields']['name'] = 'openstack' .. sep .. 'neutron' .. sep .. replace_dot_by_sep(resource)
|
|
|
|
msg['Fields']['tag_fields'] = { 'state' }
|
|
|
|
|
|
|
|
msg['Fields']['state'] = state
|
|
|
|
msg['Fields']['state'] = state
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'memcached' then
|
|
|
|
elseif metric_source == 'memcached' then
|
|
|
|
msg['Fields']['name'] = 'memcached' .. sep .. string.gsub(metric_name, 'memcached_', '')
|
|
|
|
msg['Fields']['name'] = 'memcached' .. sep .. string.gsub(metric_name, 'memcached_', '')
|
|
|
@ -280,8 +320,8 @@ function process_message ()
|
|
|
|
msg['Fields']['name'] = 'haproxy' .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = 'haproxy' .. sep .. sample['type_instance']
|
|
|
|
if sample['meta'] then
|
|
|
|
if sample['meta'] then
|
|
|
|
if sample['meta']['backend'] then
|
|
|
|
if sample['meta']['backend'] then
|
|
|
|
msg['Fields']['tag_fields'] = { 'backend' }
|
|
|
|
|
|
|
|
msg['Fields']['backend'] = sample['meta']['backend']
|
|
|
|
msg['Fields']['backend'] = sample['meta']['backend']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'backend')
|
|
|
|
if sample['meta']['state'] then
|
|
|
|
if sample['meta']['state'] then
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
msg['Fields']['state'] = sample['meta']['state']
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'state')
|
|
|
@ -291,8 +331,8 @@ function process_message ()
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'server')
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'server')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif sample['meta']['frontend'] then
|
|
|
|
elseif sample['meta']['frontend'] then
|
|
|
|
msg['Fields']['tag_fields'] = { 'frontend' }
|
|
|
|
|
|
|
|
msg['Fields']['frontend'] = sample['meta']['frontend']
|
|
|
|
msg['Fields']['frontend'] = sample['meta']['frontend']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'frontend')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'apache' then
|
|
|
|
elseif metric_source == 'apache' then
|
|
|
@ -301,17 +341,18 @@ function process_message ()
|
|
|
|
elseif metric_source == 'ceph_osd_perf' then
|
|
|
|
elseif metric_source == 'ceph_osd_perf' then
|
|
|
|
msg['Fields']['name'] = 'ceph_perf' .. sep .. sample['type']
|
|
|
|
msg['Fields']['name'] = 'ceph_perf' .. sep .. sample['type']
|
|
|
|
|
|
|
|
|
|
|
|
msg['Fields']['tag_fields'] = { 'cluster', 'osd' }
|
|
|
|
|
|
|
|
msg['Fields']['cluster'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['cluster'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['osd'] = sample['type_instance']
|
|
|
|
msg['Fields']['osd'] = sample['type_instance']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'cluster')
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'osd')
|
|
|
|
elseif metric_source:match('^ceph') then
|
|
|
|
elseif metric_source:match('^ceph') then
|
|
|
|
msg['Fields']['name'] = 'ceph' .. sep .. sample['type']
|
|
|
|
msg['Fields']['name'] = 'ceph' .. sep .. sample['type']
|
|
|
|
if sample['dsnames'][i] ~= 'value' then
|
|
|
|
if sample['dsnames'][i] ~= 'value' then
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['dsnames'][i]
|
|
|
|
msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['dsnames'][i]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
msg['Fields']['tag_fields'] = { 'cluster' }
|
|
|
|
|
|
|
|
msg['Fields']['cluster'] = sample['plugin_instance']
|
|
|
|
msg['Fields']['cluster'] = sample['plugin_instance']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'cluster')
|
|
|
|
|
|
|
|
|
|
|
|
if sample['type_instance'] ~= '' then
|
|
|
|
if sample['type_instance'] ~= '' then
|
|
|
|
local additional_tag
|
|
|
|
local additional_tag
|
|
|
@ -323,51 +364,48 @@ function process_message ()
|
|
|
|
additional_tag = 'osd'
|
|
|
|
additional_tag = 'osd'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if additional_tag then
|
|
|
|
if additional_tag then
|
|
|
|
msg['Fields']['tag_fields'][2] = additional_tag
|
|
|
|
|
|
|
|
msg['Fields'][additional_tag] = sample['type_instance']
|
|
|
|
msg['Fields'][additional_tag] = sample['type_instance']
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], additional_tag)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elseif metric_source == 'pacemaker' then
|
|
|
|
elseif metric_source == 'pacemaker' then
|
|
|
|
|
|
|
|
if sample['meta'] and sample['meta']['host'] then
|
|
|
|
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
msg['Fields']['name'] = metric_source .. sep .. sample['type_instance']
|
|
|
|
msg['Fields']['name'] = metric_source .. sep .. sample['type_instance']
|
|
|
|
|
|
|
|
|
|
|
|
-- add dimension fields
|
|
|
|
-- add dimension fields
|
|
|
|
local t = {}
|
|
|
|
|
|
|
|
for _, v in ipairs({'status', 'resource'}) do
|
|
|
|
for _, v in ipairs({'status', 'resource'}) do
|
|
|
|
if sample['meta'] and sample['meta'][v] then
|
|
|
|
if sample['meta'] and sample['meta'][v] then
|
|
|
|
t[#t+1] = v
|
|
|
|
|
|
|
|
msg['Fields'][v] = sample['meta'][v]
|
|
|
|
msg['Fields'][v] = sample['meta'][v]
|
|
|
|
|
|
|
|
table.insert(msg['Fields']['tag_fields'], v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #t > 0 then
|
|
|
|
|
|
|
|
msg['Fields']['tag_fields'] = t
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sample['meta'] and sample['meta']['host'] then
|
|
|
|
|
|
|
|
msg['Fields']['hostname'] = sample['meta']['host']
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif metric_source == 'users' then
|
|
|
|
elseif metric_source == 'users' then
|
|
|
|
-- 'users' is a reserved name for InfluxDB v0.9
|
|
|
|
-- 'users' is a reserved name for InfluxDB v0.9
|
|
|
|
msg['Fields']['name'] = 'logged_users'
|
|
|
|
msg['Fields']['name'] = 'logged_users'
|
|
|
|
elseif metric_source == 'libvirt' then
|
|
|
|
elseif metric_source == 'libvirt' then
|
|
|
|
-- collectd sends the instance's ID in the 'host' field
|
|
|
|
-- collectd sends the instance's ID in the 'host' field
|
|
|
|
msg['Fields']['instance_id'] = sample['host']
|
|
|
|
msg['Fields']['instance_id'] = sample['host']
|
|
|
|
msg['Fields']['tag_fields'] = { 'instance_id' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'instance_id')
|
|
|
|
msg['Fields']['hostname'] = hostname
|
|
|
|
msg['Fields']['hostname'] = hostname
|
|
|
|
msg['Hostname'] = hostname
|
|
|
|
msg['Hostname'] = hostname
|
|
|
|
|
|
|
|
|
|
|
|
if string.match(sample['type'], '^disk_') then
|
|
|
|
if string.match(sample['type'], '^disk_') then
|
|
|
|
msg['Fields']['name'] = 'virt' .. sep .. sample['type'] .. sep .. sample['dsnames'][i]
|
|
|
|
msg['Fields']['name'] = 'virt' .. sep .. sample['type'] .. sep .. sample['dsnames'][i]
|
|
|
|
msg['Fields']['device'] = sample['type_instance']
|
|
|
|
msg['Fields']['device'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'][2] = 'device'
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'device')
|
|
|
|
elseif string.match(sample['type'], '^if_') then
|
|
|
|
elseif string.match(sample['type'], '^if_') then
|
|
|
|
msg['Fields']['name'] = 'virt' .. sep .. sample['type'] .. sep .. sample['dsnames'][i]
|
|
|
|
msg['Fields']['name'] = 'virt' .. sep .. sample['type'] .. sep .. sample['dsnames'][i]
|
|
|
|
msg['Fields']['interface'] = sample['type_instance']
|
|
|
|
msg['Fields']['interface'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'][2] = 'interface'
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'interface')
|
|
|
|
elseif sample['type'] == 'virt_cpu_total' then
|
|
|
|
elseif sample['type'] == 'virt_cpu_total' then
|
|
|
|
msg['Fields']['name'] = 'virt_cpu_time'
|
|
|
|
msg['Fields']['name'] = 'virt_cpu_time'
|
|
|
|
elseif sample['type'] == 'virt_vcpu' then
|
|
|
|
elseif sample['type'] == 'virt_vcpu' then
|
|
|
|
msg['Fields']['name'] = 'virt_vcpu_time'
|
|
|
|
msg['Fields']['name'] = 'virt_vcpu_time'
|
|
|
|
msg['Fields']['vcpu_number'] = sample['type_instance']
|
|
|
|
msg['Fields']['vcpu_number'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'][2] = 'vcpu_number'
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'vcpu_number')
|
|
|
|
else
|
|
|
|
else
|
|
|
|
msg['Fields']['name'] = 'virt' .. sep .. metric_name
|
|
|
|
msg['Fields']['name'] = 'virt' .. sep .. metric_name
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -376,13 +414,18 @@ function process_message ()
|
|
|
|
elseif metric_source == 'http_check' then
|
|
|
|
elseif metric_source == 'http_check' then
|
|
|
|
msg['Fields']['name'] = metric_source
|
|
|
|
msg['Fields']['name'] = metric_source
|
|
|
|
msg['Fields']['service'] = sample['type_instance']
|
|
|
|
msg['Fields']['service'] = sample['type_instance']
|
|
|
|
msg['Fields']['tag_fields'] = { 'service' }
|
|
|
|
table.insert(msg['Fields']['tag_fields'], 'service')
|
|
|
|
else
|
|
|
|
else
|
|
|
|
msg['Fields']['name'] = replace_dot_by_sep(metric_name)
|
|
|
|
msg['Fields']['name'] = replace_dot_by_sep(metric_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if not skip_it then
|
|
|
|
if not skip_it then
|
|
|
|
utils.inject_tags(msg)
|
|
|
|
utils.inject_tags(msg)
|
|
|
|
|
|
|
|
-- Before injecting the message we need to check that tag_fields is not an
|
|
|
|
|
|
|
|
-- empty table otherwise the protobuf encoder fails to encode the table.
|
|
|
|
|
|
|
|
if #msg['Fields']['tag_fields'] == 0 then
|
|
|
|
|
|
|
|
msg['Fields']['tag_fields'] = nil
|
|
|
|
|
|
|
|
end
|
|
|
|
utils.safe_inject_message(msg)
|
|
|
|
utils.safe_inject_message(msg)
|
|
|
|
if metric_source == 'swap' and metric_name == 'swap_used' and swap_size > 0 then
|
|
|
|
if metric_source == 'swap' and metric_name == 'swap_used' and swap_size > 0 then
|
|
|
|
-- collectd 5.4.0 doesn't report the used swap in
|
|
|
|
-- collectd 5.4.0 doesn't report the used swap in
|
|
|
|