362f447d9f
* cmd/statreceiver: lua-scriptable stat receiver Change-Id: I3ce0fe3f1ef4b1f4f27eed90bac0e91cfecf22d7 * some updates Change-Id: I7c3485adcda1278fce01ae077b4761b3ddb9fb7a * more comments Change-Id: I0bb22993cd934c3d40fc1da80d07e49e686b80dd * linter fixes Change-Id: Ied014304ecb9aadcf00a6b66ad28f856a428d150 * catch errors Change-Id: I6e1920f1fd941e66199b30bc427285c19769fc70 * review feedback Change-Id: I9d4051851eab18970c5f5ddcf4ff265508e541d3 * errorgroup improvements Change-Id: I4699dda3022f0485fbb50c9dafe692d3921734ff * too tricky the previous thing was better for memory with lots of errors at a time but https://play.golang.org/p/RweTMRjoSCt is too much of a foot gun Change-Id: I23f0b3d77dd4288fcc20b3756a7110359576bf44
57 lines
1.8 KiB
Lua
57 lines
1.8 KiB
Lua
-- possible sources:
|
|
-- * udpin(address)
|
|
-- * filein(path)
|
|
-- multiple sources can be handled in the same run (including multiple sources
|
|
-- of the same type) by calling deliver more than once.
|
|
source = udpin("localhost:9000")
|
|
|
|
-- multiple metric destination types
|
|
-- * graphite(address) goes to tcp with the graphite wire protocol
|
|
-- * print() goes to stdout
|
|
-- * db("sqlite3", path) goes to sqlite
|
|
-- * db("postgres", connstring) goes to postgres
|
|
graphite_out = graphite("localhost:5555")
|
|
db_out = mcopy(
|
|
db("sqlite3", "db.db"),
|
|
db("postgres", "user=dbuser dbname=dbname"))
|
|
|
|
metric_handlers = mcopy(
|
|
-- send all satellite data to graphite
|
|
appfilter("satellite-prod",
|
|
graphite("localhost:5555")),
|
|
-- send specific storagenode data to the db
|
|
appfilter("storagenode-prod",
|
|
keyfilter(
|
|
"env\\.process\\." ..
|
|
"|hw\\.disk\\..*Used" ..
|
|
"|hw\\.disk\\..*Avail" ..
|
|
"|hw\\.network\\.stats\\..*\\.(tx|rx)_bytes\\.(deriv|val)",
|
|
db_out)),
|
|
-- just print uplink stuff
|
|
appfilter("uplink-prod",
|
|
print()))
|
|
|
|
-- create a metric parser.
|
|
metric_parser =
|
|
parse( -- parse takes one or two arguments. the first argument is
|
|
-- a metric handler, the remaining one is a per-packet application or
|
|
-- instance filter. each filter is a regex. all packets must
|
|
-- match all packet filters.
|
|
sanitize(metric_handlers), -- sanitize converts weird chars to underscores
|
|
packetfilter("storagenode-prod|satellite-prod|uplink-prod", ""))
|
|
|
|
-- pcopy forks data to multiple outputs
|
|
-- output types include parse, fileout, and udpout
|
|
destination = pcopy(
|
|
fileout("dump.out"),
|
|
metric_parser,
|
|
|
|
-- useful local debugging
|
|
udpout("localhost:9001"),
|
|
|
|
-- rothko
|
|
udpout("localhost:9002"))
|
|
|
|
-- tie the source to the destination
|
|
deliver(source, destination)
|