Kibana 5.4.0 垂直条形图数据可视化异常问题
Hey there, let's work through why your Y-axis isn't showing the max NO_OF_DEALS values for each EXPENSE_CODE in your bar chart. First, since you can see all your data in Discover, we know the index is healthy—so the issue is almost certainly in either your field mapping or visualization configuration.
First, Check the NO_OF_DEALS Field Type
This is the most common culprit. If Elasticsearch mapped NO_OF_DEALS as a string instead of a numeric type (like integer or long), Kibana can't calculate aggregations like "Max" on it. Here's how to verify:
- Go to Management > Index Patterns in Kibana.
- Select your
deal-expenseindex pattern. - Look for the
NO_OF_DEALSfield—check its type. If it saysstring, that's the problem.
How to Fix a Wrong Field Type
You can't modify the mapping of an existing field in Elasticsearch, so you'll need to:
- Create a new index with a correct mapping that defines
NO_OF_DEALSas a numeric type. Example mapping snippet:PUT new-deal-expense { "mappings": { "kafka-connect": { "properties": { "EXPENSE_CODE": {"type": "keyword"}, "EXPENSE_CODE_DESCRIPTION": {"type": "text"}, "NO_OF_DEALS": {"type": "integer"} } } } } - Re-import your data into this new index.
- Create a new index pattern in Kibana pointing to
new-deal-expense.
If the Field Type is Correct, Verify Your Visualization Configuration
Double-check these settings in your bar chart:
- Metrics Panel:
- Make sure you've selected Max as the aggregation type.
- Ensure you're picking the numeric
NO_OF_DEALSfield (sometimes if you have both a keyword and numeric version of a field, you'll need to select the right one).
- X-Axis Buckets:
- Confirm you're using Terms aggregation on
EXPENSE_CODE. - Optional: Set the sort order to
Max(NO_OF_DEALS)(descending) to prioritize codes with higher deal counts.
- Confirm you're using Terms aggregation on
- Time Filter:
- Kibana defaults to the last 15 minutes. If your data is older than that, adjust the time range picker at the top of the page to include your data's timestamp.
Test with a Direct Elasticsearch Query
To rule out index issues, run this query in Kibana's Dev Tools to see if Elasticsearch can compute the max values:
GET deal-expense/_search { "size": 0, "aggs": { "group_by_expense_code": { "terms": { "field": "EXPENSE_CODE" }, "aggs": { "max_no_of_deals": { "max": { "field": "NO_OF_DEALS" } } } } } }
If this returns valid max_no_of_deals values for each EXPENSE_CODE, your index is fine—focus on adjusting the Kibana visualization settings. If not, go back to fixing the field mapping.
内容的提问来源于stack exchange,提问作者Zamir Arif

