Defining an index template

Since we are going to be storing time series data that is immutable, we do not want to create one big monolithic index. We'll use the techniques discussed in the Modeling time series data section in Chapter 9, Running the Elastic Stack in Production.

The source code of the application in this chapter is within the GitHub repository at https://github.com/pranav-shukla/learningelasticstack/tree/v7.0/chapter-10. As we go through the chapter, we will perform the steps mentioned in the README.md file located at that path.

Please create the index template mentioned in Step 1 of the README.md file or execute the following script in your Kibana Dev Tools Console:

POST _template/sensor_data_template
{
"index_patterns": [
"sensor_data*"
],
"settings": {
"number_of_replicas": "1",
"number_of_shards": "5"
},
"mappings": {
"properties": {
"sensorId": {
"type": "integer"
},
"sensorType": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"customer": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"department": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"buildingName": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"room": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"floor": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"locationOnFloor": {
"type": "keyword",
"fields": {
"analyzed": {
"type": "text"
}
}
},
"location": {
"type": "geo_point"
},
"time": {
"type": "date"
},
"reading": {
"type": "double"
}
}
}
}

This index template will create a new index with the name sensor_data-YYYY.MM.dd when any client attempts to index the first record in this index. We will see later in this chapter how this can be done from Logstash under Building the Logstash data pipeline section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.184.155