For ease of use, use Kibana for running API requests
mkdir -p /snapshots
chown -R elasticsearch. /snapshots
cat >> /etc/elasticsearch/elasticsearch.yml << EOF
path.repo: ["/snapshots"]
EOF
systemctl restart elasticsearch
PUT /_snapshot/logs
{
"type": "fs",
"settings": {
"location": "/snapshots",
"compress": true
}
}
#!/bin/bash
SNAPSHOT=`date +%Y%m%d-%H%M%S`
curl -XPUT "localhost:9200/_snapshot/logs/$SNAPSHOT?wait_for_completion=true"
GET /_snapshot/logs/_all?pretty
POST /logs/_close
POST /_snapshot/<repo_name>/<snapshot_name>/_restore?wait_for_completion=true
{
"indices": "logs"
}
POST /logs/_open
PUT /logs/_settings
{
"settings": {
"index.blocks.write": true
}
}
POST /logs/_clone/logs-new
{
"settings": {
"index.number_of_shards": 5
}
}
PUT /logs/_settings
{
"settings": {
"index.blocks.write": false
}
}
DELETE /audit-logs
First create temp index
curl -X POST http://localhost:9200/_reindex?wait_for_completion=true -H "Content-Type: application/json" \
-d '{"source":{"index":"logs"},"dest":{"index":"logs-temp"}}'
curl -X PUT http://localhost:9200/logs-temp/_settings -H "Content-Type: application/json" \
-d '{"settings":{"index.blocks.write":true}}'
curl -X DELETE http://localhost:9200/logs
curl -X POST http://localhost:9200/logs-temp/_clone/logs
curl -X DELETE http://localhost:9200/logs-temp
curl -X PUT http://localhost:9200/logs/_settings -H "Content-Type: application/json" \
-d '{"settings":{"index.blocks.write":false}}'
curl -X POST http://localhost:9200/logs/_update_by_query?wait_for_completion=true -H "Content-Type: application/json" \
-d '{"script":{"source":"ctx._source.result=true;ctx._source.created_boy=params.user;","lang":"painless","params":{"user":{"id":"1","name":"User 1"}}}}'
curl -X POST http://localhost:9200/logs/_update_by_query?wait_for_completion=true -H "Content-Type: application/json" \
-d {"script":{"source":"ctx._source.new_field='value_of_new_field'"}}
curl -X POST http://localhost:9200/logs/_update_by_query?wait_for_completion=true -H "Content-Type: application/json" \
-d {"script":{"source":"ctx._source.remove('new_field')"}}
curl -X PUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -H "Content-Type: application/json" \
-d '{"index.max_result_window" : "100000"}'
curl -X PUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -H "Content-Type: application/json" \
-d '{"indices.query.bool.max_clause_count" : "100000"}'
POST /_security/api_key
{
"name": "<key-name>",
"role_descriptors": {
"<role-name>": {
"cluster": ["all"],
"index": [
{
"names": ["<index-name>"],
"privileges": ["read"]
}
]
}
}
}