Skip to content

Commit 396f87d

Browse files
committed
grafana running behind caddy
1 parent 082f3d9 commit 396f87d

File tree

4 files changed

+13
-23
lines changed

4 files changed

+13
-23
lines changed

resources/charts/caddy/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ caddyConfig: |
9999
}
100100
101101
handle_path /grafana/* {
102-
reverse_proxy grafana:3000
102+
reverse_proxy loki-grafana:80
103103
}
104104
105105
}

resources/manifests/grafana_values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ grafana.ini:
1616
auth:
1717
disable_login_form: true
1818
disable_signout_menu: true
19+
server:
20+
# this is required to use Grafana behind a reverse proxy (caddy)
21+
root_url: "%(protocol)s://%(domain)s:%(http_port)s/grafana/"
1922
auth.anonymous:
2023
enabled: true
2124
org_name: Main Org.

test/data/logging/network.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ nodes:
1010
metrics: txrate=getchaintxstats(10)["txrate"]
1111
- name: tank-0002
1212
connect:
13-
- tank-0000
13+
- tank-0000
14+
caddy:
15+
enabled: true

test/logging_test.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import logging
44
import os
5-
import threading
65
from datetime import datetime
76
from pathlib import Path
8-
from subprocess import PIPE, Popen, run
7+
from subprocess import run
98

109
import requests
1110
from test_base import TestBase
1211

12+
GRAFANA_URL = "http://localhost:2019/grafana/"
13+
1314

1415
class LoggingTest(TestBase):
1516
def __init__(self):
@@ -35,22 +36,6 @@ def start_logging(self):
3536
self.log.info("Running install_logging.sh")
3637
# Block until complete
3738
run([f"{self.scripts_dir / 'install_logging.sh'}"])
38-
self.log.info("Running connect_logging.sh")
39-
# Stays alive in background
40-
self.connect_logging_process = Popen(
41-
[f"{self.scripts_dir / 'connect_logging.sh'}"],
42-
stdout=PIPE,
43-
stderr=PIPE,
44-
bufsize=1,
45-
universal_newlines=True,
46-
)
47-
self.log.info("connect_logging.sh started...")
48-
self.connect_logging_thread = threading.Thread(
49-
target=self.output_reader,
50-
args=(self.connect_logging_process.stdout, self.connect_logging_logger.info),
51-
)
52-
self.connect_logging_thread.daemon = True
53-
self.connect_logging_thread.start()
5439

5540
def setup_network(self):
5641
self.log.info("Setting up network")
@@ -64,7 +49,7 @@ def wait_for_endpoint_ready(self):
6449

6550
def check_endpoint():
6651
try:
67-
response = requests.get("http://localhost:3000/login")
52+
response = requests.get(f"{GRAFANA_URL}login")
6853
return response.status_code == 200
6954
except requests.RequestException:
7055
return False
@@ -79,7 +64,7 @@ def make_grafana_api_request(self, ds_uid, start, metric):
7964
"from": f"{start}",
8065
"to": "now",
8166
}
82-
reply = requests.post("http://localhost:3000/api/ds/query", json=data)
67+
reply = requests.post(f"{GRAFANA_URL}api/ds/query", json=data)
8368
if reply.status_code != 200:
8469
self.log.error(f"Grafana API request failed with status code {reply.status_code}")
8570
self.log.error(f"Response content: {reply.text}")
@@ -96,7 +81,7 @@ def test_prometheus_and_grafana(self):
9681
self.warnet(f"run {miner_file} --allnodes --interval=5 --mature")
9782
self.warnet(f"run {tx_flood_file} --interval=1")
9883

99-
prometheus_ds = requests.get("http://localhost:3000/api/datasources/name/Prometheus")
84+
prometheus_ds = requests.get(f"{GRAFANA_URL}api/datasources/name/Prometheus")
10085
assert prometheus_ds.status_code == 200
10186
prometheus_uid = prometheus_ds.json()["uid"]
10287
self.log.info(f"Got Prometheus data source uid from Grafana: {prometheus_uid}")

0 commit comments

Comments
 (0)