def main(): args = parser.parse_args() msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: print(json.dumps(msg))
def main(): args = parser.parse_args() shpr = shipper.get_shipper(args.shipper)(args) msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: payload = json.dumps(msg) if args.bulk: command = json.dumps({"index": {"_index": args.bulk_index, "_type": args.bulk_type}}) payload = "{0}\n{1}\n".format(command, payload) shpr.ship(payload)
def main(): args = parser.parse_args() shpr = shipper.get_shipper(args.shipper)(args) msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) if args.fields: msgs = fields(msgs, args.fields) for msg in msgs: payload = json.dumps(msg) if args.bulk: command = json.dumps({'index': {'_index': args.bulk_index, '_type': args.bulk_type}}) payload = '{0}\n{1}\n'.format(command, payload) shpr.ship(payload)
def test_stamp(now_mock): now_mock.side_effect = [datetime.datetime(2013, 1, 1, 9, 0, 1, 0), datetime.datetime(2013, 1, 1, 9, 0, 2, 100), datetime.datetime(2013, 1, 1, 9, 0, 3, 200)] data = [{'@message': 'one'}, {'@message': 'two'}, {'@message': 'three'}] out = stamp(data) assert_equal(next(out), {'@timestamp': '2013-01-01T09:00:01.000000Z', '@message': 'one'}) assert_equal(next(out), {'@timestamp': '2013-01-01T09:00:02.000100Z', '@message': 'two'}) assert_equal(next(out), {'@timestamp': '2013-01-01T09:00:03.000200Z', '@message': 'three'})