You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionneeds-triageNew issues needed to be validated
A new metric that exposes the connection state of each device as a gauge value (e.g., 0 = disconnected; 1 = connected, ...).
Problem or use case
I have an android device where the operating system frequently kills the syncthing app.
I want to monitor, using prometheus, whether the device is connected with my central syncthing node and get alerted if it is disconnected for an extended period of time.
Alternatives or workarounds
Create a custom exporter that uses the syncthing API.
If this is something you would be interested into having, I can try to open a PR for it.
Sounds reasonable. I'd probably make it a gauge on the number of connections, so zero is disconnected and then positive numbers for connected devices.
Oh, then I probably didn't phrase it good enough 😅
My plan was to do it specific to the device ID, e.g.,
# specific device connected:
syncthing_protocol_connection_state{device="DEVICE-A"} 1
# specific device not connected:
syncthing_protocol_connection_state{device="DEVICE-B"} 0
I agree, but a single device can have an arbitrary number of active connections nowadays. So, what you're proposing, but 1 can also become 3 or 28.
syncthing_protocol_connections_active{device="DEVICE-A"} 28 # connected, large number of concurrent data connections
syncthing_protocol_connections_active{device="DEVICE-b"} 0 # disconnected
I agree, but a single device can have an arbitrary number of active connections nowadays. So, what you're proposing, but 1 can also become 3 or 28.
syncthing_protocol_connections_active{device="DEVICE-A"} 28 # connected, large number of concurrent data connections
syncthing_protocol_connections_active{device="DEVICE-b"} 0 # disconnected
After looking around a bit I found connections.accountAddedConnection & connections.accountRemovedConnection as functions where I can add the Inc & Dec calls. The connections package currently doesn't have its own metrics.go, so I would add one.
I however don't know if this is the best location. I've also found protocol.NewConnection & protocol.internalClose and model.AddConnection & model.Closed.
It would be great if you could point me to the location you would consider to be suitable.
I think the accounting functions you found are a good place. There's probably some map or slice there that has the number of connections you can get the length of, or just pair the inc/dec as you say.
So (if I may) how does one use this new functionality? I am not even clear whether the new feature is GUI or CLI.
Syncthing exposes a bunch of metrics on .../metrics (e.g. 127.0.0.1:8384/metrics) which can be handled by some prometheus instance or alike. And this change simply exposes one more metric there.
enhancementNew features or improvements of some kind, as opposed to a problem (bug)frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionneeds-triageNew issues needed to be validated
Activity
calmh commentedon May 3, 2024
Sounds reasonable. I'd probably make it a gauge on the number of connections, so zero is disconnected and then positive numbers for connected devices.
DerRockWolf commentedon May 3, 2024
Oh, then I probably didn't phrase it good enough 😅
My plan was to do it specific to the device ID, e.g.,
calmh commentedon May 3, 2024
I agree, but a single device can have an arbitrary number of active connections nowadays. So, what you're proposing, but
1can also become3or28.DerRockWolf commentedon May 3, 2024
Got it, thanks for clarifying.
I'll try to implement it and open a PR 🙂
DerRockWolf commentedon May 4, 2024
After looking around a bit I found
connections.accountAddedConnection&connections.accountRemovedConnectionas functions where I can add theInc&Deccalls. Theconnectionspackage currently doesn't have its ownmetrics.go, so I would add one.I however don't know if this is the best location. I've also found
protocol.NewConnection&protocol.internalCloseandmodel.AddConnection&model.Closed.It would be great if you could point me to the location you would consider to be suitable.
calmh commentedon May 4, 2024
I think the accounting functions you found are a good place. There's probably some map or slice there that has the number of connections you can get the length of, or just pair the inc/dec as you say.
metrics: add syncthing_connections_active in connections package (fixes
metrics: add syncthing_connections_active in connections package (fixes
lib/connections: Add syncthing_connections_active metric (fixes #9527) (
Merge branch 'main' into geoip
Merge branch 'main' into indexrefactor2
LinuxOnTheDesktop commentedon Jun 5, 2024
So (if I may) how does one use this new functionality? I am not even clear whether the new feature is GUI or CLI.
er-pa commentedon Jun 5, 2024
Syncthing exposes a bunch of metrics on
.../metrics(e.g.127.0.0.1:8384/metrics) which can be handled by some prometheus instance or alike. And this change simply exposes one more metric there.https://docs.syncthing.net/users/metrics.html
Merge tag 'v1.27.8' into ios_try_syncthing_v1.27.8
Merge branch 'main' into integrationtests
Merge branch 'main' into integrationtests