Merge pull request #113 from simonpasquier/improve-keystone-wsgi-decoder
Improve the Keystone WSGI log decoder
diff --git a/heka/files/lua/common/contrail_patterns.lua b/heka/files/lua/common/contrail_patterns.lua
index 3383a3b..9499875 100644
--- a/heka/files/lua/common/contrail_patterns.lua
+++ b/heka/files/lua/common/contrail_patterns.lua
@@ -37,7 +37,7 @@
-- Common patterns
local modulename = l.Cg(pgname, "Module")
local ip_address = l.Cg((l.digit + patt.dot)^1, "ip_address")
-local http_status = l.Cg(patt.Number, "status")
+local http_status = l.Cg(patt.Number / tonumber, "status")
local http_request_time = l.Cg(patt.Number, "request_time")
local delim = (patt.sp + patt.dash)^1
local hostname = l.Cg(patt.programname, "Hostname")
diff --git a/heka/files/lua/common/patterns.lua b/heka/files/lua/common/patterns.lua
index 09be695..be43d08 100644
--- a/heka/files/lua/common/patterns.lua
+++ b/heka/files/lua/common/patterns.lua
@@ -121,7 +121,7 @@
-- TODO(pasquier-s): build the LPEG grammar based on the log_format parameter
-- passed to eventlet.wsgi.server similar to what the build_rsyslog_grammar
-- function does for RSyslog.
-local openstack_http_status = l.P"status: "^-1 * l.Cg(l.digit^3, "http_status")
+local openstack_http_status = l.P"status: "^-1 * l.Cg(l.digit^3 / tonumber, "http_status")
local openstack_response_size = l.P"len: "^-1 * l.Cg(l.digit^1 / tonumber, "http_response_size")
local openstack_response_time = l.P"time: "^-1 * l.Cg(l.digit^1 * dot^0 * l.digit^0 / tonumber, "http_response_time")
diff --git a/heka/files/lua/decoders/collectd.lua b/heka/files/lua/decoders/collectd.lua
index b206100..ef5f27d 100644
--- a/heka/files/lua/decoders/collectd.lua
+++ b/heka/files/lua/decoders/collectd.lua
@@ -252,6 +252,14 @@
else
msg['Fields']['name'] = msg['Fields']['name'] .. sample['type_instance']
end
+ if sample['meta'] and sample['meta']['aggregate'] then
+ msg['Fields']['aggregate'] = sample['meta']['aggregate']
+ table.insert(msg['Fields']['tag_fields'], 'aggregate')
+ end
+ if sample['meta'] and sample['meta']['aggregate_id'] then
+ msg['Fields']['aggregate_id'] = sample['meta']['aggregate_id']
+ table.insert(msg['Fields']['tag_fields'], 'aggregate_id')
+ end
elseif metric_source == 'rabbitmq_info' then
msg['Fields']['name'] = 'rabbitmq' .. sep .. sample['type_instance']
if sample['meta'] and sample['meta']['queue'] then
diff --git a/heka/files/toml/output/udp.toml b/heka/files/toml/output/udp.toml
new file mode 100644
index 0000000..1b2854e
--- /dev/null
+++ b/heka/files/toml/output/udp.toml
@@ -0,0 +1,13 @@
+[{{ output_name }}_output]
+type="UdpOutput"
+address = "{{ output.host }}:{{ output.port }}"
+encoder = "{{ output.encoder }}"
+message_matcher = "{{ output.message_matcher }}"
+
+{%- if output.get('use_buffering', True) %}
+use_buffering = true
+[{{ output_name }}_output.buffering]
+max_buffer_size = {{ output.buffering_max_buffer_size|default(268435456) }}
+max_file_size = {{ output.buffering_max_file_size|default(67108864) }}
+full_action = "{{ output.output.buffering_full_action|default("drop") }}"
+{%- endif %}
diff --git a/tests/lua/test_patterns.lua b/tests/lua/test_patterns.lua
index 86d9507..d15b49d 100644
--- a/tests/lua/test_patterns.lua
+++ b/tests/lua/test_patterns.lua
@@ -87,12 +87,12 @@
assertEquals(patt.openstack_http:match(
'"OPTIONS / HTTP/1.0" status: 200 len: 497 time: 0.0006731'),
{http_method = 'OPTIONS', http_url = '/', http_version = '1.0',
- http_status = '200', http_response_size = 497,
+ http_status = 200, http_response_size = 497,
http_response_time = 0.0006731})
assertEquals(patt.openstack_http:match(
'foo "OPTIONS / HTTP/1.0" status: 200 len: 497 time: 0.0006731 bar'),
{http_method = 'OPTIONS', http_url = '/', http_version = '1.0',
- http_status = '200', http_response_size = 497,
+ http_status = 200, http_response_size = 497,
http_response_time = 0.0006731})
end
@@ -100,12 +100,12 @@
assertEquals(patt.openstack_http:match(
'"OPTIONS / HTTP/1.0" status: 200 len: 497 time: 0.0006731'),
{http_method = 'OPTIONS', http_url = '/', http_version = '1.0',
- http_status = '200', http_response_size = 497,
+ http_status = 200, http_response_size = 497,
http_response_time = 0.0006731})
assertEquals(patt.openstack_http:match(
'foo "OPTIONS / HTTP/1.0" status: 200 len: 497 time: 0.0006731 bar'),
{http_method = 'OPTIONS', http_url = '/', http_version = '1.0',
- http_status = '200', http_response_size = 497,
+ http_status = 200, http_response_size = 497,
http_response_time = 0.0006731})
end