New Relic
KEDA는 New Relic 메트릭을 기준으로 워크로드를 스케일링할 수 있어요. new-relic 트리거는 NRQL 쿼리로 조회한 값을 임계값과 비교해 자동으로 확장/축소한다고 이해하시면 돼요.
출처: 문서
본문
트리거 사양 (Trigger Specification)
이 사양은 New Relic 메트릭을 기반으로 스케일링하는 new-relic 트리거를 설명해요.
triggers:
- type: new-relic
metadata:
# Required: Account - Subaccount to run the query on
account: '1234567'
# Required: QueryKey - Api key to connect to New Relic
queryKey: "NRAK-xxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Optional: nrRegion - Region to query data for. Default value is US.
region: "US"
# Optional: noDataError - If the query returns no data should this be treated as an error. Default value is false.
noDataError: "true"
# Required: nrql
nrql: "SELECT average(duration) from Transaction where appName='SITE'"
# Required: threshold
threshold: "50.50"
# Optional: activationThreshold - Target value for activating the scaler.
activationThreshold: "20.1"
파라미터 목록은 다음과 같아요.
account- 요청을 보낼 New Relic 내의 계정(account)이에요.queryKey- New Relic에 연결하고 요청을 보내는 데 사용하는 API 키예요. 공식 문서.region- New Relic API에 연결할 리전이에요. (값:LOCAL,EU,STAGING,US, 기본값:US, 선택 사항)noDataError- 데이터가 없는(nodata) 결과가 반환되는 쿼리를 오류로 처리할지 여부예요.false로 설정하고 쿼리가 nodata를 반환하면 결과는 0이 돼요. (값:true,false, 기본값:false, 선택 사항)nrql- 요청한 데이터를 가져오기 위해 실행할 New Relic 쿼리예요. 참고: New Relic 쿼리의 기본 시간 범위는 지난 30분이라 예상치 못한 응답이 나올 수 있어요.TIMESERIES쿼리의 동작을 흉내 내려면 범위를 1분으로 줄여야 하는데, 쿼리에SINCE 1 MINUTE AGO를 추가하면 돼요. 공식 문서. 공식 문서.threshold- HPA 구성에서targetValue또는targetAverageValue(트리거 메트릭 유형에 따라 다름)로 사용되는 임계값이에요. (이 값은 float일 수 있어요.)activationThreshold- 스케일러를 활성화하기 위한 목표 값이에요. activation에 대해 더 알아보려면 여기를 참고하세요. (기본값: 0, 선택 사항, 이 값은 float일 수 있어요.)
인증 파라미터 (Authentication Parameters)
TriggerAuthentication CRD를 사용해 queryKey로 인증을 구성할 수 있어요.
인증:
queryKey- New Relic에 연결하고 요청을 보내는 데 사용하는 API 키예요. 공식 문서.account- 요청을 보낼 New Relic 내의 계정이에요. 트리거에 제공되는 값을 대체하는 데 사용할 수 있어요.region- New Relic API에 연결할 리전이에요. 트리거에 제공되는 값을 대체하는 데 사용할 수 있어요.
예시 (Example)
트랜잭션 평균 지속 시간 메트릭을 기준으로 하는 오토스케일링 트리거:
apiVersion: v1
kind: Secret
metadata:
name: new-relic-secret
namespace: my-project
type: Opaque
data:
apiKey: TlJBSy...Nwo= # base64 encoding of the new relic api key NRAK-12345678901234567
account: MTIzNDU2 # base64 encoding of the new relic account number 123456
region: VVM= # base64 encoding of the new relic region US
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-new-relic
namespace: my-project
spec:
secretTargetRef:
- parameter: queryKey
name: new-relic-secret
key: apiKey
- parameter: account
name: new-relic-secret
key: account
- parameter: region
name: new-relic-secret
key: region
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: newrelic-scaledobject
namespace: keda
spec:
maxReplicaCount: 12
scaleTargetRef:
name: dummy
triggers:
- type: new-relic
metadata:
nrql: "SELECT average(duration) from Transaction where appName='SITE'"
noDataError: "true"
threshold: '1000'
authenticationRef:
name: keda-trigger-auth-new-relic
트랜잭션 카운트율(rate) 메트릭을 기준으로 하는 오토스케일링 트리거:
apiVersion: v1
kind: Secret
metadata:
name: new-relic-secret
namespace: my-project
type: Opaque
data:
apiKey: TlJBSy...Nwo= # base64 encoding of the new relic api key NRAK-12345678901234567
account: MTIzNDU2 # base64 encoding of the new relic account number 123456
region: VVM= # base64 encoding of the new relic region US
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-new-relic
namespace: my-project
spec:
secretTargetRef:
- parameter: queryKey
name: new-relic-secret
key: apiKey
- parameter: account
name: new-relic-secret
key: account
- parameter: region
name: new-relic-secret
key: region
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: newrelic-scaledobject
namespace: keda
spec:
maxReplicaCount: 12
scaleTargetRef:
name: dummy
triggers:
- type: new-relic
metadata:
nrql: "SELECT rate(count(*), 10 SECOND) FROM Transaction WHERE appName='SITE' SINCE 1 MINUTE AGO"
noDataError: "true"
threshold: '300'
authenticationRef:
name: keda-trigger-auth-new-relic
더 알아보기 (Learn more)
new-relic 트리거는 NRQL 쿼리로 원하는 메트릭을 뽑아 그 값을 임계값과 비교해 스케일링해요. 쿼리 시간 범위에 유의하고(SINCE 1 MINUTE AGO 활용), 임계값과 activationThreshold를 잘 설정하면 안정적으로 활용할 수 있답니다.