Skip to content

coin-pipeliner/coin-elk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ELK Stack on Docker

์ง„ํ–‰์ƒํ™ฉ

  • coin-pipeliner ๋„คํŠธ์›Œํฌ ๋‚ด์—์„œ kafka-cluster, producer, elk stack ๋ชจ๋‘ ์—ฐ๊ฒฐ ์™„๋ฃŒ
  • vega ๋ฌธ๋ฒ•์„ ์ด์šฉํ•˜์—ฌ candle chart visualize
  • ํ˜„์žฌ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด๋“ค์ด๋Š” ๋Œ€๋กœ ์ €์žฅํ•˜๊ณ  ์‹œ๊ฐํ™” ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ƒ๋ช…์ฃผ๊ธฐ ๊ด€๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ๋ฐ์ดํ„ฐ๊ฐ€ ์Œ“์ด๊ธฐ๋งŒ ํ•˜๋Š” ์ƒํ™ฉ

์•ž์œผ๋กœ์˜ ๊ณผ์ œ

  • flick ์˜ ๋ถ„์„๊ฒฐ๊ณผ ์‹œ๊ฐํ™”
  • ์—ฌ๋Ÿฌ ์ธ๋ฑ์Šค๋ฅผ ๊ฐ™์ด ์‹œ๊ฐํ™”
  • ์ธ๋ฑ์Šค ์ƒ๋ช…์ฃผ๊ธฐ ๊ด€๋ฆฌ hot-warm-cold cycle (๋ชปํ•  ๊ฐ€๋Šฅ์„ฑ ๋†ํ›„)

์‹คํ–‰ ๋ฐฉ๋ฒ•

  1. ์ปค์Šคํ…€ ๋„คํŠธ์›Œํฌ ์ƒ์„ฑ (์ด๋ฏธ ์žˆ์œผ๋ฉด Skip)
docker network create coin-pipeliner
  1. (Optional) ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ

๋‚ด์žฅ๋œ์œ ์ € Elastic ์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด

.env ํŒŒ์ผ์˜

ELASTIC_PASSWORD ๊ฐ’์„ ๋ณ€๊ฒฝ

๊ทธ ์™ธ์— KIBANA_SYSTEM_PASSWORD ๋“ฑ๋„ ๊ฐ™์ด ๋ณ€๊ฒฝํ•ด์ค€๋‹ค.

ELASTIC_VERSION=8.1.2

## Passwords for stack users
#

# User 'elastic' (built-in)
#
# Superuser role, full access to cluster management and data indices.
# https://www.elastic.co/guide/en/elasticsearch/reference/current/built-in-users.html
ELASTIC_PASSWORD='changeme'

# User 'logstash_internal' (custom)
#
# The user Logstash uses to connect and send data to Elasticsearch.
# https://www.elastic.co/guide/en/logstash/current/ls-security.html
LOGSTASH_INTERNAL_PASSWORD='changeme'

# User 'kibana_system' (built-in)
#
# The user Kibana uses to connect and communicate with Elasticsearch.
# https://www.elastic.co/guide/en/elasticsearch/reference/current/built-in-users.html
KIBANA_SYSTEM_PASSWORD='changeme'
  1. Kafka ์‹คํ–‰

https://github.com/coin-pipeliner/Coin-Producer/tree/dev ์ฐธ๊ณ 

  1. ELK ๋นŒ๋“œ
docker compose build
  1. ELK ์‹คํ–‰
docker compose up # -d
  1. Elastic Search ์— logstash ์™€ kibana ๊ฐ€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ ๋ถ€์—ฌ
  • Elastic Search ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ bootup ๋˜๊ณ  ๋‚˜์„œ ๋ฐ”๋กœ ๊ถŒํ•œ์„ ์ฃผ์–ด์•ผ logstash ๋‚˜ kibana ์—์„œ ์ ‘์†ํ•  ๋•Œ ์˜ค๋ฅ˜๊ฐ€ ์—†๋‹ค
  • logstash ๊ถŒํ•œ ๋ถ€์—ฌ (terminal ์— ์ž…๋ ฅ)
  • ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ฐ”๊ฟจ๋‹ค๋ฉด changeme ๋ฅผ ๋ณ€๊ฒฝํ•ด์ฃผ๊ณ  email ๋„ ๋ณธ์ธ email
