Is there an easy way to send a slack alert when my...
# ask-community
Is there an easy way to send a slack alert when my dbt jobs give warnings? I can of course run the tests again, setting it to fail instead, but this feels a bit wrong - I’d much rather have more fine grained control over this (maybe a different message on warnings vs failure, maybe a different channel, etc)
hi @Huib Keemink! there's not a built-in way to do this, but if you're using the dbt_test_op, then you could create a slack_alert_op that's downstream of that. The object produced by dbt_test_op is a DbtCliOutput, and the
field should give you enough parsed test result information to create a slack message and send it to whichever channel makes sense, using the slack resource:
We’re not, unfortunately… We’re using the new asset-based route, with the build option. Is there an easy way to get the output from that?
ah I see -- there's no built-in way to do that on that end either. We're looking into ways of making the body of the SDA operation a bit more flexible, but the easiest thing to do for now might be to create your own dbt_cli_resource that overrides the default build() behavior. that would look something like a copy/paste of dbt_cli_resource, which instead returns a CustomDbtCliResource, where CustomDbtCliResource just inherits from DbtCliResource and overrides the build() method:
Copy code
class CustomDbtCliResource(DbtCliResource):
    def build(self, select: Optional[List[str]] = None, **kwargs) -> DbtCliOutput:
        result = self.cli("build", select=select, **kwargs)
        # ... do some slack stuff based on the result
        return result
Cool, thanks, I’ll give that a try 🙂