-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unsigned number types #13951
Comments
The values are mostly already compressed in lucene. For example, if your values range from -1 to 253, only a single byte should be used (depends on what features you have enabled for the field eg indexed, stored, doc values). I don't think we should complicate the api with more types. Other than input validation (which the user can do on their end), the different types for long/int/short/byte don't matter to lucene. They are simply numeric and we will represent them according to the values seen. I would rather see the ability to set the valid range of values in the mapping, and limit to just "integral" and "floating point" field types. (Granted the types do matter for fielddata, but with doc values by default for 2.0 this doesn't really matter anymore). |
Actually they don't, so even on 1.x things are just fine. |
I think the only time that type may be relevant is when you want to use an unsigned long that doesn't fit into the range of a signed long? |
Once we get BigDecimal support it becomes irrelevant I think? I would rather wait for that (hopefully not too long now with BKD going into lucene core soon) than add something the the api right now that would require complex internal changes (how do you represent an unsigned long without BigDecimal in java?). |
++ |
@clintongormley: Currently, I have to use cases:
As far as I can remember, 1 and 2 was the most space efficient (storing several billions, so space matters), but having an arbitrary sized integer would be the best. So my point is:
Thanks, |
@rjernst: "(how do you represent an unsigned long without BigDecimal in java?)" |
See my comments before. Would the problem you have with storing an unsigned int in a long be handled by allowing you to set the minimum and maximum value allowed on numeric types? This way it could be a long, but you set 0 as the min and max unsigned int as the max. The only limitation (for now, until we have bigint/decimal support) would be you still could not represent anything outside of min/max signed long.
See the issue #5683, and the latest lucene issue to support this, https://issues.apache.org/jira/browse/LUCENE-6825 |
@rjernst: yes, for me having a min/max (and an arbitrary precision integer :) would be enough, given that it won't explode the storage space needs. |
We just discussed this issue in FixitFriday: we like specifying types using byte,short,int,long better than min and max values. And given that doc values compute dynamically how many bits per value are required, space requirements would be pretty similar between an unsigned int field and a long, so implementing support for unsigned numeric types would not help. |
@rjernst Thanks for your suggestion, however it won't help us or anyone else indexing 64-bit hashes, our workaround for those at the moment is to store them as a string. |
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The dependencies for this code are vendored using gvt. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The dependencies for this code are vendored using gvt. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The dependencies for this code are vendored using gvt. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The dependencies for this code are vendored using gvt. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) I chose not to use the Hellogopher Makefile because I felt it was doing more than is necessary for this repo (e.g. vendoring goimports). The dependencies for this code are vendored using gvt, the vendoring tool used by Hellogopher. I've used semantic versioning rather than our usual versioning schema because I'd like to open-source this tool soon. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The dependencies for this code are vendored using gvt. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
Add a new service, `alertmanager2es`, which receives [HTTP webhook notifications][] from [AlertManager][] and inserts them into an [Elasticsearch][] index for searching and analysis. Notifications are received on the `/webhook` endpoint. Prometheus metrics are exposed on `/metrics`. Note that this service will not capture silenced or inhibited alerts currently. I used a custom type for `groupKey` so that the `groupKey` field can be marshalled into JSON as a string, since Elasticsearch does not currently support unsigned integers: elastic/elasticsearch#13951 I tested extensively to try to map the integer to a string using Elasticsearch's mappings, which I succeeded in doing, however Kibana then failed to display the documents because Elasticsearch's highlighting could not handle the unsigned integer stored in `_source`: RemoteTransportException[[Eternal Brain][172.17.0.2:9300][indices:data/read/search[phase/query+fetch]]]; nested: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; Caused by: FetchPhaseExecutionException[Fetch Failed [Failed to highlight field [alerts.labels.decoded_pem_md5]]]; nested: IllegalStateException[No matching token for number_type [BIG_INTEGER]]; at org.elasticsearch.search.highlight.PlainHighlighter.highlight(PlainHighlighter.java:123) at org.elasticsearch.search.highlight.HighlightPhase.hitExecute(HighlightPhase.java:140) at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:188) at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:490) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:392) at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryFetchTransportHandler.messageReceived(SearchServiceTransportAction.java:389) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77) at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:376) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) The dependencies for this code are vendored using gvt. [AlertManager]: https://github.com/prometheus/alertmanager [Elasticsearch]: https://www.elastic.co/products/elasticsearch [HTTP webhook]: https://prometheus.io/docs/alerting/configuration/#webhook-receiver-<webhook_config>
This is a seriously disappointing limitation. 64-bit numbers cannot be stored (since |
unsigned_long does exist now :-) |
There are a lot of cases, where you want to store a byte/short/int/long in an elastic field, but it's unsigned by nature. With byte/short/int, it's always possible to use a bigger type (at the cost of increased storage space? I haven't measured that), but not with long.
Splitting numbers or subtracting/adding the "magic number" from and to the value is a nightmare.
I think it would be much more convenient to support unsigned types natively.
Theoretically on elasticsearch side it wouldn't be too hard: if a field is marked as unsigned (ubyte/ushort/uint/ulong?), every value which "comes in" needs to be decreased by 2^(bitsize(type)-1), and when "going out", increased by the same amount. Otherwise elasticsearch internals wouldn't change.
Of course representing the unsigned values with Java native signed types can be tricky (BigInteger or Java 8 native unsigned types?).
The text was updated successfully, but these errors were encountered: