How to monitor NATS messages
search cancel

How to monitor NATS messages

book

Article ID: 293462

calendar_today

Updated On:

Products

Operations Manager

Issue/Introduction

This article describes how to monitor NATS messages.

 


Environment


Resolution

You can set up the NATS client on any host which can access the NATS Virtual Machine (VM) at port 4222. In the following example, it is done in the Operations (Ops) Manager VM. 

Example- root@pivotal-ops-manager:~# gem install nats

  • Monitor NATS messages by subscribing to the messages being published. The format is, "nats-sub -s nats://nats:<password>@<IP>:4222 '>'".
  • You can also specify the subject in the nats-sub command, the subject can be any regular expression, such as "nats-sub -s nats://nats:<password>@<IP>:4222 '>' 'router.register'".

        The output from a test environment is shown below:

ubuntu@pivotal-ops-manager:~$ nats-sub -s nats://nats:[email protected]:4222 '>'
Listening on [>]
[#1] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#2] Received on [router.register] : '{"uris":["proxy-0-p-mysql.internal.system.sunyi.com"],"host":"192.168.27.78","port":80}'
[#3] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#4] Received on [router.register] : '{"uris":["api.system.sunyi.com"],"host":"192.168.27.80","port":9022,"tags":{"component":"CloudController"},"private_instance_id":"98f313ba-b4e8-43db-6ab6-a7f9b580419c"}'
[#5] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#6] Received on [router.register] : '{"uris":["loggregator.system.sunyi.com"],"host":"192.168.27.89","port":8080,"tags":null,"private_instance_id":"5269173b-f6ca-432d-4fb6-c7410dac3967"}'
[#7] Received on [router.register] : '{"uris":["doppler.system.sunyi.com"],"host":"192.168.27.89","port":8081,"tags":null,"private_instance_id":"5269173b-f6ca-432d-4fb6-c7410dac3967"}'
[#8] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#9] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#10] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#11] Received on [router.register] : '{"uris":["proxy-0-p-mysql.internal.system.sunyi.com"],"host":"192.168.27.78","port":80}'
[#12] Received on [router.register] : '{"uris":["uaa.system.sunyi.com","*.uaa.system.sunyi.com","login.system.sunyi.com","*.login.system.sunyi.com"],"host":"192.168.27.83","port":8080,"tags":null,"private_instance_id":"5d073468-4c6e-41e4-7214-bd4bde6bab2f"}'
[#13] Received on [router.register] : '{"uris":["api.system.sunyi.com"],"host":"192.168.27.80","port":9022,"tags":{"component":"CloudController"},"private_instance_id":"98f313ba-b4e8-43db-6ab6-a7f9b580419c"}'
[#14] Received on [router.register] : '{"host":"192.168.27.85","port":60037,"uris":["apps-manager-js.system.sunyi.com","apps.system.sunyi.com/2","console.system.sunyi.com/2"],"app":"8731d53e-f115-4b5e-83f0-a00468bee65c","private_instance_id":"e1bf9481-b9df-44cc-5aa5-fdf2f0449a7a","tags":{"component":"route-emitter"}}'

 

In the examples below, you can see the router register information sent from different components.

Example 1

You can see the information being registered or unregistered in the VM when it is being recreated:

If you run "bosh recreate loggregator_trafficcontroller-partition-1506967bb2eea78b2b46" to recreate the loggregator, there will be a message like the one shown below:

[#85] Received on [router.unregister] : '{"uris":["loggregator.system.sunyi.com"],"host":"192.168.27.89","port":8080,"tags":null,"private_instance_id":"5269173b-f6ca-432d-4fb6-c7410dac3967"}'
[#170] Received on [router.register] : '{"uris":["loggregator.system.sunyi.com"],"host":"192.168.27.89","port":8080,"tags":null,"private_instance_id":"72553d93-d026-4763-673e-7d85c8ce63f4"}'

 

Example 2

You can see the information being registered or unregistered by the application when a route is created or deleted.

In one window, map a route and delete the route. 

ubuntu@pivotal-ops-manager:~$ cf map-route spring-music app.sunyi.com --hostname spring-music-route
Creating route spring-music-route.app.sunyi.com for org system / space david as admin...
OK
Adding route spring-music-route.app.sunyi.com to app spring-music in org system / space david as admin...
OK
ubuntu@pivotal-ops-manager:~$ cf delete-route app.sunyi.com --hostname spring-music-route

Really delete the route spring-music-route.app.sunyi.com?> y
Deleting route spring-music-route.app.sunyi.com...
OK

 

In another window, the following message will be there:

[#4] Received on [router.register] : '{"host":"192.168.27.85","port":60098,"uris":["spring-music-route.app.sunyi.com"],"app":"dc8dc104-9dce-453e-ad75-794bcdba16a8","private_instance_id":"d32eeedd-b451-413a-5925-d6f9c1020f95","tags":{"component":"route-emitter"}}'
[#13] Received on [router.unregister] : '{"host":"192.168.27.85","port":60098,"uris":["spring-music-route.app.sunyi.com"],"app":"dc8dc104-9dce-453e-ad75-794bcdba16a8","private_instance_id":"d32eeedd-b451-413a-5925-d6f9c1020f95","tags":{"component":"route-emitter"}}'

 


Additional Information