Skip to content
Snippets Groups Projects
Commit 19795beb authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-inventories/gentner#2369 Document re-indexing in ElasticSearch

parent fcb2ced1
No related branches found
No related tags found
No related merge requests found
Pipeline #34669 passed
......@@ -5,10 +5,10 @@ tags:
---
# ElasticSearch
- [Introduction](elk/introduction)
- [Collecting Data](elk/fluentd)
- [UI to view the data](elk/kibana)
- [Alerts on Log Data](monitoring/alerts-elk)
- [Collecting Data](fluentd)
- [UI to view the data](kibana)
- [Alerts on Log Data](../monitoring/alerts-elk)
- [Re-Indexing a broken index](re-indexing)
Log data from the OS and selected applications is generated on the server farm on many different places and we are aggregating all of that data in ElasticSearch so that we can analyse the systems when ever needed but also to be able to raise alerts if something is going wrong.
......
---
title: Ansible Wiki ELK Re-Indexing
tags:
- ansible
---
# Re-index ElasticSearch Index
Sometimes an index gets broken and here is how this can be repaired following
this [great guide](https://www.thirdrocktechkno.com/blog/6-steps-to-reindex-elasticsearch-data)
We use `$IDX` for the existing, e.g. broken index and `$IDXNEW` for the new one.
## Show number of records for all indexes
```shell
curl -X GET 'http://${ELUSER}:${ELPASS}@localhost:9200//_cat/indices/%2A?v=&s=index:desc'
```
## Create new index with mappings
```shell
curl -X PUT http://${ELUSER}:${ELPASS}@localhost:9200/$IDXNEW \
-H 'Content-Type: application/json' \
-d '{
"mappings": {
"properties": {
[PROVIDE THE MAPPING HERE]
}
}
}'
```
## Re-index from old to new index
```shell
curl -X POST http://${ELUSER}:${ELPASS}@localhost:9200/_reindex \
-H 'Content-Type: application/json' \
-d '{
"source": {
"index": "$IDX"
},
"dest": {
"index": "$IDXBEW"
}
}'
```
## Delete the old index
```shell
curl -X DELETE http://${ELUSER}:${ELPASS}@localhost:9200/$IDX
```
## Delete and recreate alias
```shell
curl -X POST http://${ELUSER}:${ELPASS}@localhost:9200/_aliases \
-H 'Content-Type: application/json' \
-d '{
"actions": [
{
"remove": {
"index": "$IDXNEW",
"alias": "$IDX"
}
}
]
}'
```
```shell
curl -X POST http://${ELUSER}:${ELPASS}@localhost:9200/_aliases \
-H 'Content-Type: application/json' \
-d '{
"actions": [
{
"add": {
"index": "$IDXNEW",
"alias": "$IDX"
}
}
]
}'
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment