I need to fetch the data from elasticsearch indices using _search API and need to know which indices hold the data for fleet and agent status?
And how do I run the query using curl to get the Host name and IP address of that agent?
Fleet agents have dashboards. You could check the visualisation on which indices they are built.
Based on some of the data, you could probably find out things too by querying your elasticsearch on the logs-* (Kibana) data view to get a more specific index.
PS: Some time ago I looked into the general health status of my stack, but it seems that value is always calculated on the fly. So not sure if your health statusses are stored..
I guess the .fleet-agents-* has all the data - If I am not wrong?
What did your investiation tell you?