テンプレート構文を使用して前のステップからの出力を参照し、アクションを連結して複雑な自動化を構築します。
要件:
- 適切な権限を持つNew Relicアカウント
- 適切な権限を持つSlackワークスペース
- ワークフロー自動化でシークレットとして設定された Slack ボット トークン
- メッセージが送信されるSlackチャンネルへのアクセス
基本的なデータの受け渡し
New Relicから発行された問題をまとめて、アクティブな問題ごとに Slack に通知を送信します。
このワークフローの機能:
- NerdGraph を実行してアクティブな集計号を取得します
- 各集計号をループする
- 問題の詳細を記載した各問題についてSlack通知を送信します
name: alertSlack description: "query Alert Issues and send notifications to Slack"
workflowInputs: accountId: type: Int
steps: - name: getAlert type: action action: newrelic.nerdgraph.execute version: 1 inputs: graphql: | query GetAlertIssues($accountId: Int!) { actor { account(id: $accountId) { aiIssues { issues(filter: {states: ACTIVATED}) { issues { issueId priority state title } } } } } } variables: accountId: ${{ .workflowInputs.accountId }}
- name: loopStep type: loop for: in: ${{ .steps.getAlert.outputs.data.actor.account.aiIssues.issues.issues }} steps: - name: sendToSlack type: action action: slack.chat.postMessage version: 1 inputs: token: ${{ :secrets:your_slack_token }} channel: incident-channel text: > issueId: ${{ .steps.loopStep.loop.element.issueId }} priority: ${{ .steps.loopStep.loop.element.priority }} state: ${{ .steps.loopStep.loop.element.state }} title: ${{ .steps.loopStep.loop.element.title | tostring }}キーアクション: newrelic.nerdgraph.execute 、 slack.chat.postMessage