This example workflow notifies the results of of Treasure Data Query to Slack.
This workflow sends notifications of calculated data from Treasure Data to Slack, using an http operator. The workflow makes use of Slack Incoming Webhooks. For example, you could add:
https://hooks.slack.com/services/xxx/yyy/zzz
Where 'xxxx', ' yyyy', and 'zzz' are the relevant URL details for your Slack account.
The workflow features a task that includes saves query results by setting the store_last_results parameter to true.
+task1:
td>:
query: |
SELECT
TD_TIME_FORMAT(time, 'yyyy-MM-dd', 'JST') as day,
COUNT(1) AS PV
FROM
www_access
WHERE
TD_TIME_RANGE(time, TD_TIME_ADD(TD_DATE_TRUNC('day',${session_unixtime}, 'JST'), '-1d', 'JST'), NULL, 'JST')
GROUP BY 1
ORDER BY 1 DESC
store_last_results: true
The workflow also features a task that uses the http operator to post the results to a Slack URL:
+task2:
http>: https://hooks.slack.com/services/xxxxx/yyyyy/zzzzzzzzzzzzzz
method: POST
content:
username: "Workflow bot"
channel: "#slackroom" # Or, @xxxx
text: |
The query result at ${session_date} is https://console.treasuredata.com/app/jobs/${td.last_job_id}.
The first 1 row of the result is ${td.last_results}.
content_format: json
Galleries
Use-Cases
- Workflow Monitoring
- Query and Workflow Error Monitoring