Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Average Aggregation #5593

Closed
cphoover opened this issue Dec 8, 2015 · 10 comments
Closed

Issue with Average Aggregation #5593

cphoover opened this issue Dec 8, 2015 · 10 comments
Labels
notabug When the issue is closed this label Indicates that it wasn't a bug

Comments

@cphoover
Copy link

cphoover commented Dec 8, 2015

... Perhaps this should be on the elasticsearch issue page. I'm not sure. I'm having an issue where average aggregations per minute are plotting my data points as zero. Where precision to the 1/1000th decimal point is significant. The issue is that my visualization of an average aggregation set to 1 min interval is plotting all the points at zero (except for a couple), even though all the data points are closer to one. Seems to me that precision is being lost some how or the aggregation is not working as intended. This is an important metric... We can multiply by 100 if that helps with the issue?

Here is a screenshot of the issue

http://imgur.com/a/qhn9p

We plan to upgrade in the upcoming weeks but have to make some schema changes beforehand... Right now we are running:
Version Kibana: 4.2.0
Elastic: 1.4.5

@rashidkpc
Copy link
Contributor

Can you click the ^ at the bottom of the chart and paste the contents of the "Response" tab?

@cphoover
Copy link
Author

cphoover commented Dec 8, 2015

Here is the response for the line chart viz

{
  "took": 97,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 18,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "2": {
      "buckets": [
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:02:00.000Z",
          "key": 1449576120000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:03:00.000Z",
          "key": 1449576180000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 1
          },
          "key_as_string": "2015-12-08T12:04:00.000Z",
          "key": 1449576240000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:05:00.000Z",
          "key": 1449576300000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:06:00.000Z",
          "key": 1449576360000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:07:00.000Z",
          "key": 1449576420000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:08:00.000Z",
          "key": 1449576480000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:09:00.000Z",
          "key": 1449576540000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:10:00.000Z",
          "key": 1449576600000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:11:00.000Z",
          "key": 1449576660000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:12:00.000Z",
          "key": 1449576720000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:13:00.000Z",
          "key": 1449576780000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:14:00.000Z",
          "key": 1449576840000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:15:00.000Z",
          "key": 1449576900000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:16:00.000Z",
          "key": 1449576960000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:17:00.000Z",
          "key": 1449577020000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 0
          },
          "key_as_string": "2015-12-08T12:18:00.000Z",
          "key": 1449577080000,
          "doc_count": 1
        },
        {
          "1": {
            "value": 1
          },
          "key_as_string": "2015-12-08T12:19:00.000Z",
          "key": 1449577140000,
          "doc_count": 1
        }
      ]
    }
  }
}

@cphoover
Copy link
Author

cphoover commented Dec 8, 2015

@rashidkpc any idea?

@spalger
Copy link
Contributor

spalger commented Dec 8, 2015

@cphoover as you can see in the pasted response, elasticsearch is responding with 1 and 0. If the aggregation truly should be averaging to smaller values there may be an issue with your elasticsearch version.

Can you verify the mapping type used for that field?

@spalger
Copy link
Contributor

spalger commented Dec 8, 2015

Since there are not any logged issues for (what I would assume is) such a common behavior I doubt this is actually a bug in elasticsearch.

@spalger
Copy link
Contributor

spalger commented Dec 8, 2015

I'm betting that your ratio field is mapped to an integer.

As you can see in the example I ran below, elasticsearch will accept a float for a field that is mapped as an integer.

This means that there won't be any issues at index time but will cause aggregations to operate on the values in that field like they are all ints (without decimal places).

image

@cphoover
Copy link
Author

cphoover commented Dec 8, 2015

Hmmm @spalger mapping seems to show that it is being indexed as long. Likely why it's not working

                      "Cache_Hit_Ratio": {
                              "type": "long"
                           },

Full Document

