switch 문을 사용하여 이전 단계의 데이터를 기반으로 결정을 내리세요.
switch 문이 가능하게 하는 것:
- 조건에 따라 의사결정 트리를 생성합니다.
- 데이터 값에 따라 라우팅 실행을 여러 단계로 나눕니다.
- 여러 조건을 순차적으로 평가합니다.
- 조건이 일치하지 않을 때의 기본 동작을 정의합니다.
데이터를 사용한 조건 논리
steps: - name: checkCPU type: action action: newrelic.nerdgraph.execute version: 1 # ... query configuration
- name: decideAction type: switch switch: - condition: "${{ .steps.checkCPU.outputs.data.actor.account.nrql.results[0].average > 90 }}" next: resizeInstance - condition: "${{ .steps.checkCPU.outputs.data.actor.account.nrql.results[0].average > 70 }}" next: sendWarning next: normalOperation
- name: resizeInstance type: action action: aws.ec2.modifyInstanceAttribute version: 1 # ... resize configuration
- name: sendWarning type: action action: slack.chat.postMessage version: 1 # ... warning message
- name: normalOperation type: action action: newrelic.ingest.sendLogs version: 1 # ... log normal status