Given logstash configs can have multiple inputs and outputs
What considerations drive the decisions as to the number of indexes to have as outputs stored in elastic search if I'm using the twitter input on logstash?
Should I have 1 index per monitored account, 1 per tag or keyword or are there other considerations that would affect the design?
There is overhead in elasticsearch for each open index, so they'll each consume HEAP.
It's common to put more than one type of document in an index (that's what the [type] field is for). Note that, in elasticsearch v2, any identically-named fields must have the same mapping ("myField", if a string in one type, must always be a string).
Shards have a recommended upper limit on size, about 60GB IIRC.
Finally, arrange your index so that enforcing your retention policy is easy. If everything is kept for 7 days, then a daily index would work well. Use 'curator' to delete old indexes.
I prefer to make a smaller number of large indexes.
Related
I am very new to elastic search and its applications, I found that elastic search saves data(indexes) onto disk. Then I wondered: Are there any limitations on number of indexes that can be created or can I create as many as I can since I have a very large disk space?
Currently I have elastic search deployed using a single node cluster with Docker. I have read something about shards and its limitation etc., but I was not able to understand it properly.
Is there anyone on SO, who can shed some light onto these questions for a newbie in layman terms?
What is a single node cluster and how does my data get saved onto disk? Also what are shards and how is it related to elastic search?
I guess the best answer is "it depends ". Generally there is no limitation for having many indexes , Every index has its own mapping and irrelevant to other indexes by default, Actually indexes are instance of Elasticsearch servers and please note that they are not data rather you may think about as entire database alone. There are many variables for answering this question for example if are planning to have replication of your shards in one index then you may found limitation due to the size of document you are planning to ingest inside the index.
As an other note you may need to ask first why I need many indexes ? for enhancing search operation or queries throughput? if it is the case then perhaps its better to use replica shards beside your primary shards in the single index because the queries are executed parallel to each other in replica shards and you can think of shards as an stand alone index inside of your main index so in conclusion I can say there is no limitation as long as you have enough free space to save new data (expanding inverted indexes table created for on field) but regarding to you needs it may be better to have primary and replica shards inside an index .
We use Elastic search for full text search use cases. The data is metadata collected across different objects and stored as ES document. We also update the document in ES whenever the master data gets updated. So, basically it is not a logging use case.
We create one ES index (one primary and 1 replica shard) as soon as we have a tenant who gets onboard for our application. This is to ensure that the ES index is ready when the first object gets created.
We do not anticipate volume of data in the index. The data could range between few hundred of MBs per index. So this is a relatively empty index.
Also, full text search is an optional add-in feature in application, so not all tenants may opt for the same, however our technical team suggested creating index upfront.
What is the overhead of such indices on the ES performance? Are we doing anything different from best practices of ES?
Any input is appreciated.
Empty Elasticsearch index don't have much overhead, as there is actually no data in them, only places where empty indices data is present in the cluster state(index mapping, setting etc) which every node in the cluster has and any change in the index mapping or settings ie index metadata updates the cluster state and gets updated on all the nodes in ES cluster.
If you have sufficient memory and ES heap size, you don't have to worry at all about these empty indices which IMO makes sense considering your use-case.
We have different document structures/schema that we on-board into different elasticsearch indices. We have ~50 such indices, and one of our primary use cases is to perform search across all these document types i.e. across all 50 indices. Data size within each index is ~10-20 GB, thus each index easily fits into a single shard.
I am looking for ways to optimize the performance in search across these 50 indices. We have a particular common field across all these indices which is available within a user's search request, and could be used for sharding within each index if we had more than one shards per index. Not sure if we could make use of it somehow to optimize the performance for this multi-index search, or any other alternate options.
You need to provide more information in order to get some concrete answer, please provide below information.
Your Sample search query with its avg time taken across good no of calls.
data nodes heap size
How many documents you are fetching in your search query ie size param.
Search slow logs of elasticsearch for your search query.
Total no of data nodes and and each indices replicas in your cluster, where you are performing search queries?
I'm using Elasticsearch as a centralized logging platform . As most examples show I've been logging to multiple indexes time-stamped by day (e.g. logmessages-2017-04-14)
However, I only have a single node setup that contains all these daily indexes. Would I be better off just logging to a single logmessages index on this single node?
Since I only have a single node I have replicas set to 0 and shards set to 1 for each daily index. I'm indexing about 100,000 documents per month.
The answer is "no".
A logging use case always has a retention period defined, meaning after some time you don't need those logs anymore and you need to delete them. This is the same with Elasticsearch indices: when the retention period has been reached that log is deleted.
With time based indices, you delete one day's index and that's it. It's much much more preferred to delete entire indices than individual documents from indices.
I have two ElasticSearch Servers:
http://12.13.54.333:9200
and
http://65.98.54.10:9200
In the first server I have 100k of data(id=1 to id=100k) and in the second server I have 100k of data(id=100k+1 to 200k).
I want to have a text search for the keyword obama in one request on both servers. Is this possible?
Your question is a little generic...I'll try not to give an "it depends" kind of answer, but in order to do so I have to make a couple of assumptions.
Are those two servers actually two nodes on the same elasticsearch cluster? I suppose so.
Did you index data on an elasticsearch index composed of more than one shard? I suppose so. The default in elasticsearch is five shards, which in your case would lead to having two shards on one node and three on the other.
Then you can just send your query to one of those nodes via REST API. The query will be executed on all the shards that the index (can be even more than one) you are querying is composed of. If you have replicas the replica shards might be used too at query time. The node that received your query will then reduce the search results got from all the shards returning back the most relevant ones.
To be more specific the search phase on every shard will most likely only collect the document ids and their score. Once the node that you hit has reduced the results, it can fetch all the needed fields (usually the _source field) only for the documents that it's supposed to return.
What's nice about elasticsearch is that even if you indexed data on different indexes you can query multiple indices and everything is going to work the same as I described. At the end of the day every index is composed of shards, and querying ten indices with one shard each is the same as querying one index with ten shards.
What I described applies to the default search_type that elasticsearch uses, called query_then_fetch. There are other search types that you can eventually use when needed, like for example the count which doesn't do any reduce nor fetch but just returns the number of hits for a query executing it on all shards and returning the sum of all the hits for each shard.
Revendra Kumar,
Elasticsearch should handler that for you. Elasticsearch was built from scratch to be distributed and do distributed search.
Basically, if those servers are in the same cluster, you will have a two shards (the first one holds the id from 1 to 100k and the second one hold the ids from 100001 to 200k). When you search by something, it doesn't matter which server it hits, it will do a search on both servers and returns the result for the client. The internal behavior of elasticsearch is too extensive to explain here.