Request: Allow multiple Elasticsearch hosts in ElasticsearchWriter
Most applications allow you to define a host array for Elasticsearch. When opening an Elasticsearch connection a random node from the array will be selected. If this node is not reachable the next node from the array is selected until either a working node was found or no nodes are left in the array.
This allows for both load balancing and redundancy.
It would be great if we had this in Icinga 2's ElasticsearchWriter, too:
object ElasticsearchWriter "elasticsearch" {
host = [ "host01:9200", "host02:9200" ]
...
}
Since the ES feature does not have a persistent HTTP connection, this would require re-evaluation on each connect with a delay in timeouts if the first node is not reachable. In order to avoid such, one needs an intelligent caching algorithm.
Such balancing is doable within an HTTP proxy in front of the ES instance now, isn't it?
I'm not sure how it's handled right now in Icinga 2 but how I solved this was sending data using the bulk API and either reconnect before every bulk request or keep the connection up and only select another node if the bulk request fails. To make sure no documents are lost I collect documents in an array and when it reaches a certain size I try to send them to ES via a bulk request. If the request succeeds I empty the array, if not I try the next host.
@matthenning So it's no longer a problem for you?
I'm not using the feature at the moment, so you could say that, yes. Sadly I wasn't able to test dnsmichi's suggestion yet, but will update this issue in case I have to do so in the future.
@N-o-X Do you find it reasonable to let the user load-balance ESes via e.g. nginx?
PING @N-o-X
I don't think this feature is worth the work at the moment and using a load balancer as a workaround should be simple enough.