https://github.com/fogbender/supafana
Supafana is a one-click, Grafana and Prometheus metrics, observability, and alerting solution for Supabase
https://github.com/fogbender/supafana
alerting azure elixir grafana nix observability prometheus supabase
Last synced: 3 months ago
JSON representation
Supafana is a one-click, Grafana and Prometheus metrics, observability, and alerting solution for Supabase
- Host: GitHub
- URL: https://github.com/fogbender/supafana
- Owner: fogbender
- License: mit
- Created: 2024-08-26T20:19:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-26T06:01:55.000Z (about 1 year ago)
- Last Synced: 2025-01-31T10:51:14.179Z (about 1 year ago)
- Topics: alerting, azure, elixir, grafana, nix, observability, prometheus, supabase
- Language: Elixir
- Homepage: https://supafana.com
- Size: 11.3 MB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 
# Supafana
## https://supafana.com
## Observability and alerting SaaS for [Supabase](https://supabase.com), based on [supabase-grafana](https://github.com/supabase/supabase-grafana)

### Building and pushing supabase-grafana Docker image
``` bash
az login
az acr login --name supafanacr
docker build supabase-grafana --tag supabase-grafana
docker tag supabase-grafana supafanacr.azurecr.io/supabase-grafana:
docker push supafanacr.azurecr.io/supabase-grafana:
```
- Update VM grafana image with new in `nix/hosts/grafana/grafana-container.nix`.
- Upload new VM grafana image version (see next section).
### NixOS Azure image creation/upload
To test Azure image build:
> nix build '.#supafana-image'
This should create a `result` directory containing a VHD image.
To create and upload an image to Azure:
``` bash
az login
# Upload supafana image
./scripts/azure-upload-image-gallery.sh \
-g supafana-common-rg \
-r supafanasig \
-n supafana \
-v '0.0.1' \
-l eastus \
-i '.#supafana-image'
# Upload grafana image
./scripts/azure-upload-image-gallery.sh \
-g supafana-common-rg \
-r supafanasig \
-n grafana \
-v '0.0.1' \
-l eastus \
-i '.#grafana-image'
```
### Grafana instance provisioning
Run the `./infra/modules/grafana-template.bicep` template with the following parameters:
- supabaseProjectRef - supabase project reference id
- supabaseServiceRoleKey - service role key
- supafanaDomain - Supafana domain (supafana-test.com for test, supafana.com for prod)
- grafanaPassword - optional: admin user password (default password is `admin`)
Use `supafana-test-rg` resource group for test env deployment.
See examples in `./infra/resources/grafana-mk-{1,2}.bicepparam
``` bash
az deployment group create -c --debug --name supafana-test-grafana-mk-1-deploy --resource-group supafana-test-rg --parameters infra/resources/grafana-mk-1.bicepparam
```
After provisioning, the host should be accessible via `https:///dashboard/`
- Example: `https://supafana-test.com/dashboard/kczjrdfrkmmofxkbjxex/`
Internally, the new instance is accessible via `supafana--grafana-.supafana-.local`
- Example: `supafana-prod-grafana-xjzrrbkmeubsmkgdwgfq.supafana-prod.local`
#### SSH access to Grafana instances
Grafana instances don't have public IPs and can be accessed only via our main servers (supafana-test.com and supafana.com).
To simplify access (to supafana-test.com), add the following lines to your `~/.ssh/config` file:
```
#test access
Host *.supafana-test.local
ProxyJump admin@supafana-test.com
#prod access
Host *.supafana-prod.local
ProxyJump admin@supafana.com
```
With this, Grafana instances can be accessed directly, e.g., `ssh admin@supafana-prod-grafana-xjzrrbkmeubsmkgdwgfq.supafana-prod.local`
While there, to access the Elixir shell of the running app:
```
supafana remote
```
#### Grafana instance internals
Internally, each Grafana instance runs on a NixOS VM, which, in turn, runs the `supafana-grafana` container as a `podman-grafana` systemd service.
To examine the service, use systemd commands:
- `systemctl status podman-grafana`
- `journalctl -u podman-grafana`
To get into a Grafana container, run `podman exec`:
- `sudo podman exec -ti grafana bash`
More info about working with containers:
- `sudo podman ps`
- `sudo podman inspect grafana`
#### Deleting Grafana instances and resources
All resources created for a particular Grafana instance are tagged with `vm:supafana--grafana-`. To delete them, filter all resources by tag:
``` bash
az resource list --tag vm=supafana--grafana- --query "[].id" -o tsv
```
Then, delete:
``` bash
az resource list --tag vm='supafana-prod-grafana-kczjrdfrkmmofxkbjxex' --query "[].id" -o tsv | xargs -I {} az resource delete --ids {}
```
### Generate Supabase API types
> cd storefront && npx openapi-typescript https://api.supabase.com/api/v1-json -o src/types/supabase-api-schema.d.ts