๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋ฐ˜์‘ํ˜•

Back-end

ElastAlert ElastAlert๋ž€?Elasticsearch์˜ ๋ฐ์ดํ„ฐ์—์„œ ์ž‘์„ฑํ•œ ๊ทœ์น™์— ๋”ฐ๋ผ์„œ ์•Œ๋ฆผ์„ ์ „์†กํ•˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ.Elasticsearch์— ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ๋กํ•˜๊ณ  ์žˆ๊ณ  ํ•ด๋‹น ๋ฐ์ดํ„ฐ๊ฐ€ ํŠน์ • ํŒจํ„ด(๊ทœ์น™)๊ณผ ์ผ์น˜ํ•  ๋•Œ ์•Œ๋ฆผ์„ ๋ฐ›๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ.ElastAlert ์ž‘๋™ ๋ฐฉ์‹๋ฐ์ดํ„ฐ ์†Œ์Šค๋ฅผ ์ฃผ๊ธฐ์ ์œผ๋กœ ์ฟผ๋ฆฌ → ์ •์˜ํ•œ ๊ทœ์น™ ์œ ํ˜•์— ์ผ์น˜ํ•˜๋Š” ์ง€๋ฅผ ๊ฒ€์‚ฌ → ์ผ์น˜ํ•œ๋‹ค๋ฉด ์ •์˜ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ alert ๋ฐœElastAlert ๊ทœ์น™ ๊ตฌ์„ฑname : ๊ทœ์น™์˜ ๊ณ ์œ ํ•œ ์ด๋ฆ„. ๋™์ผํ•œ ์ด๋ฆ„์ด 2๊ฐœ ์ด์ƒ์ผ ๊ฒฝ์šฐ ElastAlert๊ฐ€ ์‹œ์ž‘๋˜์ง€ ์•Š๋Š”๋‹ค.index : ์ฟผ๋ฆฌํ•  ๋ฐ์ดํ„ฐ ์†Œ์Šค์˜ ์œ„์น˜. ์™€์ผ๋“œ ์นด๋“œ, ์—ฌ๋Ÿฌ๊ฐœ ์‚ฌ์šฉ ๊ฐ€๋Šฅindex: topbeat-*,packetbeat-*type : ๊ทœ์น™์˜ ์œ ํ˜•. type์— ๋”ฐ๋ผ ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์œผ.. ๋”๋ณด๊ธฐ
์›น์„œ๋ฒ„(Web Server)์™€ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„(Web Application Server) ์›น ์„œ๋ฒ„? ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„? ์›น ์„œ๋ฒ„์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•˜๋ฉด์„œ, ์›น ์„œ๋ฒ„์™€ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„๋กœ ๊ตฌ๋ถ„๋œ๋‹ค๋Š” ์‚ฌ์‹ค์„ ์•Œ๊ฒŒ๋˜์—ˆ๊ณ , ์ž˜ ์ •๋ฆฌ๊ฐ€ ๋œ ๋ธ”๋กœ๊ทธ๋ฅผ ์ฝ๊ณ  ๋‚˜๋ฆ„๋Œ€๋กœ ์ •๋ฆฌ(?)๋ฅผ ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ์›น ์„œ๋ฒ„์™€ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„์˜ ์ฐจ์ด์ ์„ ์ •๋ฆฌํ•˜๊ธฐ์— ์•ž์„œ, ์›น ์„œ๋น„์Šค๋Š” ์–ด๋–ค ๊ตฌ์กฐ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๊ณ , ์›น ์„œ๋น„์Šค๋ฅผ ์ด๋ฃจ๊ณ  ์žˆ๋Š” ์›น์„œ๋ฒ„์™€ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„๊ฐ€ ๋ฌด์—‡์ธ์ง€๋ฅผ ์ •๋ฆฌํ•ด ๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ์›น ์„œ๋น„์Šค ๊ตฌ์กฐ Client → ์›น ์„œ๋ฒ„ → DB Client → ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„ → DB Client → ์›น ์„œ๋ฒ„ → ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„ → DB ์›น ์„œ๋น„์Šค๋Š” ์œ„์ฒ˜๋Ÿผ ๋‹ค์–‘ํ•œ ๊ตฌ์กฐ๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค. ์›น ์„œ๋ฒ„๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜๋„, ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜๋„, ๋‘˜ ๋‹ค ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ตฌ์กฐ๋ฅผ ์‰ฝ๊ฒŒ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด.. ๋”๋ณด๊ธฐ
Slack์œผ๋กœ OAuth ์‚ฌ์šฉํ•˜๊ธฐ OAuth๋ž€? OAuth๋Š” ์ž์› ์†Œ์œ ์ž(๊ตฌ๊ธ€, ์นด์นด์˜ค, ํŽ˜์ด์Šค๋ถ, ์Šฌ๋ž™)์™€ HTTP ์„œ๋น„์Šค ๊ฐ„์˜ ์Šน์ธ ์ƒํ˜ธ ์ž‘์šฉ์„ ์กฐ์ •ํ•˜๊ฑฐ๋‚˜ ์ œ 3์ž ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์Šค์Šค๋กœ ์•ก์„ธ์Šค๋ฅผ ์–ป์Œ์œผ๋กœ์จ ์ž์› ์†Œ์œ ์ž์˜ ์„œ๋น„์Šค์— ๋Œ€ํ•œ ์ œํ•œ๋œ ์•ก์„ธ์Šค๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์ธ์ฆ ํ”„๋ ˆ์ž„์›Œํฌ์ด๋‹ค. ํ”ํžˆ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๊ตฌ๊ธ€ ๋กœ๊ทธ์ธ, ์นด์นด์˜ค ๋กœ๊ทธ์ธ์€ OAuth๋ฅผ ํ†ตํ•ด์„œ ํ•ด๋‹น ์„œ๋น„์Šค์— ๊ฐ€์ž…ํ•œ ์‚ฌ์šฉ์ž์˜ ์ •๋ณด๋ฅผ ์ผ๋ จ์˜ ๊ณผ์ •์„ ํ†ตํ•ด์„œ ์ œ 3์ž ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์„œ ํšŒ์›๊ฐ€์ž…์„ ์ƒ๋žตํ•˜๊ณ  ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•  ์ˆ˜ ๋„ ์žˆ๋‹ค. ๋˜ํ•œ OAuth์™€ ์Šฌ๋ž™์—์„œ ์ œ๊ณตํ•˜๋Š” api๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Šฌ๋ž™์ด ์•„๋‹Œ ๋‚ด๊ฐ€ ๋งŒ๋“  ์›น์—์„œ ์Šฌ๋ž™์— ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ๋“ฑ ์ž์› ์†Œ์œ ์ž๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์„œ๋น„์Šค๋ฅผ ์ œ 3์ž ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค. OAuth๋Š” ํฌ๊ฒŒ Access Token๊ณผ S.. ๋”๋ณด๊ธฐ
MongoDB: ๊ณ ๊ธ‰ ์ฟผ๋ฆฌ(Advanced Queries - Aggregation Framework) Aggreagation Pipeline Aggregate() function is used for creating pipelines db.COLLECTION_NAME.aggregate(pipline,options) Documents enter a multi-stage pipline that transforms the documents into an aggregated result → document๋Š” multi-stage pipline์„ ํ†ต๊ณผํ•ด์„œ aggregated๋œ result๋ฅผ ๋ฐ˜ํ™˜ SQL to Attregation Mapping Chart Aggregation Pipeline Stages $match { $match: {query}} aggregation pipeline์€ ๊ฐ€๋Šฅํ•˜๋ฉด ์•ž์— ๋‘”๋‹ค. ag.. ๋”๋ณด๊ธฐ
MongoDB: ์ค‘๊ธ‰ ์ฟผ๋ฆฌ (Manipulating Data - Intermediate Query) Query embedded document {field : document} ์ˆœ์„œ๊ฐ€ ๋‹ค๋ฅผ ๊ฒฝ์šฐ ๊ฒ€์ƒ‰์ด ์•ˆ๋จ ๋ชจ๋“  embedded document์˜ ํ•„๋“œ๊ฐ€ ์—†์œผ๋ฉด ๊ฒ€์ƒ‰์ด ์•ˆ๋จ // ์•Œ๋งž์€ ์ฟผ๋ฆฌ db.inventory.find({size: {h:14, w:21, uom: "cm"}}) // ํ‹€๋ฆฐ ์ฟผ๋ฆฌ // ์ˆœ์„œ๊ฐ€ ๋‹ค๋ฅด๋ฉด ๊ฒ€์ƒ‰์ด ์•ˆ๋œ๋‹ค. db.inventory.find({size: {w:21, h:14, uom:"cm"}}) // ๋ชจ๋‘ ๋งค์น˜๋˜์ง€ ์•Š์œผ๋ฉด, ๊ฒ€์ƒ‰์ด ์•ˆ๋œ๋‹ค. db.inventory.find({size: {h:14, w:21}}) (”field.nestedField”) // size.uom์ด "in"์ธ ๊ฐ’๋“ค์„ ์ฐพ๋Š”๋‹ค. db.inventory.find({"size.uom": "in"}) // size... ๋”๋ณด๊ธฐ
MongoDB: ๊ธฐ๋ณธ ์ฟผ๋ฆฌ(Basic Quries) ์ด ๊ธ€์€ ์ „๊ณต "๋น…๋ฐ์ดํ„ฐ์‹œ์Šคํ…œ" ๊ฐ•์˜ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. Query Document The find() method db.COLLECTION_NAME.find(query, projection) collection๋‚ด์— ๋ชจ๋“  document๋ฅผ select db.inventory.find() db.inventory.find().pretty()SELECT * FROM inventoryQuery operator Comparison operators $eq { field : {$eq: value}} SELECT * FROM inventory WHERE qty = 25 db.inventory.find({qty:{$eq:25}}) db.inventory.find({qty:25}) $gt, $gte, $lt, $l.. ๋”๋ณด๊ธฐ
MongoDB Overview ์ด ๊ธ€์€ ์ „๊ณต "๋น…๋ฐ์ดํ„ฐ์‹œ์Šคํ…œ" ๊ฐ•์˜ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. MongoDB ํ•˜๋‚˜์˜ Collection์ด ์—ฌ๋Ÿฌ document๋ฅผ ๋ณด๊ด€ํ•  ์ˆ˜ ์žˆ๋Š” Document Database Relationship of RDBMS terminology with MongoDB RDBMS MongoDB Database Database Table Collection Tuple/Row Document column field Table Join Embedded Documents Primary Key Primary Key(Defalut Ket _id provded by mongodb it self) Mysqld/Oracle mongod mysql/sqlplus mongo RDBMS์—์„œ๋Š” 3๊ฐœ์˜ ํ…Œ์ด๋ธ”์ด ํ•„์š”ํ•˜์ง€๋งŒ, MongoDB.. ๋”๋ณด๊ธฐ
Big Data Storage ์ด ๊ธ€์€ ์ „๊ณต "๋น…๋ฐ์ดํ„ฐ์‹œ์Šคํ…œ" ๊ฐ•์˜ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. Centralized Storage Data is stored on the database of one single machine Relational databases Allows related data to be stored across multiple tables, and linked by establishing a relationship between the tables ⇒ ๋‹ค์ˆ˜์˜ ํ…Œ์ด๋ธ”์— ์—ฐ๊ด€๋œ data๋ฅผ ์ €์žฅํ•˜๊ณ , ํ…Œ์ด๋ธ”๋“ค๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ์„ค์ •ํ•˜์—ฌ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค. Inflexible - ์ฃผ๋กœ structured data์— ์ ํ•ฉํ•˜๊ณ  ๋‹ค๋ฅธ ํƒ€์ž…์— ๋Œ€ํ•ด ์œ ์—ฐ์„ฑ์ด ์—†๋‹ค. Velocity - ๋น ๋ฅด๊ฒŒ ์ฆ๊ฐ€ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ณด๋‹จ ์ •์ ์ธ ๋ฐ์ดํ„ฐ๋ฅผ ์œ„ํ•ด ์„ค๊ณ„๋˜.. ๋”๋ณด๊ธฐ