Skip to content

Commit

Permalink
grafana running behind caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
m3dwards committed Sep 6, 2024
1 parent 082f3d9 commit 396f87d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion resources/charts/caddy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ caddyConfig: |
}
handle_path /grafana/* {
reverse_proxy grafana:3000
reverse_proxy loki-grafana:80
}
}
Expand Down
3 changes: 3 additions & 0 deletions resources/manifests/grafana_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ grafana.ini:
auth:
disable_login_form: true
disable_signout_menu: true
server:
# this is required to use Grafana behind a reverse proxy (caddy)
root_url: "%(protocol)s://%(domain)s:%(http_port)s/grafana/"
auth.anonymous:
enabled: true
org_name: Main Org.
Expand Down
4 changes: 3 additions & 1 deletion test/data/logging/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ nodes:
metrics: txrate=getchaintxstats(10)["txrate"]
- name: tank-0002
connect:
- tank-0000
- tank-0000
caddy:
enabled: true
27 changes: 6 additions & 21 deletions test/logging_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import logging
import os
import threading
from datetime import datetime
from pathlib import Path
from subprocess import PIPE, Popen, run
from subprocess import run

import requests
from test_base import TestBase

GRAFANA_URL = "http://localhost:2019/grafana/"


class LoggingTest(TestBase):
def __init__(self):
Expand All @@ -35,22 +36,6 @@ def start_logging(self):
self.log.info("Running install_logging.sh")
# Block until complete
run([f"{self.scripts_dir / 'install_logging.sh'}"])
self.log.info("Running connect_logging.sh")
# Stays alive in background
self.connect_logging_process = Popen(
[f"{self.scripts_dir / 'connect_logging.sh'}"],
stdout=PIPE,
stderr=PIPE,
bufsize=1,
universal_newlines=True,
)
self.log.info("connect_logging.sh started...")
self.connect_logging_thread = threading.Thread(
target=self.output_reader,
args=(self.connect_logging_process.stdout, self.connect_logging_logger.info),
)
self.connect_logging_thread.daemon = True
self.connect_logging_thread.start()

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

def check_endpoint():
try:
response = requests.get("http://localhost:3000/login")
response = requests.get(f"{GRAFANA_URL}login")
return response.status_code == 200
except requests.RequestException:
return False
Expand All @@ -79,7 +64,7 @@ def make_grafana_api_request(self, ds_uid, start, metric):
"from": f"{start}",
"to": "now",
}
reply = requests.post("http://localhost:3000/api/ds/query", json=data)
reply = requests.post(f"{GRAFANA_URL}api/ds/query", json=data)
if reply.status_code != 200:
self.log.error(f"Grafana API request failed with status code {reply.status_code}")
self.log.error(f"Response content: {reply.text}")
Expand All @@ -96,7 +81,7 @@ def test_prometheus_and_grafana(self):
self.warnet(f"run {miner_file} --allnodes --interval=5 --mature")
self.warnet(f"run {tx_flood_file} --interval=1")

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

0 comments on commit 396f87d

Please sign in to comment.