Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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'})