KVS(ํค-๊ฐ ์ ์ฅ์) API ๊ฐ์ด๋ (v2.0)
GIIP ํ๋ซํผ์ ์ ์ฐํ ๋ฐ์ดํฐ ์ ์ฅ์์ธ KVS(Key-Value Store)๋ฅผ ํตํด ์ธํ๋ผ ์ํ ๋ฐ์ดํฐ(factor)๋ฅผ ๊ธฐ๋กํ๊ณ ์กฐํํ๋ ์ ์ฒด API๋ฅผ ์ค๋ช ํฉ๋๋ค.
๐ ๊ฐ์
KVS๋ ์์ด์ ํธ๊ฐ ์์งํ ์ฑ๋ฅ ๋ฉํธ๋ฆญ, ๋คํธ์ํฌ ์ฐ๊ฒฐ ์ ๋ณด, ์ธ๋ฒคํ ๋ฆฌ, ํ๋ก์ธ์ค ๋ชฉ๋ก ๋ฑ ๋ค์ํ ์๊ณ์ด ๋ฐ ์ ํ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ๋ฒ์ฉ ํค-๊ฐ ์ ์ฅ์์ ๋๋ค.
| API | ์ญํ | ์ธ์ฆ ๋ฐฉ์ | ์๋ํฌ์ธํธ |
|---|---|---|---|
| KVSPut | ๋ฐ์ดํฐ ๊ธฐ๋ก(์ฐ๊ธฐ) | Body token ํ๋ (SK) | giipApiSk2 / giipApiSk3 |
| KVSFactorLast | ์ต์ ๋ฐ์ดํฐ 1๊ฑด ์กฐํ | AK ํค๋ ๋๋ Body token (SK) | giipApi(AK) / giipApiSk2(SK) |
| KVSFactorList | ์ด๋ ฅ ๋ชฉ๋ก ์กฐํ | x-giip-ak / x-giip-sk ํค๋ | giipApi |
๐ ์์ ์ ์ค๋น๋ฌผ
KVS API๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ค์ ๋ ๊ฐ์ง๊ฐ ํ์ํฉ๋๋ค.
1. SK (Secret Key)
giipAgent.cfg ํ์ผ์ sk ํ๋ ๊ฐ์
๋๋ค. KVSPut ์์ฒญ ์ Body์ token ํ๋๋ก ์ ๋ฌํฉ๋๋ค.
์ทจ๋ ๋ฐฉ๋ฒ: GIIP ๊ด๋ฆฌ ํ๋ฉด์
lsvrdetail(์๋ฒ ์์ธ) ๋๋corpgroup(๋ฒ์ธยท๊ทธ๋ฃน ๊ด๋ฆฌ) ํ์ด์ง์์ ํ์ธํ ์ ์์ต๋๋ค.
// giipAgent.cfg ์์
{
"sk": "your-secret-key-here"
}
2. LSSN (์๋ฒ ์๋ณ ๋ฒํธ)
tLSvr.LSsn ์ปฌ๋ผ ๊ฐ์
๋๋ค. kType์ด "lssn"์ผ ๋ kKey๋ก ์ฌ์ฉํฉ๋๋ค.
SK ๋ฐ๊ธ ๋ฐ LSSN ํ์ธ ๋ฐฉ๋ฒ์ ๋คํธ์ํฌ ํ ํด๋ก์ง API ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์.
โ๏ธ KVSPut โ ๋ฐ์ดํฐ ๊ธฐ๋กํ๊ธฐ
๊ฐ๋
KVSPut์ ์์ด์ ํธ๊ฐ ์์งํ ๋ฐ์ดํฐ๋ฅผ KVS์ ์ ์ฅํ๋ ์ฐ๊ธฐ API์
๋๋ค. kType + kKey + kFactor์ ์กฐํฉ์ผ๋ก ์ ์ฅ ์์น๋ฅผ ์ง์ ํ๊ณ , kValue์ ์ค์ ๋ฐ์ดํฐ๋ฅผ ๋ด์ต๋๋ค.
์์ฒญ ๊ตฌ์กฐ
- ์๋ํฌ์ธํธ:
POST https://YOUR_API_URL/api/giipApiSk2(๋๋giipApiSk3) - Content-Type:
application/x-www-form-urlencoded
| Body ํ๋ | ํ์ | ์ค๋ช |
|---|---|---|
token | โ | SK ๊ฐ (giipAgent.cfg์ sk) |
text | โ | ๋ฆฌํฐ๋ด ๋ฌธ์์ด: KVSPut kType kKey kFactor kValue (๋ณ์ ์๋, ์ด ๊ทธ๋๋ก ์ ์ก) |
jsondata | โ | JSON ๋ฌธ์์ด: {"kType":"...","kKey":"...","kFactor":"...","kValue":...} |
์ฃผ์:
textํ๋์ ๊ฐ์KVSPut kType kKey kFactor kValue๋ผ๋ ๊ณ ์ ๋ฌธ์์ด ๊ทธ๋๋ก ์ ์กํฉ๋๋ค. ์ค์ ๋ฐ์ดํฐ ์๋ณ์๋ ๋ชจ๋jsondata์์ ๋ค์ด๊ฐ๋๋ค.
jsondata ํ๋ ์ค๋ช
| ํ๋ | ํ์ | ์ค๋ช | ์์ |
|---|---|---|---|
kType | string | ํค ์ ํ ("lssn" ๋๋ "database") | "lssn" |
kKey | string | ์๋ฒ LSSN ๋๋ DB ID (๋ฐ๋์ ์ซ์ํ ๋ฌธ์์ด) | "123456" |
kFactor | string | ๋ฐ์ดํฐ ๋ถ๋ฅ ์นดํ ๊ณ ๋ฆฌ๋ช | "netstat" |
kValue | any | ์ค์ ์ ์ฅํ ๋ฐ์ดํฐ (JSON ๋ฐฐ์ด ๋๋ ๊ฐ์ฒด) | [{...}] |
kType / kKey ๊ท์น
| kType | ์๋ฏธ | kKey ๊ฐ |
|---|---|---|
"lssn" | ์๋ฒ ๋จ์ ๋ฐ์ดํฐ | tLSvr.LSsn ์ปฌ๋ผ ๊ฐ (์ซ์ ๋ฌธ์์ด) |
"database" | DB ๋จ์ ๋ฐ์ดํฐ | tManagedDatabase.mdb_id ์ปฌ๋ผ ๊ฐ (์ซ์ ๋ฌธ์์ด) |
kKey๋ ๋ฐ๋์ ์ซ์ํ ๋ฌธ์์ด์ด์ด์ผ ํฉ๋๋ค. ํธ์คํธ๋ช (
"myserver")์ด๋ UUID("abc-123-...")๋ ํ์ฉ๋์ง ์์ต๋๋ค.
์ฃผ์ kFactor ๋ชฉ๋ก
| kFactor | ์ค๋ช | kValue ํ์ |
|---|---|---|
netstat | ์๋ฒ ๊ฐ TCP ์ฐ๊ฒฐ ์ ๋ณด | [{remote_ip, remote_port, process_name, state}] |
db_connections | DB ์ฐ๊ฒฐ ์ ๋ณด | [{client_net_address, program_name, cpu_load, last_sql}] |
heartbeat | ์์ด์ ํธ ์์กด ์ ํธ | {"status":"alive","timestamp":"..."} |
netinv | ์๋ฒ ์ธ๋ฒคํ ๋ฆฌ | {hostname, os, cpu_cores, ipv4_local} |
processlist | ์คํ ํ๋ก์ธ์ค ๋ชฉ๋ก | [{pid, name, cpu_percent, memory_mb}] |
custom_factor | ์ฌ์ฉ์ ์ ์ ๋ฐ์ดํฐ | ์์ ํ์ JSON |
์ฝ๋ ์์
์๋ ์์๋ LSSN 123456 ์๋ฒ์ netstat ๋ฐ์ดํฐ๋ฅผ KVS์ ๊ธฐ๋กํฉ๋๋ค. YOUR_API_URL๊ณผ YOUR_SK๋ฅผ ์ค์ ๊ฐ์ผ๋ก ๊ต์ฒดํ์ธ์.
curl
curl -X POST "https://YOUR_API_URL/api/giipApiSk2" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "token=YOUR_SK" \
--data-urlencode "text=KVSPut kType kKey kFactor kValue" \
--data-urlencode 'jsondata={"kType":"lssn","kKey":"123456","kFactor":"netstat","kValue":[{"remote_ip":"10.0.0.5","remote_port":5432,"process_name":"python","state":"ESTABLISHED"}]}'
PowerShell
$body = @{
token = "YOUR_SK"
text = "KVSPut kType kKey kFactor kValue"
jsondata = '{"kType":"lssn","kKey":"123456","kFactor":"netstat","kValue":[{"remote_ip":"10.0.0.5","remote_port":5432,"process_name":"python","state":"ESTABLISHED"}]}'
}
$response = Invoke-RestMethod `
-Method Post `
-Uri "https://YOUR_API_URL/api/giipApiSk2" `
-ContentType "application/x-www-form-urlencoded" `
-Body $body
$response | ConvertTo-Json
Bash
SK="YOUR_SK"
API_URL="https://YOUR_API_URL/api/giipApiSk2"
LSSN="123456"
JSONDATA=$(cat <<'EOF'
{
"kType": "lssn",
"kKey": "123456",
"kFactor": "netstat",
"kValue": [
{
"remote_ip": "10.0.0.5",
"remote_port": 5432,
"process_name": "python",
"state": "ESTABLISHED"
}
]
}
EOF
)
curl -X POST "$API_URL" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "token=$SK" \
--data-urlencode "text=KVSPut kType kKey kFactor kValue" \
--data-urlencode "jsondata=$JSONDATA"
Python
import requests
import json
API_URL = "https://YOUR_API_URL/api/giipApiSk2"
SK = "YOUR_SK"
kv_data = {
"kType": "lssn",
"kKey": "123456",
"kFactor": "netstat",
"kValue": [
{
"remote_ip": "10.0.0.5",
"remote_port": 5432,
"process_name": "python",
"state": "ESTABLISHED"
}
]
}
payload = {
"token": SK,
"text": "KVSPut kType kKey kFactor kValue",
"jsondata": json.dumps(kv_data)
}
response = requests.post(
API_URL,
data=payload,
headers={"Content-Type": "application/x-www-form-urlencoded"}
)
print(response.json())
์๋ต ํด์
์ฑ๊ณต ์
{
"RstVal": 200,
"RstMsg": "Success"
}
์คํจ ์์
{
"RstVal": 401,
"RstMsg": "Unauthorized"
}
์ ์ฒด ์๋ต ์ฝ๋ ๋ชฉ๋ก์ API ๊ฒฐ๊ณผ ์ฝ๋ ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์.
๐ KVSFactorLast โ ์ต์ ๋ฐ์ดํฐ ์กฐํ
ํน์ ์์ค์ ์ง์ ๋ factor์ ๋ํด ๊ฐ์ฅ ์ต๊ทผ ๊ธฐ๋ก 1๊ฑด์ ๋ฐํํฉ๋๋ค.
์ธ์ฆ
- Header:
x-giip-ak: YOUR_AK/x-giip-sk: YOUR_SK
์์ฒญ ํ์
POST https://YOUR_API_URL/api/giipApi
Content-Type: application/x-www-form-urlencoded
text=KVSFactorLast <factorType>, <lssn>, <factor>
์์
LSSN 123456 ์๋ฒ์ ์ต์ netstat ๋ฐ์ดํฐ ์กฐํ:
curl -X POST "https://YOUR_API_URL/api/giipApi" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "x-giip-ak: YOUR_AK" \
-H "x-giip-sk: YOUR_SK" \
--data-urlencode "text=KVSFactorLast lssn, 123456, netstat"
PowerShell:
$headers = @{
"x-giip-ak" = "YOUR_AK"
"x-giip-sk" = "YOUR_SK"
}
$body = @{
text = "KVSFactorLast lssn, 123456, netstat"
}
Invoke-RestMethod `
-Method Post `
-Uri "https://YOUR_API_URL/api/giipApi" `
-Headers $headers `
-ContentType "application/x-www-form-urlencoded" `
-Body $body
SK ๊ธฐ๋ฐ ์กฐํ (giipApiSk2)
AK ์์ด SK๋ง์ผ๋ก ๋์ผ ๋ฒ์ธ ๊ทธ๋ฃน(CGSn) ๋ด ์๋ฒ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ์ ์์ต๋๋ค.
curl -X POST "https://YOUR_API_URL/api/giipApiSk2" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "token=YOUR_SK" \
--data-urlencode "text=KVSFactorLast lssn, 123456, netstat"
Invoke-RestMethod `
-Method Post `
-Uri "https://YOUR_API_URL/api/giipApiSk2" `
-ContentType "application/x-www-form-urlencoded" `
-Body @{
token = "YOUR_SK"
text = "KVSFactorLast lssn, 123456, netstat"
}
๊ถํ ๋ฒ์: SK์ CGSn(๋ฒ์ธ ๊ทธ๋ฃน)์ ์ํ ์๋ฒ๋ง ์กฐํํ ์ ์์ต๋๋ค.
๐ KVSFactorList โ ์ด๋ ฅ ๋ชฉ๋ก ์กฐํ
ํน์ ์กฐ๊ฑด์ ๋ง๋ factor ๋ฐ์ดํฐ์ ์ด๋ ฅ ๋ชฉ๋ก์ ๋ฐํํฉ๋๋ค. *๋ฅผ ์ฌ์ฉํ๋ฉด ํด๋น ์์ค์ ๋ชจ๋ factor ์ด๋ ฅ์ ์กฐํํ ์ ์์ต๋๋ค.
์์ฒญ ํ์
POST https://YOUR_API_URL/api/giipApi
Content-Type: application/x-www-form-urlencoded
text=KVSFactorList <factorType>, <lssn>, <factor>
์์
LSSN 123456 ์๋ฒ์ ๋ชจ๋ factor ์ด๋ ฅ ์กฐํ:
curl -X POST "https://YOUR_API_URL/api/giipApi" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "x-giip-ak: YOUR_AK" \
-H "x-giip-sk: YOUR_SK" \
--data-urlencode "text=KVSFactorList lssn, 123456, *"
ํน์ factor(heartbeat)๋ง ์ด๋ ฅ ์กฐํ:
curl -X POST "https://YOUR_API_URL/api/giipApi" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "x-giip-ak: YOUR_AK" \
-H "x-giip-sk: YOUR_SK" \
--data-urlencode "text=KVSFactorList lssn, 123456, heartbeat"
๐ก๏ธ Sk3 ๊ณ ์ฑ๋ฅ ๋ก๊น
๋์ฉ๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋กํ๊ฑฐ๋ ๋ฐ์ดํฐ ์ ํฉ์ฑ์ด ์ค์ํ ๊ฒฝ์ฐ giipApiSk3 ์๋ํฌ์ธํธ๋ฅผ ์ฌ์ฉํ์ธ์.
- ์๋ํฌ์ธํธ:
https://giipfaw.azurewebsites.net/api/giipApiSk3 - ์ฅ์ :
- ๋๋์
jsondata์ ์ก ์ ๋ฐ์ดํฐ ์์ค ๋ฐฉ์ง - ๊ธฐ๋ก ์คํจ ์ ์์ด์ ํธ์ ์์ธ ์๋ฌ ๋ก๊ทธ(StackTrace)๋ฅผ ํจ๊ป ์ ์ฅํ์ฌ ์ ํฉ์ฑ ํ๋ณด
- ๋๋์
- ํ์ฉ ํ: KVSPut ์ฌ์ฉ ์
jsondata๋ด์kType,kKey,kFactor,kValueํ๋๋ฅผ ํฌํจํ๋ฉด Sk3 ์์ง์ด ์๋์ผ๋ก ๋งคํํ์ฌ ์์ ์ ์ผ๋ก DB์ ๊ธฐ๋กํฉ๋๋ค.
# Sk3 ์๋ํฌ์ธํธ๋ก KVSPut ํธ์ถ ์์
curl -X POST "https://giipfaw.azurewebsites.net/api/giipApiSk3" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "token=YOUR_SK" \
--data-urlencode "text=KVSPut kType kKey kFactor kValue" \
--data-urlencode 'jsondata={"kType":"lssn","kKey":"123456","kFactor":"netstat","kValue":[...]}'
๐ง ํธ๋ฌ๋ธ์ํ
KVSPut์ด 401 ์๋ต์ ๋ฐํํ๋ ๊ฒฝ์ฐ
tokenํ๋์ SK ๊ฐ์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ์ธ์.- SK๋ Header๊ฐ ์๋ Body์
tokenํ๋๋ก ์ ๋ฌํด์ผ ํฉ๋๋ค.
KVSPut์ด 400 ์๋ต์ ๋ฐํํ๋ ๊ฒฝ์ฐ
textํ๋์ ๊ฐ์ด ์ ํํKVSPut kType kKey kFactor kValue์ธ์ง ํ์ธํ์ธ์ (์ด ๋ฌธ์์ด ๊ทธ๋๋ก).jsondata๊ฐ ์ ํจํ JSON ๋ฌธ์์ด์ธ์ง ํ์ธํ์ธ์.kKey๊ฐ ์ซ์ํ ๋ฌธ์์ด("123456")์ธ์ง ํ์ธํ์ธ์. ํธ์คํธ๋ช ์ด๋ UUID๋ ํ์ฉ๋์ง ์์ต๋๋ค.
๋ฐ์ดํฐ๊ฐ ์ ์ฅ๋์๋์ง ํ์ธํ๋ ๋ฐฉ๋ฒ
KVSPut ์งํ KVSFactorLast๋ก ๋์ผํ kType/kKey/kFactor ์กฐํฉ์ ์กฐํํ๋ฉด ์ ์ฅ๋ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
# 1. ๋ฐ์ดํฐ ๊ธฐ๋ก
curl -X POST "https://YOUR_API_URL/api/giipApiSk2" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "token=YOUR_SK" \
--data-urlencode "text=KVSPut kType kKey kFactor kValue" \
--data-urlencode 'jsondata={"kType":"lssn","kKey":"123456","kFactor":"heartbeat","kValue":{"status":"alive","timestamp":"2026-06-19T10:00:00Z"}}'
# 2. ๊ธฐ๋ก ํ์ธ
curl -X POST "https://YOUR_API_URL/api/giipApi" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "x-giip-ak: YOUR_AK" \
-H "x-giip-sk: YOUR_SK" \
--data-urlencode "text=KVSFactorLast lssn, 123456, heartbeat"
KVSFactorLast / KVSFactorList๊ฐ ๋น ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ๊ฒฝ์ฐ
- ํด๋น kType/kKey/kFactor ์กฐํฉ์ผ๋ก ์ ์ฅ๋ ๋ฐ์ดํฐ๊ฐ ์๋ ๊ฒฝ์ฐ์ ๋๋ค.
- KVSPut์ผ๋ก ๋จผ์ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋กํ ํ ์กฐํํ์ธ์.
- LSSN ๋ฒํธ๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ์ธ์.
๋ฌธ์ ํด๊ฒฐ
| ์ฆ์ | ์์ธ | ํด๊ฒฐ |
|---|---|---|
| KVSPut์ด 401 ๋ฐํ | SK๋ฅผ ํค๋๋ก ์ ์กํ๊ฑฐ๋ token ๊ฐ์ด ์ฌ๋ฐ๋ฅด์ง ์์ | SK๋ฅผ Body์ token ํ๋๋ก ์ ๋ฌํ๊ณ ๊ฐ์ด ์ ํํ์ง ํ์ธ |
| KVSPut์ด 400 ๋ฐํ | text๊ฐ ๋ฆฌํฐ๋ด KVSPut kType kKey kFactor kValue์ ๋ค๋ฅด๊ฑฐ๋ jsondata๊ฐ ์ ํจํ JSON์ด ์๋ | text๋ ๊ณ ์ ๋ฌธ์์ด ๊ทธ๋๋ก ์ ์กํ๊ณ jsondata๋ฅผ ์ฌ๋ฐ๋ฅธ JSON์ผ๋ก ์ง๋ ฌํ |
| ์ ์ฅ ์คํจ ๋๋ kKey ์ค๋ฅ | kKey๊ฐ ์ซ์ํ ๋ฌธ์์ด์ด ์๋(ํธ์คํธ๋ช
ยทUUID ์ฌ์ฉ) | tLSvr.LSsn ๋ฑ ์ซ์ ๋ฌธ์์ด์ kKey๋ก ์ฌ์ฉ |
| KVSFactorLast/List๊ฐ ๋น ๊ฒฐ๊ณผ ๋ฐํ | ํด๋น kType/kKey/kFactor ๋ฐ์ดํฐ ๋ฏธ๊ธฐ๋ก ๋๋ LSSN ์ค๋ฅ | KVSPut์ผ๋ก ๋จผ์ ๊ธฐ๋กํ ๋ค ์กฐํํ๊ณ LSSN ๊ฐ์ ํ์ธ |
๋ฒ์ : 2.1
์ต์ข
์
๋ฐ์ดํธ: 2026-06-19
์์ค ํ์ผ: giipv3/public/help/api-kvs.ko.md
๊ด๋ จ ๋ฌธ์:
- ๋คํธ์ํฌ ํ ํด๋ก์ง API ๊ฐ์ด๋ โ SK ๋ฐ๊ธ ๋ฐ LSSN ํ์ธ ๋ฐฉ๋ฒ
- API ๊ฒฐ๊ณผ ์ฝ๋ ๊ฐ์ด๋ (RstVal)