> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jethings.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Grafana Setup

> Dashboards and visualization on port 4000

## Install Grafana

```bash theme={null}
sudo mkdir -p /etc/apt/keyrings/
wget -q -O- https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

sudo apt update
sudo apt install -y grafana
```

## Configure the port

Edit `/etc/grafana/grafana.ini` to run on port 4000 instead of the default 3000:

```bash theme={null}
sudo sed -i "s/^;http_port = 3000/http_port = 4000/" /etc/grafana/grafana.ini
```

<Note>
  The line starts commented out with `;http_port = 3000`. Removing the `;` and changing the value is what actually takes effect.
</Note>

## Enable and start

```bash theme={null}
sudo systemctl enable grafana-server
sudo systemctl restart grafana-server
sudo systemctl status grafana-server --no-pager
```

<Check>
  Confirm it's listening on the right port:

  ```bash theme={null}
    sudo ss -tlnp | grep 4000
  ```
</Check>

Default login: `admin` / `admin` (you'll be prompted to change it on first login).

## Add Loki as a data source

In Grafana UI: **Connections → Data sources → Add data source → Loki**

```bash theme={null}
  URL: http://localhost:4100
```

## Reverse proxy (optional)

If exposing Grafana on a subdomain instead of an IP:port, reuse the [Nginx setup](/vps-setup/nginx) pattern with `proxy_pass http://localhost:4000;` and a `server_name grafana.jethings.com;`.

## Useful checks

```bash theme={null}
sudo systemctl status grafana-server --no-pager
sudo journalctl -u grafana-server -f
```
