]> git.proxmox.com Git - ceph.git/blame - ceph/examples/lua/elasticsearch_adapter.md
buildsys: change download over to reef release
[ceph.git] / ceph / examples / lua / elasticsearch_adapter.md
CommitLineData
20effc67
TL
1# Introduction
2
3This directory contains an example `elasticsearch_adapter.lua` on how to
4use [Lua Scripting](https://docs.ceph.com/en/latest/radosgw/lua-scripting/)
5to push fields of the RGW requests
6to [Elasticsearch](https://www.elastic.co/elasticsearch/).
7
8## Elasticsearch
9
10Install and run Elasticsearch using docker:
11```bash
12docker network create elastic
13docker pull elasticsearch:2.4.6
14docker run --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:2.4.6
15```
16
17[Full documentation for Elasticsearch installation](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html)
18
19## Usage
20
21* Upload the script:
22
23```bash
24radosgw-admin script put --infile=elasticsearch_adapter.lua --context=postRequest
25```
26
27* Add the packages used in the script:
28
29```bash
30radosgw-admin script-package add --package='elasticsearch 1.0.0-1' --allow-compilation
31radosgw-admin script-package add --package='lunajson' --allow-compilation
32radosgw-admin script-package add --package='lua-cjson 2.1.0-1' --allow-compilation
33```
34
35* Restart radosgw.
36
37* Send a request:
38```bash
39s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== mb s3://mybucket
40s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== put -P /etc/hosts s3://mybucket
41curl http://localhost:8000/mybucket/hosts
42```
43
44* Search by bucket id from Elasticsearch:
45```bash
46curl -X GET "localhost:9200/rgw/_search?pretty" -H 'Content-Type: application/json' -d'
47{
48 "query": {
49 "match": {
50 "Bucket.Id": "05382336-b2db-409f-82dc-f28ab5fef978.4471.4471"
51 }
52 }
53}
54'
55```
56
57## Requirements
58* Lua 5.3
59