Skip to content

Commit 81d7d27

Browse files
committed
feat: gsw service and grafana provisioning
1 parent 9e120ba commit 81d7d27

11 files changed

Lines changed: 131 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Once set up, the grafana_live application can be run from the root directory (wi
4646
Make sure the GSW service is running before starting the application.
4747

4848
In case the setup utility does not work, live data streaming can be set up manually as follows:
49-
1. Import a new dashboard into Grafana using the JSON file located at `data/grafana/Backplane-Live.json`. The dashboard can have any name and UID.
49+
1. Import a new dashboard into Grafana using the JSON file located at `data/grafana/dashboards/Backplane-Live.json`. The dashboard can have any name and UID.
5050
2. Create a service account at the following URL: [http://localhost:3000/org/serviceaccounts/create](http://localhost:3000/org/serviceaccounts/create) (replace `http://localhost:3000` if you are using a different host).
5151
The service account can have any display name but must be given the Admin role ([More information about creating service accounts](https://grafana.com/docs/grafana/latest/administration/service-accounts/)).
5252
3. Click "Add service account token" and then "Generate token". The token can have any display name. Don't set an expiration date unless you want the token to become invalid after that date.

cmd/Containerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM golang:1.25-alpine AS build
2+
3+
RUN apk add --update --no-cache build-base
4+
5+
# TODO: document how to use delve
6+
RUN --mount=type=cache,target=/root/.cache/go-build \
7+
CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest
8+
9+
WORKDIR /go/src/app
10+
11+
COPY go.mod .
12+
COPY go.sum .
13+
14+
RUN --mount=type=cache,id=gsw_mod,target=/go/pkg/mod \
15+
go mod download
16+
17+
COPY . .
18+
19+
RUN --mount=type=cache,id=gsw_mod,target=/go/pkg/mod \
20+
--mount=type=cache,id=gsw_build,target=/root/.cache/go-build \
21+
CGO_ENABLED=1 GOOS=linux go build \
22+
-trimpath \
23+
-o out/gsw_service \
24+
-v \
25+
# delve
26+
-gcflags "all=-N -l" \
27+
./cmd/gsw_service.go
28+
29+
RUN --mount=type=cache,id=gsw_mod,target=/go/pkg/mod \
30+
--mount=type=cache,id=gsw_build,target=/root/.cache/go-build \
31+
for binary in grafana_live live_setup mem_view benchmark telem_view udp_command; do \
32+
CGO_ENABLED=1 GOOS=linux go build \
33+
-trimpath \
34+
-o out/$binary \
35+
-v \
36+
# delve
37+
-gcflags "all=-N -l" \
38+
./cmd/$binary/$binary.go; \
39+
done
40+
41+
FROM alpine
42+
43+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
44+
45+
COPY data /opt/app/data
46+
RUN mkdir -p /opt/app/data/logs && chown -R appuser:appgroup /opt/app/data/logs
47+
48+
COPY --from=build /go/bin/dlv /usr/bin/dlv
49+
COPY --from=build /go/src/app/out/ /usr/bin/
50+
51+
WORKDIR /opt/app
52+
53+
USER appuser
54+
55+
ENTRYPOINT [ "gsw_service" ]

cmd/live_setup/live_setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"strings"
1717
)
1818

19-
const DashboardJsonFile = "data/grafana/Backplane-Live.json"
19+
const DashboardJsonFile = "data/grafana/dashboards/Backplane-Live.json"
2020

2121
// Prompts the user for the Grafana username, password, and URL.
2222
// Returns a URL to Grafana containing the username and password info for basic auth.

compose.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
services:
2+
gsw:
3+
build:
4+
context: .
5+
dockerfile: cmd/Containerfile
6+
depends_on:
7+
influxdb:
8+
condition: service_started
9+
grafana:
10+
condition: service_started
11+
ports:
12+
- 11020:11020/udp
13+
- 13020:13020/udp
14+
- 12005:12005/udp
15+
- 12006:12006/udp
16+
- 12002:12002/udp
17+
18+
grafana:
19+
build:
20+
context: data/grafana
21+
dockerfile: Containerfile
22+
ports:
23+
- "127.0.0.1:3000:3000"
24+
depends_on:
25+
influxdb:
26+
condition: service_started
27+
environment:
28+
- GSW_GRAFANA_INFLUXDB_URL=http://influxdb:8086
29+
- GSW_GRAFANA_INFLUXDB_USER=root
30+
- GSW_GRAFANA_INFLUXDB_PASSWORD=root
31+
- GF_AUTH_ANONYMOUS_ENABLED=true
32+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
33+
- GF_AUTH_BASIC_ENABLED=false
34+
volumes:
35+
- grafana-data:/var/lib/grafana
36+
influxdb:
37+
image: influxdb:1.11-alpine
38+
volumes:
39+
- influxdb-data:/var/lib/influxdb
40+
environment:
41+
- INFLUXDB_UDP_ENABLED=true
42+
43+
volumes:
44+
grafana-data:
45+
influxdb-data:

data/grafana/Containerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM grafana/grafana
2+
3+
COPY dashboards /etc/grafana/provisioning/gsw-dashboards
4+
COPY provisioning/datasources /etc/grafana/provisioning/datasources
5+
COPY provisioning/gsw-dashboard-provider.yaml /etc/grafana/provisioning/dashboards/gsw-dashboard-provider.yaml
File renamed without changes.
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: GSW InfluxDB
5+
uid: gsw-influxdb
6+
type: influxdb
7+
access: proxy
8+
9+
user: $GSW_GRAFANA_INFLUXDB_USER
10+
url: $GSW_GRAFANA_INFLUXDB_URL
11+
secureJsonData:
12+
password: $GSW_GRAFANA_INFLUXDB_PASSWORD

0 commit comments

Comments
 (0)