elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.67k stars 8.1k forks source link

[Stack Monitoring] Improve error message for getKibanaInfo #123521

Open simianhacker opened 2 years ago

simianhacker commented 2 years ago

The current error message from the getKibanaInfo() when Elasticsearch returns ZERO results is unhelpful; it will return this error message:

Monitoring Request Error Missing required parameter of field: timestamp: Missing required parameter of field: timestamp

This error doesn't indicate the real problem which is the query returned ZERO results. We should add a check to ensure there are results and when it fails we should return a meaningful error message like:

Monitoring Request Error: The query for Kibana state using "${clusterUuid}" cluster UUID and "${kibanaUuid}" Kibana UUID returned zero results. There needs to be at least one record returned for this query."

The offending code lives here:

https://github.com/elastic/kibana/blob/4d47cb793b577d1f2f94f338abdd7ce2de94ce3b/x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts#L19-L24

elasticmachine commented 2 years ago

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

lucabelluccini commented 2 years ago

The problem affects any get_<product>_info. E.g. Logstash (https://github.com/elastic/kibana/blob/4d47cb793b577d1f2f94f338abdd7ce2de94ce3b/x-pack/plugins/monitoring/server/lib/logstash/get_node_info.ts#L20).

The problem can be triggered by the presence of metricbeat-* indices with incorrect mappings, as Stack Monitoring queries .monitoring-*,metricbeat-* by default (monitoring.ui.metricbeat.indices allows to customize the set of Metricbeat indices to use).

To identify the problematic indices, one could run GET .monitoring-*,metricbeat-*/_mapping/field/timestamp and check if there are indices with such field and the type is not date.