[comment]: # translation:outdated

[comment]: # ({4ff8e217-4ff8e217})
# 6 Elasticsearch beállítása

::: Fontos
 Az Elasticsearch támogatás kísérleti jellegű!

:::

A Zabbix támogatja a történelmi adatok tárolását az Elasticsearch segítségével
adatbázis helyett. A felhasználók kiválaszthatják a történelmi tárolási helyet
adatok egy kompatibilis adatbázis és az Elasticsearch között. A beállítás
Az ebben a részben leírt eljárás az Elasticsearch esetében is alkalmazható
7.X verzió. Abban az esetben, ha az Elasticsearch korábbi vagy későbbi verziója az
előfordulhat, hogy egyes funkciók nem megfelelően működnek.

::: megjegyzésfigyelmeztetés
 Ha az összes előzményadatot az Elasticsearch tárolja,
a trendeket **nem** számítják ki és nem tárolják az adatbázisban. Trendek nélkül
kiszámítva és tárolva, előfordulhat, hogy az előzmények tárolási időszakának kell lennie
kiterjedt.
:::

[comment]: # ({/4ff8e217-4ff8e217})

[comment]: # ({0b6587bd-0b6587bd})
#### Konfiguráció

Az összes érintett elem közötti megfelelő kommunikáció biztosítása érdekében győződjön meg róla
a szerver konfigurációs fájl és a frontend konfigurációs fájl paraméterei
megfelelően konfigurálva.

[comment]: # ({/0b6587bd-0b6587bd})

[comment]: # ({new-293ef64c})
##### Zabbix server and frontend

Zabbix server configuration file draft with parameters to be updated:

    ### Option: HistoryStorageURL
    # History storage HTTP[S] URL.
    #
    # Mandatory: no
    # Default:
    # HistoryStorageURL= 
    ### Option: HistoryStorageTypes
    # Comma separated list of value types to be sent to the history storage.
    #
    # Mandatory: no
    # Default:
    # HistoryStorageTypes=uint,dbl,str,log,text

Example parameter values to fill the Zabbix server configuration file
with:

    HistoryStorageURL=http://test.elasticsearch.lan:9200
    HistoryStorageTypes=str,log,text

This configuration forces Zabbix Server to store history values of
numeric types in the corresponding database and textual history data in
Elasticsearch.

Elasticsearch supports the following item types:

    uint,dbl,str,log,text

Supported item type explanation:

|   |   |   |
|---|---|---|
|**Item value type**|**Database table**|**Elasticsearch type**|
|Numeric (unsigned)|history\_uint|uint|
|Numeric (float)|history|dbl|
|Character|history\_str|str|
|Log|history\_log|log|
|Text|history\_text|text|

Zabbix frontend configuration file (`conf/zabbix.conf.php`) draft with
parameters to be updated:

    // Elasticsearch url (can be string if same url is used for all types).
    $HISTORY['url']   = [
          'uint' => 'http://localhost:9200',
          'text' => 'http://localhost:9200'
    ];
    // Value types stored in Elasticsearch.
    $HISTORY['types'] = ['uint', 'text'];

Example parameter values to fill the Zabbix frontend configuration file
with:

    $HISTORY['url']   = 'http://test.elasticsearch.lan:9200';
    $HISTORY['types'] = ['str', 'text', 'log'];

This configuration forces to store `Text`, `Character` and `Log` history
values in Elasticsearch.

It is also required to make $HISTORY global in `conf/zabbix.conf.php` to
ensure everything is working properly (see
`conf/zabbix.conf.php.example` for how to do it):

    // Zabbix GUI configuration file.
    global $DB, $HISTORY;

[comment]: # ({/new-293ef64c})

[comment]: # ({new-e9a9c5bd})
##### Installing Elasticsearch and creating mapping

Final two steps of making things work are installing Elasticsearch
itself and creating mapping process.

To install Elasticsearch please refer to [Elasticsearch installation
guide](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html).

::: noteclassic
Mapping is a data structure in Elasticsearch (similar to a
table in a database). Mapping for all history data types is available
here: `database/elasticsearch/elasticsearch.map`.
:::

::: notewarning
Creating mapping is mandatory. Some functionality
will be broken if mapping is not created according to the
instruction.
:::

To create mapping for `text` type send the following request to
Elasticsearch:

``` {.java}
curl -X PUT \
 http://your-elasticsearch.here:9200/text \
 -H 'content-type:application/json' \
 -d '{
   "settings": {
      "index": {
         "number_of_replicas": 1,
         "number_of_shards": 5
      }
   },
   "mappings": {
      "properties": {
         "itemid": {
            "type": "long"
         },
         "clock": {
            "format": "epoch_second",
            "type": "date"
         },
         "value": {
            "fields": {
               "analyzed": {
                  "index": true,
                  "type": "text",
                  "analyzer": "standard"
               }
            },
            "index": false,
            "type": "text"
         }
      }
   }
}'
```

