- coin-pipeliner ๋คํธ์ํฌ ๋ด์์ kafka-cluster, producer, elk stack ๋ชจ๋ ์ฐ๊ฒฐ ์๋ฃ
- vega ๋ฌธ๋ฒ์ ์ด์ฉํ์ฌ candle chart visualize
- ํ์ฌ๋ ๋ฐ์ดํฐ๋ฅผ ์ฝ์ด๋ค์ด๋ ๋๋ก ์ ์ฅํ๊ณ ์๊ฐํ ํ๊ธฐ ๋๋ฌธ์ ์๋ช ์ฃผ๊ธฐ ๊ด๋ฆฌ๊ฐ ํ์ํ๋ค. ๋ฐ์ดํฐ๊ฐ ์์ด๊ธฐ๋ง ํ๋ ์ํฉ
- flick ์ ๋ถ์๊ฒฐ๊ณผ ์๊ฐํ
- ์ฌ๋ฌ ์ธ๋ฑ์ค๋ฅผ ๊ฐ์ด ์๊ฐํ
- ์ธ๋ฑ์ค ์๋ช ์ฃผ๊ธฐ ๊ด๋ฆฌ hot-warm-cold cycle (๋ชปํ ๊ฐ๋ฅ์ฑ ๋ํ)
- ์ปค์คํ ๋คํธ์ํฌ ์์ฑ (์ด๋ฏธ ์์ผ๋ฉด Skip)
docker network create coin-pipeliner
- (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'
- Kafka ์คํ
https://github.com/coin-pipeliner/Coin-Producer/tree/dev ์ฐธ๊ณ
- ELK ๋น๋
docker compose build
- ELK ์คํ
docker compose up # -d
- 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"
}
'
- kibana ์น ์ ์ - localhost:5601
user: elastic
password: changeme (์ด๊ธฐ)
- coin-producer ๋ก ๋ฐ์ดํฐ ์ ์ฌ
- ํ์ฌ๋ btc-krw-๋ ์ง ๋ก index๊ฐ ๋ง๋ค์ด์ง
- ์น ์ฝ์ ์ข์ธก ๋ฉ๋ด๋ฐ ๋งจ ํ๋จ stack management ์์ ์ ์ฅ๋ ์ธ๋ฑ์ค ํ์ธ
๋ฐ์ดํฐ ์์ฒด๋ฅผ ํ์ธํ๊ธฐ ์ํด์ Discover ํญ ํด๋ฆญ
data view ๋ฅผ ๋ง๋ค์ด์ผ ๋ณผ ์ ์๋๋ฐ index ์ด๋ฆ ๊ทธ๋๋ก ์ ์ด์ฃผ๋ฉด ๋๋ค
์ฐ์ธก ์๋จ์ ์๊ฐ์ ์ ์ ํ ์ค์ ํ๋ฉด ๋ฐ์ดํฐ๋ฅผ ํ์ธํ ์ ์๋ค.
์๊ฐํ๋ฅผ ์ํด์ Visualize Library ํด๋ฆญ
Custom visualiztion ์ผ๋ก visualiztion ์ ์์ฑํ๋ค (candle ์ฐจํธ ์์ฑ์ ์ํด)
์ฐ์ธก ์๋ํฐ์ vega ์ฝ๋ ์ ๋ ฅ (vega ๋ ๊ทธ๋ํ๋ฅผ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ)
{
"$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" }
}
}
]
}