Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,33 @@
on:
pull_request:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- id: load-registry-credentials
if: ${{ github.triggering_actor != 'dependabot[bot]' }}
uses: 1password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: false
version: 2.33.1
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_RUNWAYOSS_SERVICE_ACCOUNT }}
REGISTRY_USERNAME: "op://RunwayOSS/robot-harbor-quantum-public/username"
REGISTRY_PASSWORD: "op://RunwayOSS/robot-harbor-quantum-public/password"
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: docker/setup-buildx-action@v4
- if: ${{ github.triggering_actor != 'dependabot[bot]' }}
uses: docker/login-action@v4
with:
registry: r.planetary-quantum.com
username: ${{ secrets.QUANTUM_REGISTRY_USER }}
password: ${{ secrets.QUANTUM_REGISTRY_PASSWORD }}
registry: r.planetary-quantum.com/quantum-public
username: ${{ steps.load-registry-credentials.outputs.REGISTRY_USERNAME }}
password: ${{ steps.load-registry-credentials.outputs.REGISTRY_PASSWORD }}
- name: build and push
id: docker_build
uses: docker/build-push-action@v7
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ on:
branches:
- main

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- id: load-registry-credentials
uses: 1password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: false
version: 2.33.1
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_RUNWAYOSS_SERVICE_ACCOUNT }}
REGISTRY_USERNAME: "op://RunwayOSS/robot-harbor-quantum-public/username"
REGISTRY_PASSWORD: "op://RunwayOSS/robot-harbor-quantum-public/password"
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: r.planetary-quantum.com
username: ${{ secrets.QUANTUM_REGISTRY_USER }}
password: ${{ secrets.QUANTUM_REGISTRY_PASSWORD }}
registry: r.planetary-quantum.com/quantum-public
username: ${{ steps.load-registry-credentials.outputs.REGISTRY_USERNAME }}
password: ${{ steps.load-registry-credentials.outputs.REGISTRY_PASSWORD }}
- name: build and push
id: docker_build
uses: docker/build-push-action@v7
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM r.planetary-quantum.com/docker-hub-proxy/grafana/grafana-oss:10.4.2
FROM r.planetary-quantum.com/docker-hub-proxy/grafana/grafana:13.3.1

# install https://github.com/noqcks/gucci (CLI templating)
USER root
Expand All @@ -10,7 +10,8 @@ USER grafana

COPY --chown=grafana datasource.tpl.yaml /tmp/datasource.tpl.yaml
COPY --chown=grafana dashboard-provider.yaml /etc/grafana/provisioning/dashboards/dashboard-provider.yml
COPY --chown=grafana swarm-dashboard.json /var/lib/grafana/dashboards/swarm.json
# not below /var/lib/grafana: the volume there would hide updated dashboards
COPY --chown=grafana dashboards/ /etc/grafana/dashboards/

ENTRYPOINT ["/bin/sh", "-c"]
CMD ["export GF_SECURITY_ADMIN_PASSWORD=\"$INITIAL_ADMIN_PASSWORD\" && gucci /tmp/datasource.tpl.yaml > /etc/grafana/provisioning/datasources/loki.yml && /run.sh"]
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
IMAGE?=quantum-grafana:dev

.PHONY: build
build:
docker build --platform linux/amd64 -t $(IMAGE) -f Dockerfile .

.PHONY: lint
lint:
@for f in dashboards/*.json; do \
jq empty $$f || exit 1; \
done
@echo "dashboards: ok"

.PHONY: test
test: lint build
IMAGE=$(IMAGE) ./test.sh

.PHONY: run-dev
run-dev: build
docker run --rm \
--platform linux/amd64 \
-p 3000:3000 \
-e INITIAL_ADMIN_PASSWORD=admin \
$(IMAGE)

.PHONY: manual-push
manual-push:
docker build -t quay.io/pngmbh/quantum-grafana:next -f Dockerfile .
docker push quay.io/pngmbh/quantum-grafana:next
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,47 @@ Then follow these two steps:

### Create stack file

Copy the `cp docker-compose.example.yml docker-compose.yml`, and edit it:
Run `cp docker-compose.example.yml docker-compose.yml`, and edit it:

* set the `traefik.frontend.rule` label to include the hostname of your endpoint/cluster (or your custom domain, if you want that)
* set `INITIAL_ADMIN_PASSWORD` to something random
* set `QUANTUM_ENDPOINT` to the name of your endpoint/cluster

### Deploy it

```
$ QUANTUM_ENDPOINT=your-cluster-name
$ quantum-cli stack update --create --wait --stack "grafana-$QUANTUM_ENDPOINT"
> [!TIP]
> Use our GitHub Action: [setup-quantum-cli](https://github.com/hostwithquantum/setup-quantum-cli).

```sh
$ export QUANTUM_ENDPOINT=your-cluster-name
$ quantum-cli stack deploy --stack "grafana-$QUANTUM_ENDPOINT"
```

## Basic usage

* on the left-hand side menu choose "Explore"
![explore menu screenshot](img/explore_menu.png)
* select "Docker Logs" at the top, and click on "Logs" right next to it
* select "Logs" at the top, and click on "Logs" right next to it
![docker logs selection screenshot](img/docker_logs.png)
* select some log label via the drop-down next to the search bar
![log label selection](img/log_labels.png)
* you should now see your logs

For metrics: go to Dashboards :point_right: Manage. There should be one pre-configured dashboard "Usage by Stack".
For metrics: go to Dashboards. These dashboards are pre-configured:

* "Nodes Overview": size and usage (CPU, RAM, disk) of each node, with links to the other two
* "Usage By Stack": usage per node, stack and service
* "Node Exporter Full": all details of a single node

## Development

The dashboards live in [dashboards](dashboards/). They are copies from our internal Grafana:

* `swarm.json` keeps its `uid`, so existing links continue to work
* `node-exporter.json` is [1860](https://grafana.com/grafana/dashboards/1860) with a patch: the host is selected by `instance`, not by `nodename`

```
$ make lint # validate the dashboards
$ make test # build the image, start it, check the provisioning
$ make run-dev # http://localhost:3000 (admin/admin)
```
2 changes: 1 addition & 1 deletion dashboard-provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ providers:
allowUiUpdates: true
options:
# <string, required> path to dashboard files on disk. Required when using the 'file' type
path: /var/lib/grafana/dashboards
path: /etc/grafana/dashboards
# <bool> use folder names from filesystem to create folders in Grafana
foldersFromFilesStructure: true
Loading