Similar request is required to be executed for `Character` and `Log`
history values mapping creation with corresponding type correction.

::: noteclassic
To work with Elasticsearch please refer to [Requirement
page](/manual/installation/requirements#server) for additional
information.
:::

::: noteclassic
[Housekeeper](/manual/installation/requirements?s[]=housekeeper)
is not deleting any data from Elasticsearch.
:::

[comment]: # ({/new-e9a9c5bd})

[comment]: # ({new-8451a0a2})
#### Storing history data in multiple date-based indices

This section describes additional steps required to work with pipelines
and ingest nodes.

To begin with, you must create templates for indices.

The following example shows a request for creating uint template:

``` {.java}
curl -X PUT \
 http://your-elasticsearch.here:9200/_template/uint_template \
 -H 'content-type:application/json' \
 -d '{
   "index_patterns": [
      "uint*"
   ],
   "settings": {
      "index": {
         "number_of_replicas": 1,
         "number_of_shards": 5
      }
   },
   "mappings": {
      "properties": {
         "itemid": {
            "type": "long"
         },
         "clock": {
            "format": "epoch_second",
            "type": "date"
         },
         "value": {
            "type": "long"
         }
      }
   }
}'
```

To create other templates, user should change the URL (last part is the
name of template), change `"index_patterns"` field to match index name
and to set valid mapping, which can be taken from
`database/elasticsearch/elasticsearch.map`.

For example, the following command can be used to create a template for
text index:

``` {.java}
curl -X PUT \
 http://your-elasticsearch.here:9200/_template/text_template \
 -H 'content-type:application/json' \
 -d '{
   "index_patterns": [
      "text*"
   ],
   "settings": {
      "index": {
         "number_of_replicas": 1,
         "number_of_shards": 5
      }
   },
   "mappings": {
      "properties": {
         "itemid": {
            "type": "long"
         },
         "clock": {
            "format": "epoch_second",
            "type": "date"
         },
         "value": {
            "fields": {
               "analyzed": {
                  "index": true,
                  "type": "text",
                  "analyzer": "standard"
               }
            },
            "index": false,
            "type": "text"
         }
      }
   }
}'
```

This is required to allow Elasticsearch to set valid mapping for indices
created automatically. Then it is required to create the pipeline
definition. Pipeline is some sort of preprocessing of data before
putting data in indices. The following command can be used to create
pipeline for uint index:

``` {.java}
curl -X PUT \
 http://your-elasticsearch.here:9200/_ingest/pipeline/uint-pipeline \
 -H 'content-type:application/json' \
 -d '{
   "description": "daily uint index naming",
   "processors": [
      {
         "date_index_name": {
            "field": "clock",
            "date_formats": [
               "UNIX"
            ],
            "index_name_prefix": "uint-",
            "date_rounding": "d"
         }
      }
   ]
}'
```

User can change the rounding parameter ("date\_rounding") to set a
specific index rotation period. To create other pipelines, user should
change the URL (last part is the name of pipeline) and change
"index\_name\_prefix" field to match index name.

See also [Elasticsearch
documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/date-index-name-processor.html).

Additionally, storing history data in multiple date-based indices should
also be enabled in the new parameter in Zabbix server configuration:

    ### Option: HistoryStorageDateIndex
    # Enable preprocessing of history values in history storage to store values in different indices based on date.
    # 0 - disable
    # 1 - enable
    #
    # Mandatory: no
    # Default:
    # HistoryStorageDateIndex=0

[comment]: # ({/new-8451a0a2})

[comment]: # ({5c4a5e3c-5c4a5e3c})
#### Hibaelhárítás

A következő lépések segíthetnek a problémák elhárításában
Elasticsearch beállítása:

1. Ellenőrizze, hogy a leképezés helyes-e (GET kérés a szükséges index URL-hez
    mint a `http://localhost:9200/uint`).
2. Ellenőrizze, hogy a szilánkok nincsenek-e meghibásodott állapotban (az Elasticsearch újraindítása
    segítenie kell).
3. Ellenőrizze az Elasticsearch konfigurációját. A konfigurációnak lehetővé kell tennie
    hozzáférés a Zabbix frontend gazdagépről és a Zabbix szerver gazdagépről.
4. Ellenőrizze az Elasticsearch naplókat.

Ha továbbra is problémákat tapasztal a telepítéssel, akkor
kérjük, hozzon létre egy hibajelentést a listán szereplő összes információval
(leképezés, hibanaplók, konfiguráció, verzió stb.)

[comment]: # ({/5c4a5e3c-5c4a5e3c})
