Skip to content

Commit 83bf2e8

Browse files
authored
add comare_workflow_task sample to monitoring/app (#405)
* add comare_workflow_task sample to monitoring/app
1 parent 0ee80ba commit 83bf2e8

File tree

11 files changed

+134
-0
lines changed

11 files changed

+134
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Workflow: Scenario (compare tasks's duration in workflow between multiple attempts)
2+
3+
## Scenario
4+
5+
The purpose of this scenario is to compare tasks's duration in workflow between multiple attemps.
6+
7+
### Steps
8+
#### 1. push this workflow to Treasure Data
9+
```
10+
> cd compare_workflow_task
11+
> td push compare_workflow_task
12+
```
13+
14+
#### 2. configure endpoint settings
15+
- api_endpoint
16+
- workflow_endpoint
17+
![](images/1.png)
18+
19+
#### 3. configure attempts (you want to compare attempt)
20+
![](images/2.png)
21+
22+
#### 4. register td.apikey as a secret (Owner of td.apikey must be attempts which you specify.)
23+
![](images/3.png)
24+
25+
#### 5. run workflow
26+
![](images/4.png)
27+
28+
29+
After this workflow run, you can get the following query result.
30+
![](images/5.png)
31+
32+
![](images/6.png)
33+
34+
You can compare tasks's duration between multiple attempts.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
_export:
2+
td:
3+
database: temporary_${session_id}
4+
tables:
5+
tasks: tasks
6+
api_endpoint: api.treasuredata.com
7+
workflow_endpoint: api-workflow.treasuredata.com
8+
attempt_ids:
9+
- 1201247649
10+
- 1200176632
11+
- 1199185996
12+
13+
+create_temporary_db:
14+
td_ddl>:
15+
create_databases: ["${td.database}"]
16+
17+
+get_attempt_task:
18+
py>: scripts.ingest_task.run
19+
session_unixtime: ${session_unixtime}
20+
dest_db: ${td.database}
21+
dest_table: ${td.tables.tasks}
22+
attempt_ids: ${attempt_ids.join(',')}
23+
api_endpoint: ${td.api_endpoint}
24+
workflow_endpoint: ${td.workflow_endpoint}
25+
docker:
26+
image: "digdag/digdag-python:3.9"
27+
_env:
28+
TD_API_KEY: ${secret:td.apikey}
29+
30+
+gen_query:
31+
td>: queries/gen_query.sql
32+
store_last_results: true
33+
34+
+compare_task:
35+
td>: queries/compare_task.sql
36+
37+
+delete_temporary_db:
38+
td_ddl>:
39+
drop_databases: ["${td.database}"]
40+
41+
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
select
2+
fullname as task_name,
3+
${td.last_results.query}
4+
from ${td.tables.tasks}
5+
group by 1
6+
order by max(id)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
with temp1 as (
2+
select 'max(If(attemptid=''' || attemptid || ''', DATE_DIFF(''second'', DATE_PARSE(startedat, ''%Y-%m-%dT%H:%i:%sZ''), DATE_PARSE(updatedat, ''%Y-%m-%dT%H:%i:%sZ'')), NULL)) as "' || attemptid || '"' as query_fragment from ${td.tables.tasks}
3+
group by 1
4+
)
5+
select array_join(array_agg(query_fragment), ',') as query from temp1

0 commit comments

Comments
 (0)