curl -k -u elastic:changeme -X POST "http://localhost:9200/_security/user/logstash_internal?pretty" -H 'Content-Type: application/json' -d'
{
  "password" : "changeme",
  "roles" : [ "superuser" ],
  "full_name" : "logstash internal",
  "email" : "์ด๋ฉ”์ผ@yonsei.ac.kr"
}
'
  • kibana ๊ถŒํ•œ ๋ถ€์—ฌ
curl -k -u elastic:changeme -X POST "http://localhost:9200/_security/user/kibina_system?pretty" -H 'Content-Type: application/json' -d'
{
  "password" : "changeme",
  "roles" : [ "superuser" ],
  "full_name" : "kibana system",
  "email" : "์ด๋ฉ”์ผ@yonsei.ac.kr"
}
'
  1. kibana ์›น ์ ‘์† - localhost:5601

user: elastic

password: changeme (์ดˆ๊ธฐ)

  1. coin-producer ๋กœ ๋ฐ์ดํ„ฐ ์ ์žฌ
  • ํ˜„์žฌ๋Š” btc-krw-๋‚ ์งœ ๋กœ index๊ฐ€ ๋งŒ๋“ค์–ด์ง
  • ์›น ์ฝ˜์†” ์ขŒ์ธก ๋ฉ”๋‰ด๋ฐ” ๋งจ ํ•˜๋‹จ stack management ์—์„œ ์ €์žฅ๋œ ์ธ๋ฑ์Šค ํ™•์ธ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.48.39.png

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.49.08.png

๋ฐ์ดํ„ฐ ์ž์ฒด๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ Discover ํƒญ ํด๋ฆญ

data view ๋ฅผ ๋งŒ๋“ค์–ด์•ผ ๋ณผ ์ˆ˜ ์žˆ๋Š”๋ฐ index ์ด๋ฆ„ ๊ทธ๋Œ€๋กœ ์ ์–ด์ฃผ๋ฉด ๋œ๋‹ค

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.49.35.png

์šฐ์ธก ์ƒ๋‹จ์— ์‹œ๊ฐ„์„ ์ ์ ˆํžˆ ์„ค์ •ํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.50.05.png

์‹œ๊ฐํ™”๋ฅผ ์œ„ํ•ด์„œ Visualize Library ํด๋ฆญ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.50.33.png

Custom visualiztion ์œผ๋กœ visualiztion ์„ ์ƒ์„ฑํ•œ๋‹ค (candle ์ฐจํŠธ ์ƒ์„ฑ์„ ์œ„ํ•ด)

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.51.03.png

์šฐ์ธก ์—๋””ํ„ฐ์— vega ์ฝ”๋“œ ์ž…๋ ฅ (vega ๋Š” ๊ทธ๋ž˜ํ”„๋ฅผ ์œ„ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ)

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2022-05-15 แ„‹แ…ฉแ„’แ…ฎ 9.51.56.png

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "width": 800,
  "autosize": {
    "type": "fit",
    "contains": "padding"
  },
  "description": "A candlestick chart inspired by an example in Protovis (http://mbostock.github.io/protovis/ex/candlestick.html)",
  "data": {
    "url": {
      "%context%": true,
      "%timefield%": "@timestamp",
      "index": "_all",
      "body": {
        "aggs": {
          "time_buckets": {
            "date_histogram": {
              "field": "@timestamp",
              "fixed_interval": "1s",
              "time_zone": "Asia/Seoul",
              "min_doc_count": 0
            },
            "aggs": {
              "high": {
                "max": {
                  "field": "high_price"
                }
              },
              "open": {
                "max": {
                  "field": "opening_price"
                }
              },
              "close": {
                "min": {
                  "field": "trade_price"
                }
              },
              "low": {
                "max": {
                  "field": "low_price"
                }
              }
            }
          }
        },
        "size": 0
      }
    },
    "format": { "property": "aggregations.time_buckets.buckets" }
  },

  "encoding": {
    "x": {
      "field": "key",
      "type": "temporal",
      "title": "Date"
    },
    "y": {
      "type": "quantitative",
      "scale": { "zero": false },
      "axis": { "title": "Price" }
    },
    "color": {
      "condition": {
        "test": "datum.open < datum.close",
        "value": "#06982d"
      },
      "value": "#ae1325"
    }
  },
  "layer": [
    {
      "mark": "rule",
      "encoding": {
        "y": { "field": "high.value" },
        "y2": { "field": "low.value" }
      }
    },
    {
      "mark": "bar",
      "encoding": {
        "y": { "field": "close.value" },
        "y2": { "field": "open.value" }
      }
    }
  ]
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published