{
   "logstash-2015.12.08": {
      "mappings": {
         "b2c_databases-mssql": {
            "dynamic_templates": [
               {
                  "string_fields": {
                     "mapping": {
                        "index": "analyzed",
                        "omit_norms": true,
                        "type": "string",
                        "fields": {
                           "raw": {
                              "index": "not_analyzed",
                              "ignore_above": 256,
                              "type": "string"
                           }
                        }
                     },
                     "match": "*",
                     "match_mapping_type": "string"
                  }
               }
            ],
            "_all": {
               "enabled": true
            },
            "properties": {
               "@timestamp": {
                  "type": "date",
                  "format": "dateOptionalTime"
               },
               "@version": {
                  "type": "string",
                  "index": "not_analyzed"
               },
               "category": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               },
               "event": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               },
               "geoip": {
                  "dynamic": "true",
                  "properties": {
                     "location": {
                        "type": "geo_point"
                     }
                  }
               },
               "host": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               },
               "hostname": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               },
               "name": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               },
               "output": {
                  "properties": {
                     "SAN_Perf_Counters_R": {
                        "properties": {
                           "Avg_Bytes_Per_Read": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Transfer": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Write": {
                              "type": "long"
                           },
                           "Date": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "Drive": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "IO_stall": {
                              "type": "long"
                           },
                           "IO_stall_read_ms": {
                              "type": "long"
                           },
                           "IO_stall_write_ms": {
                              "type": "long"
                           },
                           "Latency": {
                              "type": "long"
                           },
                           "Num_of_bytes_read": {
                              "type": "long"
                           },
                           "Num_of_bytes_written": {
                              "type": "long"
                           },
                           "Num_of_reads": {
                              "type": "long"
                           },
                           "Num_of_writes": {
                              "type": "long"
                           },
                           "Read_Latency": {
                              "type": "long"
                           },
                           "Write_Latency": {
                              "type": "long"
                           }
                        }
                     },
                     "SAN_Perf_Counters_S": {
                        "properties": {
                           "Avg_Bytes_Per_Read": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Transfer": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Write": {
                              "type": "long"
                           },
                           "Date": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "Drive": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "IO_stall": {
                              "type": "long"
                           },
                           "IO_stall_read_ms": {
                              "type": "long"
                           },
                           "IO_stall_write_ms": {
                              "type": "long"
                           },
                           "Latency": {
                              "type": "long"
                           },
                           "Num_of_bytes_read": {
                              "type": "long"
                           },
                           "Num_of_bytes_written": {
                              "type": "long"
                           },
                           "Num_of_reads": {
                              "type": "long"
                           },
                           "Num_of_writes": {
                              "type": "long"
                           },
                           "Read_Latency": {
                              "type": "long"
                           },
                           "Write_Latency": {
                              "type": "long"
                           }
                        }
                     },
                     "SAN_Perf_Counters_T": {
                        "properties": {
                           "Avg_Bytes_Per_Read": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Transfer": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Write": {
                              "type": "long"
                           },
                           "Date": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "Drive": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "IO_stall": {
                              "type": "long"
                           },
                           "IO_stall_read_ms": {
                              "type": "long"
                           },
                           "IO_stall_write_ms": {
                              "type": "long"
                           },
                           "Latency": {
                              "type": "long"
                           },
                           "Num_of_bytes_read": {
                              "type": "long"
                           },
                           "Num_of_bytes_written": {
                              "type": "long"
                           },
                           "Num_of_reads": {
                              "type": "long"
                           },
                           "Num_of_writes": {
                              "type": "long"
                           },
                           "Read_Latency": {
                              "type": "long"
                           },
                           "Write_Latency": {
                              "type": "long"
                           }
                        }
                     },
                     "SAN_Perf_Counters_U": {
                        "properties": {
                           "Avg_Bytes_Per_Read": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Transfer": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Write": {
                              "type": "long"
                           },
                           "Date": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "Drive": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "IO_stall": {
                              "type": "long"
                           },
                           "IO_stall_read_ms": {
                              "type": "long"
                           },
                           "IO_stall_write_ms": {
                              "type": "long"
                           },
                           "Latency": {
                              "type": "long"
                           },
                           "Num_of_bytes_read": {
                              "type": "long"
                           },
                           "Num_of_bytes_written": {
                              "type": "long"
                           },
                           "Num_of_reads": {
                              "type": "long"
                           },
                           "Num_of_writes": {
                              "type": "long"
                           },
                           "Read_Latency": {
                              "type": "long"
                           },
                           "Write_Latency": {
                              "type": "long"
                           }
                        }
                     },
                     "SAN_Perf_Counters_V": {
                        "properties": {
                           "Avg_Bytes_Per_Read": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Transfer": {
                              "type": "long"
                           },
                           "Avg_Bytes_Per_Write": {
                              "type": "long"
                           },
                           "Date": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "Drive": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "IO_stall": {
                              "type": "long"
                           },
                           "IO_stall_read_ms": {
                              "type": "long"
                           },
                           "IO_stall_write_ms": {
                              "type": "long"
                           },
                           "Latency": {
                              "type": "long"
                           },
                           "Num_of_bytes_read": {
                              "type": "long"
                           },
                           "Num_of_bytes_written": {
                              "type": "long"
                           },
                           "Num_of_reads": {
                              "type": "long"
                           },
                           "Num_of_writes": {
                              "type": "long"
                           },
                           "Read_Latency": {
                              "type": "long"
                           },
                           "Write_Latency": {
                              "type": "long"
                           }
                        }
                     },
                     "SQL_Perf_Counters": {
                        "properties": {
                           "Batch_Requests_Sec": {
                              "type": "long"
                           },
                           "CPU_idle": {
                              "type": "long"
                           },
                           "CPU_sql": {
                              "type": "long"
                           },
                           "CPU_sys": {
                              "type": "long"
                           },
                           "Cache_Hit_Ratio": {
                              "type": "long"
                           },
                           "Connections": {
                              "type": "long"
                           },
                           "DATE": {
                              "type": "string",
                              "norms": {
                                 "enabled": false
                              },
                              "fields": {
                                 "raw": {
                                    "type": "string",
                                    "index": "not_analyzed",
                                    "ignore_above": 256
                                 }
                              }
                           },
                           "Deadlocks": {
                              "type": "long"
                           },
                           "Lazy_Writes_Sec": {
                              "type": "long"
                           },
                           "Memory_Grants_Pending": {
                              "type": "long"
                           },
                           "Page_Life_Exp": {
                              "type": "long"
                           },
                           "Page_Lookups_Sec": {
                              "type": "long"
                           },
                           "Page_Reads_Sec": {
                              "type": "long"
                           },
                           "Page_Writes_Sec": {
                              "type": "long"
                           },
                           "SQL_Compilations_Sec": {
                              "type": "long"
                           },
                           "SQL_Recompilations_Sec": {
                              "type": "long"
                           },
                           "ServerMemoryTarget_KB": {
                              "type": "long"
                           },
                           "ServerMemoryTotal_KB": {
                              "type": "long"
                           },
                           "Transactions_Sec": {
                              "type": "long"
                           }
                        }
                     }
                  }
               },
               "tags": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               },
               "type": {
                  "type": "string",
                  "norms": {
                     "enabled": false
                  },
                  "fields": {
                     "raw": {
                        "type": "string",
                        "index": "not_analyzed",
                        "ignore_above": 256
                     }
                  }
               }
            }
         }
      }
   }
}

@spalger
Copy link
Contributor

spalger commented Dec 8, 2015

Ah, well long doesn't support any decimal places (had to look that one up). It's basically a bigger version of integer. In order to store decimals you will need to use the float or double field types.

@spalger spalger added notabug When the issue is closed this label Indicates that it wasn't a bug and removed feedback_needed labels Dec 8, 2015
@spalger
Copy link
Contributor

spalger commented Dec 8, 2015

Closing this for now, but let me know if you have other questions

@spalger spalger closed this as completed Dec 8, 2015
@cphoover
Copy link
Author

cphoover commented Dec 8, 2015

makes sense. thanks for help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notabug When the issue is closed this label Indicates that it wasn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants