diff -Naur zabbix-4.0.3/src/libs/zbxhistory/history_elastic.c zabbix-4.0.3-patched/src/libs/zbxhistory/history_elastic.c
--- zabbix-4.0.3/src/libs/zbxhistory/history_elastic.c  2018-12-20 12:24:27.000000000 +0100
+++ zabbix-4.0.3-patched/src/libs/zbxhistory/history_elastic.c   2019-01-10 16:16:33.799110713 +0100
@@ -38,11 +38,13 @@
 const char     *value_type_str[] = {"dbl", "str", "log", "uint", "text"};

 extern char    *CONFIG_HISTORY_STORAGE_URL;
+extern char    *CONFIG_HISTORY_INDICE_PREFIX;
 extern int     CONFIG_HISTORY_STORAGE_PIPELINES;

 typedef struct
 {
        char    *base_url;
+       char    *idx_prefix;
        char    *post_url;
        char    *buf;
        CURL    *handle;
@@ -590,6 +592,7 @@
        elastic_close(hist);

        zbx_free(data->base_url);
+       zbx_free(data->idx_prefix);
        zbx_free(data);
 }

@@ -625,9 +628,11 @@
        struct zbx_json         query;
        struct curl_slist       *curl_headers = NULL;
        char                    *scroll_id = NULL, *scroll_query = NULL, errbuf[CURL_ERROR_SIZE];
+       char                    *index_name = NULL;

        zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);

+
        ret = FAIL;

        if (NULL == (data->handle = curl_easy_init()))
@@ -637,8 +642,15 @@
                return FAIL;
        }

+       if ((data->idx_prefix != NULL) && (data->idx_prefix[0] == '\0')) {
+               index_name = zbx_strdup(NULL, value_type_str[hist->value_type]);
+       } else {
+               index_name = zbx_strdup(NULL, data->idx_prefix);
+               index_name = zbx_strdcatf(index_name, "-%s", value_type_str[hist->value_type]);
+       }
+
        zbx_snprintf_alloc(&data->post_url, &url_alloc, &url_offset, "%s/%s*/values/_search?scroll=10s", data->base_url,
-                       value_type_str[hist->value_type]);
+                       index_name);

        /* prepare the json query for elasticsearch, apply ranges if needed */
        zbx_json_init(&query, ZBX_JSON_ALLOCATE);
@@ -839,19 +851,27 @@
        ZBX_DC_HISTORY          *h;
        struct zbx_json         json_idx, json;
        size_t                  buf_alloc = 0, buf_offset = 0;
-       char                    pipeline[14]; /* index name length + suffix "-pipeline" */
+       char                    pipeline[20]; /* index name length + suffix "-pipeline" also more 5 chars for index prefix */
+       char                    *index_name = NULL;

        zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);

        zbx_json_init(&json_idx, ZBX_IDX_JSON_ALLOCATE);

+       if ((data->idx_prefix != NULL) && (data->idx_prefix[0] == '\0')) {
+               index_name = zbx_strdup(NULL, value_type_str[hist->value_type]);
+       } else {
+               index_name = zbx_strdup(NULL, data->idx_prefix);
+               index_name = zbx_strdcatf(index_name, "-%s", value_type_str[hist->value_type]);
+       }
+
        zbx_json_addobject(&json_idx, "index");
-       zbx_json_addstring(&json_idx, "_index", value_type_str[hist->value_type], ZBX_JSON_TYPE_STRING);
+       zbx_json_addstring(&json_idx, "_index", index_name, ZBX_JSON_TYPE_STRING);
        zbx_json_addstring(&json_idx, "_type", "values", ZBX_JSON_TYPE_STRING);

        if (1 == CONFIG_HISTORY_STORAGE_PIPELINES)
        {
-               zbx_snprintf(pipeline, sizeof(pipeline), "%s-pipeline", value_type_str[hist->value_type]);
+               zbx_snprintf(pipeline, sizeof(pipeline), "%s-pipeline", index_name);
                zbx_json_addstring(&json_idx, "pipeline", pipeline, ZBX_JSON_TYPE_STRING);
        }

@@ -955,6 +975,12 @@
        data = (zbx_elastic_data_t *)zbx_malloc(NULL, sizeof(zbx_elastic_data_t));
        memset(data, 0, sizeof(zbx_elastic_data_t));
        data->base_url = zbx_strdup(NULL, CONFIG_HISTORY_STORAGE_URL);
+       if (NULL != CONFIG_HISTORY_INDICE_PREFIX) {
+               data->idx_prefix = zbx_strdup(NULL, CONFIG_HISTORY_INDICE_PREFIX);
+       } else { 
+               data->idx_prefix = "";
+       }
+
        zbx_rtrim(data->base_url, "/");
        data->buf = NULL;
        data->post_url = NULL;
diff -Naur zabbix-4.0.3/src/zabbix_proxy/proxy.c zabbix-4.0.3-patched/src/zabbix_proxy/proxy.c
--- zabbix-4.0.3/src/zabbix_proxy/proxy.c       2018-12-20 12:24:26.000000000 +0100
+++ zabbix-4.0.3-patched/src/zabbix_proxy/proxy.c        2019-01-10 17:12:19.482271578 +0100
@@ -267,6 +268,7 @@
 static char    *CONFIG_SOCKET_PATH     = NULL;

 char   *CONFIG_HISTORY_STORAGE_URL             = NULL;
