Open thanh-lam opened 3 years ago
Following are the steps to load a customized index mapping for cast-allocation
using the filebeat
command.
/etc/filebeat/filebeat.ym
contains following at the end (no changes).
Note: The section under "Elasticsearch template setting" could be added automatically by one of the commands.
name: "master"
setup.kibana:
host: "X.XXX.XX.XX:5601"
output.logstash: hosts: [ "cXXXfXn0X:10523" ]
logging.level: info logging.to_files: true logging.files: path: /var/log/filebeat name: filebeat keepfiles: 7 permissions: 0644
setup.template.name: "filebeat-*" setup.template.fields: "filebeat_fields.yml" setup.template.overwrite: true
2. Obtain current `cast-allocation` index mapping from `elasticsearch` and save the output to a file (`cast-allocation-map.json`:
curl http://XX.X.X.XX:9200/cast-allocation/_mapping?pretty > cast-allocation-map.json
3. Edit `cast-allocation-map.json` and change the two fields: `data.begin_time` and `data.history.end_time` to type `date` as shown in defect description.
4. Copy `cast-allocation-map.json` to `cast-allocation-template.json`. Edit the new file and make sure the "index_patterns" attribute is assigned the value "cast-allocation" before the "mappings" section.
{ "index_patterns": [ "cast-allocation" ], "mappings": {
5. Run `filebeat` to disable `logstash` output and enable `elasticsearch` output:
filebeat setup --index-management -E output.logstash.enabled=false -E 'output.elasticsearch.hosts=["XX.X.X.XX:9200"]'
6. Run `curl` to load the customized template:
curl -XPUT -H 'Content-Type: application/json' http://XX.X.X.XX:9200/_template/cast-allocation -d@cast-allocation-template.json
7. Verify that the template was applied:
curl http://XX.X.X.XX:9200/_template/cast-allocation?pretty
8. Login to `kibana` GUI to delete existing `cast-allocation` index in `elasticsearch` and `kibana`. Then, create some new csm allocations to see new `cast-allocation` index in `Elasticsearch`. Now, create the index pattern in `kibana` to access new data.
Edited the steps to add the last step because it's necessary to delete the old cast-allocation
index in elasticsearch
and kibana
. Then, the new data will be mapped to the new data type.
Describe the bug Current cast-allocation index contains two string fields that are used for time range query:
With elasticsearch 7.5.1+, time range queries on
text
fields do not work. These fields need to be mapped todate
type.It's possible that the index cast-allocation didn't have a customized mapping of data fields initially. So,
filebeat
reads the allocation records incsm_transaction
log and puts them intoelasticsearch
indexes as text or string type.This defect documents the procedure of loading a customized index mapping template for
cast-allocation
using thefilebeat
andcurl
commands.To Reproduce Steps to reproduce the behavior:
curl
to displaycast-allocation
index mapping:begin_time
andend_time
text
, for example:Expected behavior Those date fields should be defined as date, for example:
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context With these fields changed to
date
type, the date format to be written into them needs to have correct format as well. See #992.Issue Source: Beside addressing the index mapping issue, the procedure of how to use the
filebeat
command to load customized mapping template should be in CSM BDS readthedoc for when there's need in the future.