]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | # Introduction |
2 | ||
3 | This directory contains an example `elasticsearch_adapter.lua` on how to | |
4 | use [Lua Scripting](https://docs.ceph.com/en/latest/radosgw/lua-scripting/) | |
5 | to push fields of the RGW requests | |
6 | to [Elasticsearch](https://www.elastic.co/elasticsearch/). | |
7 | ||
8 | ## Elasticsearch | |
9 | ||
10 | Install and run Elasticsearch using docker: | |
11 | ```bash | |
12 | docker network create elastic | |
13 | docker pull elasticsearch:2.4.6 | |
14 | docker 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 | |
24 | radosgw-admin script put --infile=elasticsearch_adapter.lua --context=postRequest | |
25 | ``` | |
26 | ||
27 | * Add the packages used in the script: | |
28 | ||
29 | ```bash | |
30 | radosgw-admin script-package add --package='elasticsearch 1.0.0-1' --allow-compilation | |
31 | radosgw-admin script-package add --package='lunajson' --allow-compilation | |
32 | radosgw-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 | |
39 | s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== mb s3://mybucket | |
40 | s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== put -P /etc/hosts s3://mybucket | |
41 | curl http://localhost:8000/mybucket/hosts | |
42 | ``` | |
43 | ||
44 | * Search by bucket id from Elasticsearch: | |
45 | ```bash | |
46 | curl -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 |