]> git.proxmox.com Git - ceph.git/blame - ceph/examples/lua/prometheus_adapter.md
buildsys: change download over to reef release
[ceph.git] / ceph / examples / lua / prometheus_adapter.md
CommitLineData
20effc67
TL
1# Introduction
2
3This directory contains an example `prometheus_adapter.lua` on how to
4use [Lua Scripting](https://docs.ceph.com/en/latest/radosgw/lua-scripting/)
5to push metrics from the RGW requests to [Prometheus](https://prometheus.io/),
6specifically to collect information on object sizes.
7
8## Prometheus
9
10As every single run of a lua script is short-lived,
11so [Pushgateway](https://github.com/prometheus/pushgateway)
12should be used as an intermediate service to enable Prometheus to scrape data
13from RGW.
14
15* Install and run Pushgateway using docker:
16
17```bash
18docker pull prom/pushgateway
19docker run -p 9091:9091 -it prom/pushgateway
20```
21
22* Install and run Prometheus using docker:
23
24```bash
25docker pull prom/prometheus
26docker 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
36radosgw-admin script put --infile=prometheus_adapter.lua --context=postRequest
37```
38
39* Add the packages used in the script:
40
41```bash
42radosgw-admin script-package add --package='luasocket' --allow-compilation
43```
44
45* Restart radosgw.
46
47* Send a request:
48```bash
49s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== mb s3://mybucket
50s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== put -P /etc/hosts s3://mybucket
51curl 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