added request statusCode heka counter

This commit is contained in:
Danny Coates 2013-06-04 17:47:03 -07:00
Родитель 8e75bd9f53
Коммит 14290c8854
4 изменённых файлов: 69 добавлений и 2 удалений

Просмотреть файл

@ -19,7 +19,7 @@ max_filters = 100
[memoryGauge]
type = "SandboxFilter"
message_matcher = "Type == 'ops'"
message_matcher = "Type == 'mem'"
ticker_interval = 15
script_type = "lua"
filename = "./heka/memory.lua"
@ -28,6 +28,17 @@ memory_limit = 1048576
instruction_limit = 100
output_limit = 64512
[requestCounter]
type = "SandboxFilter"
message_matcher = "Type == 'request'"
ticker_interval = 60
script_type = "lua"
filename = "./heka/request.lua"
preserve_data = false
memory_limit = 1048576
instruction_limit = 100
output_limit = 64512
[debugOutput]
type = "LogOutput"
message_matcher = "Type != 'heka.all-report' && Type != 'heka.sandbox-output' && Type != 'statmetric'"

Просмотреть файл

@ -0,0 +1,33 @@
data = circular_buffer.new(1440, 5, 60)
local OK = data:set_header(1, "200", "count")
local REDIRECT = data:set_header(2, "300", "count")
local BADREQUEST = data:set_header(3, "400", "count")
local SERVERERR = data:set_header(4, "500", "count")
local TOTAL = data:set_header(5, "TOTAL", "count")
function process_message()
local ts = read_message("Timestamp")
local statusCode = read_message("Fields[statusCode]")
if statusCode == nil then return 0 end
data:add(ts, TOTAL, 1)
if statusCode < 200 then
return 0
elseif statusCode < 300 then
data:add(ts, OK, 1)
elseif statusCode < 400 then
data:add(ts, REDIRECT, 1)
elseif statusCode < 500 then
data:add(ts, BADREQUEST, 1)
elseif statusCode < 600 then
data:add(ts, SERVERERR, 1)
end
return 0
end
function timer_event(ns)
output(data)
inject_message("cbuf", "HTTP status codes")
end

Просмотреть файл

@ -36,7 +36,7 @@ module.exports = {
// statsd.gauge('heapUsed', event.proc.mem.heapUsed);
heka.heka(
'ops',
'mem',
{
timestamp: new Date(event.timestamp),
severity: 6,
@ -50,5 +50,24 @@ module.exports = {
hostname: HOSTNAME
}
);
},
request: function (event) {
heka.heka(
'request',
{
timestamp: new Date(event.timestamp),
severity: 6,
fields: {
method: event.method,
statusCode: event.statusCode,
path: event.path,
responseTime: event.responseTime
},
pid: PID,
hostname: HOSTNAME
}
);
}
};

Просмотреть файл

@ -54,6 +54,10 @@ server.pack.require('good', {
ops: {
events: ['ops'],
handler: stats.ops
},
request: {
events: ['request'],
handler: stats.request
}
},
extendedRequests: true,