https://prefect.io logo
#prefect-community
Title
# prefect-community
a

Andres

05/12/2022, 12:43 PM
HI Guys, I need help with a
dbtShellTask
. The issue I have is that I have a handler which sends notifications with details on the failing flows but when dbt task fails with return code 1, all i get is
'Command failed with exit code 1'
is there a way to capture in a variable the logs of a failed shell task to then process them and display them using the handler?
a

alex

05/12/2022, 12:45 PM
Hey @Andres! Since
DbtShellTask
subclasses
ShellTask
, I believe that you can use the
steam_output
option to log the output of the command that you’re running. Here’s a link to the
ShellTask
docs for more info: https://docs.prefect.io/api/latest/tasks/shell.html#shelltask.
🙏 1
a

Anna Geller

05/12/2022, 1:06 PM
We have quite a lot of resources about dbt collected under the dbt tag on Discourse if you are interested, e.g. this post dives deeper into it, but you can use those two arguments to capture logs and stdout from dbt runs:
Copy code
dbt = DbtShellTask(
    return_all=True,
    log_stdout=True, ...)
specifically to capture errors, you may add:
log_stderr=True
a

Andres

05/12/2022, 1:29 PM
my bad, I missed that the exception contains the logs on the result variable
👍 1
7 Views