Git Product home page Git Product logo

firelens-fluent-bit-sample's Introduction

firelens-fluent-bit-sample

AWS Fargate上のFirelensを利用して、ログをCloudWatchLogsとKinesisFirehoseに送信するサンプルです。

Fluent Bitを利用しログの種別によって送信先を分けています。

サンプルの実行方法

1.Terraformを利用してAWSに必要なリソースを構築します。

2.Application(今回はログを10秒間出力するだけ)とLogrouterのイメージをECRにpushします。

3.ECSのコンソールから、タスクを手動で実行します。

4.ログがCloudWatchLogsとKinesisFirehoseに出力されていることを確認します。

Terraform

Terraformを利用して必要なリソースを構築します。

aws-fargate/providers/terraform.tfvars を追加し、プロファイルを設定してください。

profile = "your-profile-name"

ECRへのpush

direnvを利用して、AWS CLIのprofileを指定します。

export AWS_PROFILE=your-profile-name
export AWS_REGION=your-region
  • app用

app/push-ecr.sh を実行して、ECRへpushを行います。

引数に、アカウントIDとECRのリポジトリ名を指定してください。

$ ./app/push-ecr.sh 123456789012 firelens-fluentbit-sample-app
  • fluentbit用

fluentbit/push-ecr-logrouter.sh を実行して、ECRへpushを行います。

引数に、アカウントIDとECRのリポジトリ名を指定してください。

$ ./fluentbit/push-ecr-logrouter.sh 123456789012 firelens-fluentbit-sample-logrouter

ログサンプル

Golangのアプリケーションのログは下記の通りです。

serviceがaccessの場合はKinesisFirehoseへ、serviceがerrorの場合はCloudWatchLogsへ送信します。

{"countdown":10,"level":"info","msg":"FireLens Fluent Bit Test","service":"error","time":"2020-01-24T21:25:05+09:00"}
{"countdown":9,"level":"info","msg":"FireLens Fluent Bit Test","service":"access","time":"2020-01-24T21:25:06+09:00"}
{"countdown":8,"level":"info","msg":"FireLens Fluent Bit Test","service":"error","time":"2020-01-24T21:25:07+09:00"}
{"countdown":7,"level":"info","msg":"FireLens Fluent Bit Test","service":"access","time":"2020-01-24T21:25:08+09:00"}
{"countdown":6,"level":"info","msg":"FireLens Fluent Bit Test","service":"error","time":"2020-01-24T21:25:09+09:00"}
{"countdown":5,"level":"info","msg":"FireLens Fluent Bit Test","service":"access","time":"2020-01-24T21:25:10+09:00"}
{"countdown":4,"level":"info","msg":"FireLens Fluent Bit Test","service":"error","time":"2020-01-24T21:25:11+09:00"}
{"countdown":3,"level":"info","msg":"FireLens Fluent Bit Test","service":"access","time":"2020-01-24T21:25:12+09:00"}
{"countdown":2,"level":"info","msg":"FireLens Fluent Bit Test","service":"error","time":"2020-01-24T21:25:13+09:00"}
{"countdown":1,"level":"info","msg":"FireLens Fluent Bit Test","service":"access","time":"2020-01-24T21:25:14+09:00"}

firelens-fluent-bit-sample's People

Contributors

kobayashi-m42 avatar

Watchers

 avatar

firelens-fluent-bit-sample's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.