Skip to content

Commit 85725ed

Browse files
committed
fix prom example and add test
1 parent d8b3a7b commit 85725ed

4 files changed

Lines changed: 53 additions & 4 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: OATS Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- .github/workflows/prometheus-test.yml
9+
- mise.toml
10+
- .mise/tasks/prometheus-test.sh
11+
- 'prometheus/**'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
acceptance-tests:
19+
runs-on: ubuntu-24.04
20+
steps:
21+
- name: Check out
22+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
23+
24+
- uses: jdx/mise-action@9dc7d5dd454262207dea3ab5a06a3df6afc8ff26 # v3.4.1
25+
26+
- name: Run Prometheus test
27+
run: mise run prometheus-test

.mise/tasks/prometheus-test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Run Prometheus example build"
3+
4+
set -euo pipefail
5+
6+
cd prometheus
7+
../gradlew shadowJar
8+
# start docker compose in background
9+
docker compose start
10+
11+
# check that 200 is returned from the metrics endpoint
12+
curl -f localhost:19090/metrics > /dev/null 2>&1 || (echo "Metrics endpoint did not return 200" && exit 1)
13+
# check that 200 is returned from the Prometheus server
14+
curl -f http://localhost:9090 > /dev/null 2>&1 || (echo "Prometheus did not return 200" && exit 1)
15+
16+
echo "Prometheus example build and endpoints are working correctly"
17+
18+
docker compose down

prometheus/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ docker compose up
3232

3333
## 3 - View Metrics
3434

35-
To view metrics in Prometheus, navigate to:
35+
To view metrics in Prometheus (e.g. 90% percentile), navigate to:
3636

37-
http://localhost:9090/graph?g0.range_input=15m&g0.expr=incoming_messages&g0.tab=0
37+
http://localhost:9090/query?g0.expr=histogram_quantile%28.90%2C+sum+by%28le%29+%28rate%28super_timer_milliseconds_bucket%5B5m%5D%29%29%29&g0.show_tree=0&g0.tab=graph&g0.range_input=15m&g0.res_type=auto&g0.res_density=medium&g0.display_mode=lines&g0.show_exemplars=0
3838

3939
To fetch application metrics in prometheus format, run:
40-
40+
41+
```shell
4142
curl localhost:19090/metrics
43+
```
4244

4345
To fetch application metrics in OpenMetrics format, which includes exemplars, run:
4446

47+
```shell
4548
curl -H 'Accept: application/openmetrics-text; version=1.0.0; charset=utf-8' localhost:19090/metrics
49+
```

prometheus/prometheus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alerting:
88
- targets: []
99
scheme: http
1010
timeout: 10s
11-
api_version: v1
11+
api_version: v2
1212
scrape_configs:
1313
- job_name: prometheus
1414
honor_timestamps: true

0 commit comments

Comments
 (0)