AnalogJ / scrutiny

Hard Drive S.M.A.R.T Monitoring, Historical Trends & Real World Failure Thresholds
MIT License
4.72k stars 154 forks source link

[BUG] Need write access on all influxdb buckets #561

Closed remz1337 closed 6 months ago

remz1337 commented 6 months ago

Describe the bug I have a Proxmox server with a few LXC, including influxdb that already has a few buckets (including proxmox stats). Thus, I want to reuse that influxdb server by adding a bucket for scrutiny and generate an API token with minimal access to improve security and avoid messing with my other data. My influxdb has a single organization with a few buckets. I created a scrutiny bucket and generated an API token with read/write access only to that bucket (+ Read to All org and read/write to All tasks).

Scrutiny throws the following error: panic: unauthorized: write:orgs/7dfc21b40d851f55/buckets is unauthorized

I fixed it by generating a new API token with read/write on All buckets.

Expected behavior Maybe I'm missing something, I don't understand why Scrutiny would need write on my other buckets. Expected behaviour: write access only on bucket defined in config.

Screenshots If applicable, add screenshots to help explain your problem.

Log Files

2024/01/04 22:23:29 Loading configuration file: /opt/scrutiny/config/scrutiny.yaml

 ___   ___  ____  __  __  ____  ____  _  _  _  _
/ __) / __)(  _ \(  )(  )(_  _)(_  _)( \( )( \/ )
\__ \( (__  )   / )(__)(   )(   _)(_  )  (  \  /
(___/ \___)(_)\_)(______) (__) (____)(_)\_) (__)
github.com/AnalogJ/scrutiny                     linux.amd64-0.7.2

Start the scrutiny server
2024/01/04 22:23:29 Loading configuration file: /opt/scrutiny/config/scrutiny.yaml
INFO[0000] Trying to connect to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db  type=web
INFO[0000] Successfully connected to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db  type=web
INFO[0000] InfluxDB certificate verification: true       type=web
panic: unauthorized: write:orgs/7dfc21b40d851f55/buckets is unauthorized

goroutine 1 [running]:
github.com/analogj/scrutiny/webapp/backend/pkg/web/middleware.RepositoryMiddleware({0x11b4088?, 0xc00009ed90?}, {0x11b8790?, 0xc0003a3570?})
        /home/runner/work/scrutiny/scrutiny/webapp/backend/pkg/web/middleware/repository.go:15 +0xd6
github.com/analogj/scrutiny/webapp/backend/pkg/web.(*AppEngine).Setup(0xc000097698, 0x10349ee?)
        /home/runner/work/scrutiny/scrutiny/webapp/backend/pkg/web/server.go:26 +0xa5
github.com/analogj/scrutiny/webapp/backend/pkg/web.(*AppEngine).Start(0xc000097698)
        /home/runner/work/scrutiny/scrutiny/webapp/backend/pkg/web/server.go:82 +0x12c
main.main.func2(0xc000364c40)
        /home/runner/work/scrutiny/scrutiny/webapp/backend/cmd/scrutiny/scrutiny.go:133 +0x39c
github.com/urfave/cli/v2.(*Command).Run(0xc00037b7a0, 0xc000364ac0)
        /home/runner/work/scrutiny/scrutiny/vendor/github.com/urfave/cli/v2/command.go:164 +0x5c8
github.com/urfave/cli/v2.(*App).RunContext(0xc000262600, {0x11ab5b8?, 0xc0000a6020}, {0xc0000a4040, 0x4, 0x4})
        /home/runner/work/scrutiny/scrutiny/vendor/github.com/urfave/cli/v2/app.go:306 +0xbac
github.com/urfave/cli/v2.(*App).Run(...)
        /home/runner/work/scrutiny/scrutiny/vendor/github.com/urfave/cli/v2/app.go:215
main.main()
        /home/runner/work/scrutiny/scrutiny/webapp/backend/cmd/scrutiny/scrutiny.go:158 +0x774
remz1337 commented 6 months ago

Food for thought, maybe have the collector write directly to influxdb, without going through the webapp

AnalogJ commented 6 months ago

Hey @remz1337 were you following the INFLUXDB troubleshooting instructions? https://github.com/AnalogJ/scrutiny/blob/master/docs/TROUBLESHOOTING_INFLUXDB.md

Specifically the section titled Bring your own InfluxDB

remz1337 commented 6 months ago

oh, I did not see that. Thanks for pointing it out! It would be nice to have that link in the manual installation section of the README. Awesome library, thanks for your work :)