+char   *CONFIG_HISTORY_INDICE_PREFIX           = NULL;
 char   *CONFIG_HISTORY_STORAGE_OPTS            = NULL;
 int    CONFIG_HISTORY_STORAGE_PIPELINES        = 0;

diff -Naur zabbix-4.0.3/src/zabbix_server/server.c zabbix-4.0.3-patched/src/zabbix_server/server.c
--- zabbix-4.0.3/src/zabbix_server/server.c     2018-12-20 12:24:26.000000000 +0100
+++ zabbix-4.0.3-patched/src/zabbix_server/server.c      2019-01-10 16:07:37.142678163 +0100
@@ -282,6 +283,7 @@
 static char    *CONFIG_SOCKET_PATH     = NULL;

 char   *CONFIG_HISTORY_STORAGE_URL             = NULL;
+char   *CONFIG_HISTORY_INDICE_PREFIX           = NULL;
 char   *CONFIG_HISTORY_STORAGE_OPTS            = NULL;
 int    CONFIG_HISTORY_STORAGE_PIPELINES        = 0;

@@ -527,6 +529,7 @@
        err |= (FAIL == check_cfg_feature_str("SSLCertLocation", CONFIG_SSL_CERT_LOCATION, "cURL library"));
        err |= (FAIL == check_cfg_feature_str("SSLKeyLocation", CONFIG_SSL_KEY_LOCATION, "cURL library"));
        err |= (FAIL == check_cfg_feature_str("HistoryStorageURL", CONFIG_HISTORY_STORAGE_URL, "cURL library"));
+       err |= (FAIL == check_cfg_feature_str("HistoryIndicePrefix", CONFIG_HISTORY_INDICE_PREFIX, "cURL library"));
        err |= (FAIL == check_cfg_feature_str("HistoryStorageTypes", CONFIG_HISTORY_STORAGE_OPTS, "cURL library"));
        err |= (FAIL == check_cfg_feature_int("HistoryStorageDateIndex", CONFIG_HISTORY_STORAGE_PIPELINES,
                        "cURL library"));
@@ -723,6 +728,8 @@
                        PARM_OPT,       1,                      1000},
                {"HistoryStorageURL",           &CONFIG_HISTORY_STORAGE_URL,            TYPE_STRING,
                        PARM_OPT,       0,                      0},
+               {"HistoryIndicePrefix",         &CONFIG_HISTORY_INDICE_PREFIX,          TYPE_STRING,
+                       PARM_OPT,       0,                      0},
                {"HistoryStorageTypes",         &CONFIG_HISTORY_STORAGE_OPTS,           TYPE_STRING_LIST,
                        PARM_OPT,       0,                      0},
                {"HistoryStorageDateIndex",     &CONFIG_HISTORY_STORAGE_PIPELINES,      TYPE_INT,
diff -Naur zabbix-4.0.3/frontends/php/conf/zabbix.conf.php.example zabbix-4.0.3-patched/frontends/php/conf/zabbix.conf.php.example
--- zabbix-4.0.3/frontends/php/conf/zabbix.conf.php.example     2018-12-20 12:24:28.000000000 +0100
+++ zabbix-4.0.3-patched/frontends/php/conf/zabbix.conf.php.example      2019-01-10 16:17:24.540031562 +0100
@@ -1,6 +1,6 @@
 <?php
 // Zabbix GUI configuration file.
-global $DB, $HISTORY;
+global $DB, $HISTORY, $HISTORY_PREFIX;

 $DB['TYPE']                            = 'MYSQL';
 $DB['SERVER']                  = 'localhost';
@@ -25,3 +25,4 @@
 //];
 // Value types stored in Elasticsearch.
 //$HISTORY['types'] = ['uint', 'text'];
+//$HISTORY_PREFIX='';
\ No newline at end of file
diff -Naur zabbix-4.0.3/frontends/php/include/classes/api/managers/CHistoryManager.php zabbix-4.0.3-patched/frontends/php/include/classes/api/managers/CHistoryManager.php
--- zabbix-4.0.3/frontends/php/include/classes/api/managers/CHistoryManager.php 2018-12-20 12:24:28.000000000 +0100
+++ zabbix-4.0.3-patched/frontends/php/include/classes/api/managers/CHistoryManager.php  2019-01-10 16:09:44.878341839 +0100
@@ -684,6 +684,8 @@
         * @return array    Elasticsearch query endpoints
         */
        public static function getElasticsearchEndpoints($value_types, $action = '_search') {
+               global $HISTORY_PREFIX;
+
                if (!is_array($value_types)) {
                        $value_types = [$value_types];
                }
@@ -697,9 +699,13 @@
                        }
                }

+               if (isset($HISTORY_PREFIX) && !empty($HISTORY_PREFIX)) {
+                 $HISTORY_PREFIX = $HISTORY_PREFIX . "-";
+               }
+
                foreach ($indices as $type => $index) {
                        if (($url = self::getElasticsearchUrl($index)) !== null) {
-                               $endponts[$type] = $url.$index.'*/values/'.$action;
+                               $endponts[$type] = $url.$HISTORY_PREFIX.$index.'*/values/'.$action;
                        }
                }
