My device connect to Hono MQTT adapter via a gateway. I want to know the number of devices currently connected.
I can only find some metrics from this documentation(https://www.eclipse.org/hono/docs/api/metrics/) One metrics named "hono.connections.authenticated" indicates that current number of connected authenticated devices. But I can only see the number of gateway connections from this indicator, what I want to know is the number of connections for non-gateway devices
So does hono provide corresponding metrics indicating the number of non-gateway devices?
Thanks for any useful suggestions.
As you correctly pointed out, the hono.connections.authenticated gauge also tells you how many devices are currently connected to any of Hono's protocol adapters which have successfully authenticated. Because edge devices that connect via a gateway do not themselves get authenticated by adapters (only the gateway is being authenticated and is then trusted to act on behalf of the edge devices), this gauge does not include such edge devices.
I currently do not see how these edge devices could be included in that gauge, simply because the protocol adapters only get to see them once they start sending data or the gateway subscribes to commands on their behalf.
What you could do is evaluate the hono.messages.received timer in order to determine the number of distinct devices that have sent/received data during a particular period of time, e.g. the last 2 minutes. Assuming that the data is being collected by a Prometheus server, the corresponding meter to query would be hono_messages_received_seconds_count.