Skip to content

Commit d271f99

Browse files
authored
feat: add GORM, add more prometheus metrics with auth, add example configurations for Grafana and Prometheus.
2 parents 07b68ee + 9f2f398 commit d271f99

8 files changed

Lines changed: 950 additions & 84 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ tinyice.json
33
*.log
44
.DS_Store
55
history.db
6+
history.db-shm
7+
history.db-wal
8+
tinyice.db
69
MEDIUM_POST.md
710
music/
811
tests/
912
tinyice.pid
1013
playlists/
14+
.go-cache/
15+
tmp_gocache/
16+
tmp_gomodcache/
17+
bin/
18+
.gemini/
19+
.antigravity/

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,26 @@ bantime = 3600
297297
> **Note**: Once the certificate is successfully obtained and stored in the `certs/` directory, you can revert TinyIce to custom ports (like 8000/8443) if needed.
298298
However, you will need to switch back to ports 80/443 for automatic renewals (typically every 60-90 days).
299299

300+
## Monitoring & Observability
301+
302+
TinyIce provides built-in support for real-time monitoring via Prometheus.
303+
304+
- **Metrics Endpoint**: `/metrics` (Requires Basic Auth)
305+
- **Included Metrics**:
306+
- **Listeners**: Total and per-mount counts.
307+
- **Throughput**: Bytes in/out and dropped packets (health ratio).
308+
- **System**: Memory usage, goroutine counts, GC statistics, and server uptime.
309+
310+
### Grafana Dashboard & Prometheus Config
311+
Example monitoring configurations are available in the repository:
312+
- 📊 **[monitoring/grafana-dashboard.json](monitoring/grafana-dashboard.json)**
313+
- ⚙️ **[monitoring/prometheus.yml](monitoring/prometheus.yml)**
314+
315+
To use them:
316+
1. Add the contents of `prometheus.yml` to your Prometheus configuration (update targets and auth).
317+
2. Import the Grafana JSON file into your Grafana instance.
318+
3. Select your Prometheus data source.
319+
300320
## Command Line Usage
301321

302322
By default, TinyIce will look for `tinyice.json` in the current directory and bind to all interfaces:

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ require (
66
github.com/bogem/id3v2/v2 v2.1.4
77
github.com/braheezy/shine-mp3 v0.1.0
88
github.com/dhowden/tag v0.0.0-20240417053706-3d75831295e8
9-
github.com/glebarez/go-sqlite v1.22.0
9+
github.com/glebarez/sqlite v1.11.0
1010
github.com/gomarkdown/markdown v0.0.0-20260217112301-37c66b85d6ab
1111
github.com/hajimehoshi/go-mp3 v0.3.4
1212
github.com/kazzmir/opus-go v1.2.1
1313
github.com/pion/webrtc/v4 v4.2.8
1414
github.com/sirupsen/logrus v1.9.4
1515
golang.org/x/crypto v0.48.0
1616
golang.org/x/sys v0.41.0
17+
gorm.io/gorm v1.31.1
1718
)
1819

1920
require (
2021
github.com/dustin/go-humanize v1.0.1 // indirect
22+
github.com/glebarez/go-sqlite v1.22.0 // indirect
2123
github.com/google/uuid v1.6.0 // indirect
24+
github.com/jinzhu/inflection v1.0.0 // indirect
25+
github.com/jinzhu/now v1.1.5 // indirect
2226
github.com/mattn/go-isatty v0.0.20 // indirect
2327
github.com/pion/datachannel v1.6.0 // indirect
2428
github.com/pion/dtls/v3 v3.1.2 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
1010
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
1111
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
1212
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
13+
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
14+
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
1315
github.com/gomarkdown/markdown v0.0.0-20260217112301-37c66b85d6ab h1:VYNivV7P8IRHUam2swVUNkhIdp0LRRFKe4hXNnoZKTc=
1416
github.com/gomarkdown/markdown v0.0.0-20260217112301-37c66b85d6ab/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
1517
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
@@ -19,6 +21,10 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
1921
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
2022
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
2123
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
24+
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
25+
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
26+
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
27+
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
2228
github.com/kazzmir/opus-go v1.2.1 h1:uKHJgA4zlZv60eatfwGBhLdrovlPdRVBVco22MQQvmU=
2329
github.com/kazzmir/opus-go v1.2.1/go.mod h1:oKDlLYxYVpknE4zKDmJyiLPB9RyhKw0n/l7EoPr6000=
2430
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
@@ -105,6 +111,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
105111
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
106112
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
107113
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
114+
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
115+
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
108116
modernc.org/libc v1.37.6 h1:orZH3c5wmhIQFTXF+Nt+eeauyd+ZIt2BX6ARe+kD+aw=
109117
modernc.org/libc v1.37.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE=
110118
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=

0 commit comments

Comments
 (0)