# log results in on-run-end hook only when dbt run is executed.

**URL:** <https://discourse.getdbt.com/t/log-results-in-on-run-end-hook-only-when-dbt-run-is-executed/11981>\
**Category:** Help\
**Created:** [February 9, 2024, 5:41pm UTC](https://discourse.getdbt.com/t/log-results-in-on-run-end-hook-only-when-dbt-run-is-executed/11981 "2024-02-09T17:41:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![datajake](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@datajake](https://discourse.getdbt.com/u/datajake)\
**Post date:** [February 9, 2024, 5:41pm UTC](https://discourse.getdbt.com/t/log-results-in-on-run-end-hook-only-when-dbt-run-is-executed/11981/1 "2024-02-09T17:41:21Z")

</div>

## The problem I’m having

Right now, we are logging metadata about the run using the on-run-end hook, the issue is that no matter what command is ran (dbt seed, dbt, snapshot) the on-run-end executes. Is there a way to add a condition so that the run only gets logged if it’s ‘dbt run’ and not snapshot, seed, or anything else?

## current on-run-end command

```auto
on-run-end:
  - "{% if target.name == 'prod' %}{{ dbt_artifacts.upload_results(results) }}{% endif %}"

```

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [February 9, 2024, 6:21pm UTC](https://discourse.getdbt.com/t/log-results-in-on-run-end-hook-only-when-dbt-run-is-executed/11981/2 "2024-02-09T18:21:33Z")

</div>

You could try using `invocation_args_dict.which`

Something like

```auto
on-run-end:
  - "{% if target.name == 'prod' and invocation_args_dict.which == 'run' %}{{ dbt_artifacts.upload_results(results) }}{% endif %}"

```

---

<div class="post-metadata">

**Author:** ![hvignolo](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/hvignolo/32/3605_2.png) [@hvignolo](https://discourse.getdbt.com/u/hvignolo)\
**Post date:** [February 9, 2024, 8:56pm UTC](https://discourse.getdbt.com/t/log-results-in-on-run-end-hook-only-when-dbt-run-is-executed/11981/3 "2024-02-09T20:56:24Z")

</div>

I’m curious if a similar behavior can be achieved using the `execute` variable 🤔
