# Custom\_metrics not reporting as expected

**URL:** <https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059>\
**Category:** RLlib\
**Created:** [March 1, 2021, 5:47pm UTC](https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059 "2021-03-01T17:47:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![albheim](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@albheim](https://discuss.ray.io/u/albheim)\
**Post date:** [March 1, 2021, 5:47pm UTC](https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059/1 "2021-03-01T17:47:04Z")

</div>

So I use `custom_metrics` to log some environment information each step, but I have noticed it does not show the values I expect.

For example I have one value I log that only ever take the value 0 or 1, but in the logging it shows a mean value of between 2-10 which should not be possible. I currently log each step with the callback `on_episode_step` and run it in a continuing environment with `soft_horizon=True` and `horizon=1000`.

I assumed it might be something with the horizon being 1000 long (though I really thought that would be what we had the min/max/mean from) and also tried `horizon=1` with similar results.

How does the metric logging work and what is it that I’m misunderstanding here?

---

<div class="post-metadata">

**Author:** ![rliaw](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/rliaw/32/24_2.png) [@rliaw](https://discuss.ray.io/u/rliaw)\
**Post date:** [March 2, 2021, 5:37am UTC](https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059/2 "2021-03-02T05:37:03Z")

</div>

Hey @sven1977 what are your thoughts here?

---

<div class="post-metadata">

**Author:** ![sven1977](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sven1977/32/53_2.png) [@sven1977](https://discuss.ray.io/u/sven1977)\
**Post date:** [March 2, 2021, 9:47am UTC](https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059/3 "2021-03-02T09:47:35Z")

</div>

Hey @albheim, thanks for raising this issue.  
That’s indeed strange. If you are certain that your env does not produce values outside 0 and 1, could you maybe try to reproduce this issue in a small, self-sufficient script so I can debug this?

---

<div class="post-metadata">

**Author:** ![albheim](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@albheim](https://discuss.ray.io/u/albheim)\
**Post date:** [March 2, 2021, 10:58am UTC](https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059/4 "2021-03-02T10:58:48Z")

</div>

Yeah, as everyone probably expected this was an error on my side 😅

Logged both the variable (if a certain job was dropped or not) and the cost of dropping that job (for later use in the reward function). The cost was currently set to 10 and so it nicely rescaled the interval 0-1 to 0-10 and made me confused when I looked at the logged value dropped cost instead of the dropped state. I thought I must have misunderstood something about how ray aggregated metrics and all of that, but it all worked as I initially assumed.

Thanks for the help and sorry for taking up your time 🙂

---

<div class="post-metadata">

**Author:** ![sven1977](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sven1977/32/53_2.png) [@sven1977](https://discuss.ray.io/u/sven1977)\
**Post date:** [March 3, 2021, 9:41am UTC](https://discuss.ray.io/t/custom-metrics-not-reporting-as-expected/1059/5 "2021-03-03T09:41:40Z")

</div>

Awesome, no worries 🙂 Thanks for getting back to us and clarifying!
