# Kibana's "average" aggregation display time is showing the time wrong

**URL:** <https://discuss.elastic.co/t/kibanas-average-aggregation-display-time-is-showing-the-time-wrong/344333>\
**Category:** Kibana\
**Created:** [October 3, 2023, 6:03pm UTC](https://discuss.elastic.co/t/kibanas-average-aggregation-display-time-is-showing-the-time-wrong/344333 "2023-10-03T18:03:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skimifil](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Skimifil](https://discuss.elastic.co/u/Skimifil)\
**Post date:** [October 3, 2023, 6:03pm UTC](https://discuss.elastic.co/t/kibanas-average-aggregation-display-time-is-showing-the-time-wrong/344333/1 "2023-10-03T18:03:28Z")

</div>

I have a pipeline that processes a field, whose value comes in the format "HH:MM:SS", and transforms it into seconds:

```auto
ruby {
      code => "
        duration_parts = event.get('format_hh_mm_ss').split(':').map{|str| str.to_i}
        duration_seconds = duration_parts[0]*3600 + duration_parts[1]*60 + duration_parts[2]*60/100
        event.set('duration_in_seconds', duration_seconds)
      "
    }

```

In "Index Patterns", the "Set format" was set to "Duration". So, when using this field on a Dashboard, with the "Aggregation" of type "Average", sometimes it does not return time values ​​correctly, sometimes it comes with something like "3.75 min"

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [October 24, 2023, 4:19pm UTC](https://discuss.elastic.co/t/kibanas-average-aggregation-display-time-is-showing-the-time-wrong/344333/2 "2023-10-24T16:19:46Z")

</div>

I tried to reproduce the issue without success. In a 8.10.4 cluster I created some sample data and a data view with a duration field:

```auto
PUT issue-344333
{
  "mappings": {
    "properties": {
      "id": { "type": "integer"},
      "ts": { "type": "date"},
      "duration": { "type": "integer"}
    }
  }
}

PUT issue-344333/_bulk
{ "index": {}}
{ "id": 1, "ts": "2023-10-10", "duration": 60}
{ "index": {}}
{ "id": 2, "ts": "2023-10-11", "duration": 60}
{ "index": {}}
{ "id": 3, "ts": "2023-10-12", "duration": 120}
{ "index": {}}
{ "id": 4, "ts": "2023-10-13", "duration": 120}
{ "index": {}}
{ "id": 5, "ts": "2023-10-14", "duration": 180}
{ "index": {}}
{ "id": 6, "ts": "2023-10-15", "duration": 180}

POST kbn:/api/data_views/data_view
{
  "data_view": {
    "title": "issue-344333",
    "timeFieldName": "ts",
    "fieldFormats": {
      "duration": {
        "id": "duration",
        "params": {
          "inputFormat": "seconds",
          "outputFormat": "asSeconds",
          "outputPrecision": 2,
          "includeSpaceWithSuffix": true
        }
      }
    }
  }
}

```

And a new dashboard showing the average of the duration. Switching between different time frames did not yield a wrong value

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4ba6f2081a505f80e6f0a4ca26f2237f102f71bb.png)

Did you find some common pattern to reproduce this issue?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 21, 2023, 4:19pm UTC](https://discuss.elastic.co/t/kibanas-average-aggregation-display-time-is-showing-the-time-wrong/344333/3 "2023-11-21T16:19:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
