зеркало из https://github.com/mozilla/fxa.git
switch to using native heka messages for memory reporting
This commit is contained in:
Родитель
53f7a435f5
Коммит
8e75bd9f53
|
@ -17,9 +17,9 @@ message_matcher = "Type == 'heka.control.sandbox'"
|
|||
working_directory = "./sandbox"
|
||||
max_filters = 100
|
||||
|
||||
[memory_counter]
|
||||
[memoryGauge]
|
||||
type = "SandboxFilter"
|
||||
message_matcher = "Type == 'statmetric'"
|
||||
message_matcher = "Type == 'ops'"
|
||||
ticker_interval = 15
|
||||
script_type = "lua"
|
||||
filename = "./heka/memory.lua"
|
||||
|
@ -28,9 +28,9 @@ memory_limit = 1048576
|
|||
instruction_limit = 100
|
||||
output_limit = 64512
|
||||
|
||||
[debug_output]
|
||||
[debugOutput]
|
||||
type = "LogOutput"
|
||||
message_matcher = "Type != 'heka.all-report' && Type != 'heka.sandbox-output'"
|
||||
message_matcher = "Type != 'heka.all-report' && Type != 'heka.sandbox-output' && Type != 'statmetric'"
|
||||
payload_only = false
|
||||
|
||||
[DashboardOutput]
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
data = circular_buffer.new(240, 3, 15)
|
||||
local cols = {
|
||||
rss = data:set_header(1, "RSS", "max"),
|
||||
heapTotal = data:set_header(2, "HEAP_TOTAL", "max"),
|
||||
heapUsed = data:set_header(3, "HEAP_USED", "max")
|
||||
}
|
||||
local RSS = data:set_header(1, "RSS", "max")
|
||||
local TOTAL = data:set_header(2, "Heap_Total", "max")
|
||||
local USED = data:set_header(3, "Heap_Used", "max")
|
||||
local SCALE = 1024 * 1024
|
||||
|
||||
function process_message()
|
||||
local ts = read_message("Timestamp")
|
||||
local payload = read_message("Payload")
|
||||
if payload == nil then return 0 end
|
||||
local rss = read_message("Fields[rss]")
|
||||
local heapTotal = read_message("Fields[heapTotal]")
|
||||
local heapUsed = read_message("Fields[heapUsed]")
|
||||
if rss == nil then return 0 end
|
||||
|
||||
for k, v in string.gmatch(payload, "stats.(%w+) (%d+)") do
|
||||
if cols[k] ~= nil then
|
||||
data:set(ts, cols[k], v)
|
||||
end
|
||||
end
|
||||
data:set(ts, RSS, (rss / SCALE))
|
||||
data:set(ts, TOTAL, (heapTotal / SCALE))
|
||||
data:set(ts, USED, (heapUsed / SCALE))
|
||||
|
||||
return 0
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
ip_address = "127.0.0.1:5565"
|
||||
ip_address = "127.0.0.1:5565"
|
||||
[signer]
|
||||
name = "test"
|
||||
hmac_hash = "md5"
|
||||
hmac_key = "4865ey9urgkidls xtb0[7lf9rzcivthkm"
|
||||
version = 0
|
||||
name = "test"
|
||||
hmac_hash = "md5"
|
||||
hmac_key = "4865ey9urgkidls xtb0[7lf9rzcivthkm"
|
||||
version = 0
|
|
@ -1,56 +1,54 @@
|
|||
const os = require('os');
|
||||
const Heka = require('heka');
|
||||
const Statsd = require('node-statsd').StatsD;
|
||||
//const Statsd = require('node-statsd').StatsD;
|
||||
|
||||
//TODO read config
|
||||
|
||||
const HOSTNAME = os.hostname();
|
||||
const PID = process.pid;
|
||||
|
||||
// var heka = Heka.clientFromJsonConfig(
|
||||
// JSON.stringify(
|
||||
// {
|
||||
// sender: {
|
||||
// factory: './senders:udpSenderFactory',
|
||||
// hosts: '127.0.0.1',
|
||||
// ports: 4880
|
||||
// },
|
||||
// logger: 'picl-idp',
|
||||
// severity: 5
|
||||
// }
|
||||
// )
|
||||
// );
|
||||
|
||||
var statsd = new Statsd(
|
||||
{
|
||||
host: '127.0.0.1',
|
||||
port: 8125
|
||||
}
|
||||
var heka = Heka.clientFromJsonConfig(
|
||||
JSON.stringify(
|
||||
{
|
||||
sender: {
|
||||
factory: './senders:udpSenderFactory',
|
||||
hosts: '127.0.0.1',
|
||||
ports: 4880
|
||||
},
|
||||
logger: 'picl-idp',
|
||||
severity: 5
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// var statsd = new Statsd(
|
||||
// {
|
||||
// host: '127.0.0.1',
|
||||
// port: 8125
|
||||
// }
|
||||
// );
|
||||
|
||||
module.exports = {
|
||||
ops: function (event) {
|
||||
|
||||
statsd.gauge('rss', event.proc.mem.rss);
|
||||
statsd.gauge('heapTotal', event.proc.mem.heapTotal);
|
||||
statsd.gauge('heapUsed', event.proc.mem.heapUsed);
|
||||
// statsd.gauge('rss', event.proc.mem.rss);
|
||||
// statsd.gauge('heapTotal', event.proc.mem.heapTotal);
|
||||
// statsd.gauge('heapUsed', event.proc.mem.heapUsed);
|
||||
|
||||
// When we send stats with heka it will look like this:
|
||||
//
|
||||
// heka.heka(
|
||||
// 'ops',
|
||||
// {
|
||||
// timestamp: new Date(event.timestamp),
|
||||
// severity: 6,
|
||||
// fields: {
|
||||
// rss: event.proc.mem.rss,
|
||||
// heapTotal: event.proc.mem.heapTotal,
|
||||
// heapUsed: event.proc.mem.heapUsed,
|
||||
// uptime: event.proc.uptime
|
||||
// },
|
||||
// pid: PID,
|
||||
// hostname: HOSTNAME
|
||||
// }
|
||||
// );
|
||||
heka.heka(
|
||||
'ops',
|
||||
{
|
||||
timestamp: new Date(event.timestamp),
|
||||
severity: 6,
|
||||
fields: {
|
||||
rss: event.proc.mem.rss,
|
||||
heapTotal: event.proc.mem.heapTotal,
|
||||
heapUsed: event.proc.mem.heapUsed,
|
||||
uptime: event.proc.uptime
|
||||
},
|
||||
pid: PID,
|
||||
hostname: HOSTNAME
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
"async": "0.2.8",
|
||||
"kvstore": "git://github.com/mozilla/node-kvstore.git#4b8c2f6763",
|
||||
"good": "git://github.com/dannycoates/good.git#223e5d6db3",
|
||||
"heka": "git://github.com/dannycoates/heka-node.git#dc31a1c1f4",
|
||||
"heka": "git://github.com/dannycoates/heka-node.git#db91220ec0",
|
||||
"node-statsd": "0.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче