Amberflo.io API 미터링: Amberflo 플러그인 활성화
Amberflo.io API 미터링: Amberflo 플러그인 활성화 (Amberflo.io API Metering: Enable the Amberflo plugin)
이 문서는 Kong에서 Amberflo.io 미터링 플러그인을 활성화하는 방법을 단계별로 안내해요. 시작하기 전에 Amberflo.io API 키가 있고 플러그인이 설치되어 있어야 한다는 점을 먼저 확인해요. 이후 decK, Admin API, Kubernetes Ingress Controller 등 다양한 방식으로 글로벌 또는 서비스 단위에 플러그인을 설정하는 예시를 소개해요
출처: 문서
본문
Amberflo 플러그인 활성화하기 v3.0+
Amberflo.io 미터링 플러그인을 활성화해요.
사전 요구 사항
환경 변수
API_KEY: 여러분의 Amberflo API 키
플러그인 설정하기
전역
decK
다음 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: amberflo
config:
apiKey: ${{ env "DECK_API_KEY" }}
meterApiName: kong-api-calls
customerHeader: x-consumer-username
methodDimension: method
hostDimension: host
routeDimension: route
serviceDimension: service
{: data-file="kong.yaml" data-tool="deck" }
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "amberflo",
"config": {
"apiKey": "'$API_KEY'",
"meterApiName": "kong-api-calls",
"customerHeader": "x-consumer-username",
"methodDimension": "method",
"hostDimension": "host",
"routeDimension": "route",
"serviceDimension": "service"
}
}
'
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
labels:
global: 'true'
config:
apiKey: '$API_KEY'
meterApiName: kong-api-calls
customerHeader: x-consumer-username
methodDimension: method
hostDimension: host
routeDimension: route
serviceDimension: service
plugin: amberflo
" | kubectl apply -f -
서비스
decK
다음 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: amberflo
service: serviceName|Id
config:
apiKey: ${{ env "DECK_API_KEY" }}
meterApiName: kong-api-calls
customerHeader: x-consumer-username
methodDimension: method
hostDimension: host
routeDimension: route
serviceDimension: service
{: data-file="kong.yaml" data-tool="deck" }
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
serviceName|Id: 플러그인 설정이 대상으로 지정할 서비스의id또는name이에요.
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/services/{serviceName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "amberflo",
"config": {
"apiKey": "'$API_KEY'",
"meterApiName": "kong-api-calls",
"customerHeader": "x-consumer-username",
"methodDimension": "method",
"hostDimension": "host",
"routeDimension": "route",
"serviceDimension": "service"
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
serviceName|Id: 플러그인 설정이 대상으로 지정할 서비스의id또는name이에요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
apiKey: '$API_KEY'
meterApiName: kong-api-calls
customerHeader: x-consumer-username
methodDimension: method
hostDimension: host
routeDimension: route
serviceDimension: service
plugin: amberflo
" | kubectl apply -f -
다음으로, service 리소스에 어노테이션을 붙여서 KongPlugin 리소스를 적용하세요:
kubectl annotate -n kong service SERVICE_NAME konghq.com/plugins=
라우트
decK
다음 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: amberflo
route: routeName|Id
config:
apiKey: ${{ env "DECK_API_KEY" }}
meterApiName: kong-api-calls
customerHeader: x-consumer-username
methodDimension: method
hostDimension: host
routeDimension: route
serviceDimension: service
{: data-file="kong.yaml" data-tool="deck" }
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
routeName|Id: 플러그인 설정이 대상으로 지정할 라우트의id또는name이에요.
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/routes/{routeName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "amberflo",
"config": {
"apiKey": "'$API_KEY'",
"meterApiName": "kong-api-calls",
"customerHeader": "x-consumer-username",
"methodDimension": "method",
"hostDimension": "host",
"routeDimension": "route",
"serviceDimension": "service"
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
routeName|Id: 플러그인 설정이 대상으로 지정할 라우트의id또는name이에요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
apiKey: '$API_KEY'
meterApiName: kong-api-calls
customerHeader: x-consumer-username
methodDimension: method
hostDimension: host
routeDimension: route
serviceDimension: service
plugin: amberflo
" | kubectl apply -f -
다음으로, httproute 또는 ingress 리소스에 어노테이션을 붙여서 KongPlugin 리소스를 적용하세요:
Gateway API
kubectl annotate -n kong httproute konghq.com/plugins=
Ingress
kubectl annotate -n kong ingress konghq.com/plugins=