File: prometheus_adapter.md

package info (click to toggle)
ceph 18.2.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,186,140 kB
  • sloc: cpp: 6,278,388; ansic: 3,507,431; python: 372,964; asm: 216,381; java: 133,450; sh: 125,043; xml: 39,398; ruby: 32,026; makefile: 29,004; javascript: 23,994; cs: 18,980; perl: 9,708; sql: 7,833; lisp: 5,920; pascal: 3,109; ada: 1,681; yacc: 478; awk: 188; f90: 55; php: 1
file content (59 lines) | stat: -rw-r--r-- 1,850 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Introduction

This directory contains an example `prometheus_adapter.lua` on how to
use [Lua Scripting](https://docs.ceph.com/en/latest/radosgw/lua-scripting/)
to push metrics from the RGW requests to [Prometheus](https://prometheus.io/), 
specifically to collect information on object sizes.

## Prometheus

As every single run of a lua script is short-lived,
so [Pushgateway](https://github.com/prometheus/pushgateway)
should be used as an intermediate service to enable Prometheus to scrape data
from RGW.

* Install and run Pushgateway using docker:

```bash
docker pull prom/pushgateway
docker run -p 9091:9091 -it prom/pushgateway
```

* Install and run Prometheus using docker:

```bash
docker pull prom/prometheus
docker run --network host -v ${CEPH_DIR}/examples/lua/config/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
```

[Full documentation for Prometheus installation](https://prometheus.io/docs/prometheus/latest/installation/)

## Usage

* Upload the script:

```bash
radosgw-admin script put --infile=prometheus_adapter.lua --context=postRequest
```

* Add the packages used in the script:

```bash
radosgw-admin script-package add --package='luasocket' --allow-compilation
```

* Restart radosgw.

* Send a request:
```bash
s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== mb s3://mybucket
s3cmd --host=localhost:8000 --host-bucket="localhost:8000/%(bucket)" --access_key=0555b35654ad1656d804 --secret_key=h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q== put -P /etc/hosts s3://mybucket
curl http://localhost:8000/mybucket/hosts
```

* Open `http://localhost:9090` by browser and search for `rgw_request_content_length`
![](img/prometheus.png)

## Requirements
* Lua 5.3 or higher