From 0f19aab53248687a7c3d235b53c49d2cb55dc78a Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Wed, 31 Mar 2021 15:44:14 +0900 Subject: [PATCH] create fluentd test --- fluentd/docker-compose.yml | 8 ++++++++ fluentd/fluent.conf | 37 +++++++++++++++++++++++++++++++++++++ fluentd/index.js | 25 +++++++++++++++++++++++++ fluentd/package.json | 12 ++++++++++++ fluentd/yarn.lock | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 fluentd/docker-compose.yml create mode 100644 fluentd/fluent.conf create mode 100644 fluentd/index.js create mode 100644 fluentd/package.json create mode 100644 fluentd/yarn.lock diff --git a/fluentd/docker-compose.yml b/fluentd/docker-compose.yml new file mode 100644 index 0000000..3fa6369 --- /dev/null +++ b/fluentd/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3" +services: + fluentd: + image: fluent/fluentd:edge + ports: ["24224:24224"] + volumes: + - "./log:/fluentd/log" + - "./fluent.conf:/fluentd/etc/fluent.conf" diff --git a/fluentd/fluent.conf b/fluentd/fluent.conf new file mode 100644 index 0000000..3a0510a --- /dev/null +++ b/fluentd/fluent.conf @@ -0,0 +1,37 @@ + + enable_msgpack_time_support true + + + + @type forward + @id input1 + @label @mainstream + port 24224 + + + + @type stdout + + + diff --git a/fluentd/index.js b/fluentd/index.js new file mode 100644 index 0000000..c1a0800 --- /dev/null +++ b/fluentd/index.js @@ -0,0 +1,25 @@ +import msgpack from "msgpack-lite"; +import fetch from "node-fetch"; + +const body = msgpack.encode({ + int: 1, + float: 0.5, + // date: new Date(), + // error: new Error(), + // num: new Number(0), + buff: Buffer.from([1, 2]), + // arrbuff: Uint32Array.from([3, 4]), + // dataView: new ArrayBuffer([1]), + array: [2, 3], + object: { key: "val" }, + str: new String("hello"), + // bool: new Boolean(true), + // intArray: new Int8Array(), + // bigInt: 1n, +}); +const res = await fetch("http://localhost:24224/", { + method: "POST", + headers: { "Content-type": "application/msgpack" }, + body, +}); +console.log(res); diff --git a/fluentd/package.json b/fluentd/package.json new file mode 100644 index 0000000..02dec52 --- /dev/null +++ b/fluentd/package.json @@ -0,0 +1,12 @@ +{ + "name": "fluentd", + "version": "1.0.0", + "main": "index.js", + "type": "module", + "author": "Kohei Watanabe ", + "license": "MIT", + "dependencies": { + "msgpack-lite": "^0.1.26", + "node-fetch": "^2.6.1" + } +} diff --git a/fluentd/yarn.lock b/fluentd/yarn.lock new file mode 100644 index 0000000..1006072 --- /dev/null +++ b/fluentd/yarn.lock @@ -0,0 +1,38 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +event-lite@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/event-lite/-/event-lite-0.1.2.tgz#838a3e0fdddef8cc90f128006c8e55a4e4e4c11b" + integrity sha512-HnSYx1BsJ87/p6swwzv+2v6B4X+uxUteoDfRxsAb1S1BePzQqOLevVmkdA15GHJVd9A9Ok6wygUR18Hu0YeV9g== + +ieee754@^1.1.8: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +int64-buffer@^0.1.9: + version "0.1.10" + resolved "https://registry.yarnpkg.com/int64-buffer/-/int64-buffer-0.1.10.tgz#277b228a87d95ad777d07c13832022406a473423" + integrity sha1-J3siiofZWtd30HwTgyAiQGpHNCM= + +isarray@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +msgpack-lite@^0.1.26: + version "0.1.26" + resolved "https://registry.yarnpkg.com/msgpack-lite/-/msgpack-lite-0.1.26.tgz#dd3c50b26f059f25e7edee3644418358e2a9ad89" + integrity sha1-3TxQsm8FnyXn7e42REGDWOKprYk= + dependencies: + event-lite "^0.1.1" + ieee754 "^1.1.8" + int64-buffer "^0.1.9" + isarray "^1.0.0" + +node-fetch@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==