]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | # Introduction |
2 | ||
3 | This directory contains an example `prometheus_adapter.lua` on how to | |
4 | use [Lua Scripting](https://docs.ceph.com/en/latest/radosgw/lua-scripting/) | |
5 | to push metrics from the RGW requests to [Prometheus](https://prometheus.io/), | |
6 | specifically to collect information on object sizes. | |
7 | ||
8 | ## Prometheus | |
9 | ||
10 | As every single run of a lua script is short-lived, | |
11 | so [Pushgateway](https://github.com/prometheus/pushgateway) | |
12 | should be used as an intermediate service to enable Prometheus to scrape data | |
13 | from RGW. | |
14 | ||
15 | * Install and run Pushgateway using docker: | |
16 | ||
17 | ```bash | |
18 | docker pull prom/pushgateway | |
19 | docker run -p 9091:9091 -it prom/pushgateway | |
20 | ``` | |
21 | ||
22 | * Install and run Prometheus using docker: | |
23 | ||
24 | ```bash | |
25 | docker pull prom/prometheus | |
26 | docker run --network host -v ${CEPH_DIR}/examples/lua/config/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus | |
27 | ``` | |
28 | ||
29 | [Full documentation for Prometheus installation](https://prometheus.io/docs/prometheus/latest/installation/) | |
30 | ||
31 | ## Usage | |
32 | ||
33 | * Upload the script: | |
34 | ||
35 | ```bash | |
36 | radosgw-admin script put --infile=prometheus_adapter.lua --context=postRequest | |
37 | ``` | |
38 | ||
39 | * Add the packages used in the script: | |
40 | ||
41 | ```bash | |
42 | radosgw-admin script-package add --package='luasocket' --allow-compilation | |
43 | ``` | |
44 | ||
45 | * Restart radosgw. | |
46 | ||
47 | * Send a request: | |
48 | ```bash | |
49 | s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== mb s3://mybucket | |
50 | s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== put -P /etc/hosts s3://mybucket | |
51 | curl http://localhost:8000/mybucket/hosts | |
52 | ``` | |
53 | ||
54 | * Open `http://localhost:9090` by browser and search for `rgw_request_content_length` | |
55 | ![](img/prometheus.png) | |
56 | ||
57 | ## Requirements | |
58 | * Lua 5.3 or higher | |
59 |