Add user information for connection.closed
event under the amq.rabbitmq.event
exchange
#6331
-
Hi RabbitMQ. I'm working with the MQTT plugin, and trying to get notifications about MQTT clients connecting & disconnecting. I enabled the Event Exchange Plugin and am able to consume messages from a queue named While Since I do get the My request is to add the same correlation fields to the Attached example events:
{
"fields":{
"consumerTag":"amq.ctag-J3ZBInPWRiX8AsvCw83KMQ",
"deliveryTag":41,
"redelivered":false,
"exchange":"amq.rabbitmq.event",
"routingKey":"connection.created"
},
"properties":{
"contentType":"undefined",
"contentEncoding":"undefined",
"headers":{
"ssl":false,
"client_properties":[
],
"frame_max":0,
"channel_max":1,
"channels":1,
"variable_map":"#{<<\"client_id\">> => <<\"mqttjs_b99a1b36\">>}",
"user_who_performed_action":"device",
"node":"rabbit@bf5a60dffe48",
"connected_at":1667573092655,
"type":"direct",
"vhost":"/",
"user":"device",
"peer_port":35884,
"peer_host":"{0,0,0,0,0,65535,44063,1}",
"name":"172.31.0.1:35884 -> 172.31.0.3:1883",
"port":1883,
"host":"{0,0,0,0,0,65535,44063,3}",
"protocol":"`{'MQTT',\"3.1.1\"}`",
"pid":"<[email protected]>",
"timestamp_in_ms":1667573092655
},
"deliveryMode":2,
"priority":"undefined",
"correlationId":"undefined",
"replyTo":"undefined",
"expiration":"undefined",
"messageId":"undefined",
"timestamp":1667573092,
"type":"undefined",
"userId":"undefined",
"appId":"undefined",
"clusterId":"undefined"
},
"content":"<Buffer >"
}
{
"fields":{
"consumerTag":"amq.ctag-J3ZBInPWRiX8AsvCw83KMQ",
"deliveryTag":42,
"redelivered":false,
"exchange":"amq.rabbitmq.event",
"routingKey":"connection.closed"
},
"properties":{
"contentType":"undefined",
"contentEncoding":"undefined",
"headers":{
"name":"172.31.0.1:35884 -> 172.31.0.3:1883",
"node":"rabbit@bf5a60dffe48",
"pid":"<[email protected]>",
"timestamp_in_ms":1667573092665
},
"deliveryMode":2,
"priority":"undefined",
"correlationId":"undefined",
"replyTo":"undefined",
"expiration":"undefined",
"messageId":"undefined",
"timestamp":1667573092,
"type":"undefined",
"userId":"undefined",
"appId":"undefined",
"clusterId":"undefined"
},
"content":"<Buffer >"
} Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 14 replies
-
I vaguely remember this being requested before but the user information is not available when a connection is closed. @michaelklishin @ansd ? |
Beta Was this translation helpful? Give feedback.
-
Correct, sometimes connections are closed before authenticating successfully so we don't have anything to populate that field with |
Beta Was this translation helpful? Give feedback.
-
@michaelklishin that's understandable, but on the "happy path", when disconnected connections did authenticated, is it still problematic? |
Beta Was this translation helpful? Give feedback.
-
By the way, I the |
Beta Was this translation helpful? Give feedback.
-
In the current implementation, MQTT is proxied via AMQP 0.9.1. It uses something called an "AMQP direct connection" underneath. This creates 2 channels in the We are currently working on "native MQTT" in #5895 which does not use any channels anymore. In that case you won't see From my point of view, it makes sense to add the user to the Feel free to create a PR including a test. rabbitmq-server/deps/rabbitmq_mqtt/test/integration_SUITE.erl Lines 157 to 208 in add7b74 |
Beta Was this translation helpful? Give feedback.
-
Sounds like when #5895 will be done I won't be able to utilize the |
Beta Was this translation helpful? Give feedback.
-
Hi all, I'm evaluating However, I'm going to use a single user to represent all of my IoT devices, where each of them will be connected with a different I am getting the Thank you, 3.12 looks great until now. In general, I wonder if it makes sense to match all the fields under the |
Beta Was this translation helpful? Give feedback.
If someone from the core team thinks that such "inherently optional" metrics make sense, we can add them. But it will mislead some, so we might have to explicitly set this username field to
undefined
in code paths when the connection is closed before successful authentication or access to connection state would be difficult.I don't think refactoring a decade old code path just to access to this field would be worth the effort and risk.