IOx Messaging Service
Managing topics
Commands under managing topics are:
~$ioxclient service infrastructure messaging topics
NAME:
ioxclient service infrastructure messaging topics - create/delete/publish topics
USAGE:
ioxclient service infrastructure messaging topics command [command options] [arguments...]
COMMANDS:
create, cr Create a topic
delete, del Delete a topic
publish, pub Publish into a topic
help, h Shows a list of commands or help for one command
Creating a topic
Any topic of the user's choice can be created by specifying a name for a topic to be created
~$ioxclient svc infrastructure messaging topics cr sampleTopic
Currently active profile : vm211
Command Name: service-infrastructure-topics-create
Url formed is - https://10.78.106.211:40001/api/v1/mw/topics/sampleTopic
Successfully added Topic
Publishing to a topic
Data can be published to a topic either by passing the json data in the required format as command line argument or by specifying a file using the --file flag
~$ioxclient svc infrastructure messaging topics publish --file test_resources\middleware-files\topics.json
Currently active profile : vm211
Command Name: service-infrastructure-topics-publish-create
Sending https request to https://10.78.106.211:40001/api/v1/mw/topics/publish/
{
"topic": "sampleTopic",
"context" : {
"prop1": "value1",
"prop2": "value2"
},
"message" : {
"id": 5,
"severity": "warn",
"description": "unable to contact northbound"
}
}
Successfully published the topic
Deleting a topic
A topic can be deleted by specifying the name of the topic
~$ioxclient svc infrastructure messaging topics del sampleTopic
Currently active profile : vm211
Command Name: service-infrastructure-topics-delete
Url is https://10.78.106.211:40001/api/v1/mw/topics/sampleTopic
Successfully Deleted sampleTopic
Publish / Subscribe Messages using Websockets
IOx Service infrastructure allows using websockets to allow the user to publish or subscribe to/from a topics.
~$ioxclient service infrastructure websocket
NAME:
ioxclient service infrastructure websocket - To stream data from the socket
USAGE:
ioxclient service infrastructure websocket command [command options] [arguments...]
COMMANDS:
subscribe, sub Stream data from a websocket
publish, pub Publish data through a websocket
help, h Shows a list of commands or help for one command
Topic Subscription using websocket
~$ioxclient svc infra msg ws sub sampleTopic
Currently active profile : vm211
Command Name: service-infrastructure-messaging-websocket-subscribe
{"context":{"prop1":"value1","prop2":"value2"},"topic":"sampleTopic","message":{"id":5,"severity":"warn","description":"This is a sample publish"}}
{"context":{"prop1":"value1","prop2":"value2"},"topic":"sampleTopic","message":{"id":5,"severity":"warn","description":"This is a sample 2nd publish"}}
{"context":{"prop1":"value1","prop2":"value2"},"topic":"sampleTopic","message":{"id":5,"severity":"warn","description":"This is a sample 3rd publish"}}
Publish Messages Using websocket
~$ioxclient svc infra msg ws pub test_resources\middleware-files\topics.json
Currently active profile : vm211
Command Name: service-infrastructure-messaging-websocket-publish
No of characters written 247
IOx Service Infrastructure - Metrics
In order to aid in troubleshooting issues, IOX Service Infrastructure maintains various metrics. These metrics are mostly in the form of counters, meters, guages, histograms, etc
View metrics
~$ioxclient service infrastructure metrics
Currently active profile : vm211
Command Name: service-infrastructure-metrics
https://10.78.106.211:40001/api/v1/mw/metrics
0 . system:service:protocolHandler:mqtt-broker
1 . system:service:mqttstoreandforward
2 . logconfig
3 . system:service:coapstoreandforward
4 . token
5 . system:service:coap-proxy
6 . system:service:protocolHandler:modbus-async-tcp
7 . system:service:protocolHandler:coap-server
8 . mlib-rpc.IOxMiddlewareServices
9 . mlib-threadpool.IOxMiddlewareServices
10 . system:service:provisioning
11 . system:service:data:snapshot
14 . mlib-pubsub.IOxMiddlewareServices
Enter the serial Number of the required metric
1
{
"stats": [
{
"name": "numberOfNBIRequestsFailed",
"type": "counter",
"count": 0
},
{
"name": "numberOfNBIRequestsSucceeded",
"type": "counter",
"count": 0
},
{
"name": "numberOfPolicies",
"type": "counter",
"count": 0
}
],
"policies": {
"type": "composite",
"kind": "sf#policy#collection"
}
}
Log services
The log services allow us to list the modules and their log levels of a particular service. A user could also set the log level of a particular module with this command The command structure of log services is
~$ioxclient service infrastructure logservice --help
NAME:
logservice - Use log services to view the available modules and set their log levels
USAGE:
command logservice [command options]
DESCRIPTION:
To list the modules of a service -
ioxclient service infra --service service_name
In order to set the log level of a module in a given service,
ioxclient service infra --service svc_name --module mod_name -- level log_level
OPTIONS:
--service, --svc Specify the service of the module
--module, --mod Specify the module who's log level has to be set
--level, --lvl Specify the log level that is to be set
List modules
To list th modules and their log levels of a given service, specify the service name using the --service flag as follows
~$ioxclient service infra logservice --svc mw
Currently active profile : vm211
Command Name: service-infrastructure-logservice
Sending HTTP request to - https://10.78.106.211:40001/api/v1/mw/logs/mw/modules
-------------HTTP Response----------------
{
"system:service:protocolHandler:modbus-async-tcp": "warning",
"urn:cisco:system:service:data:snapshot": "trace",
"urn:cisco:system:service:provisioning": "error"
}
Set log level module
To set the log level of a module, specify the service name using the --service flag, the module with the --module flag and the log level using the --level flag The log levels could be INFO, WARN,ERROR,DEBUG,TRACE
~$ioxclient service infra logservice --service mw --module system:service:protocolHandler:modbus-async-tcp --level trace
Currently active profile : vm211
Command Name: service-infrastructure-logservice
Sending HTTP request to - https://10.78.106.211:40001/api/v1/mw/logs/mw/modules/system:service:protocolHandler:modbus-async-tcp?level=trace
Successfully changed the log level of system:service:protocolHandler:modbus-async-tcp to trace
In order to verify the succesful setting of the log level, list the modules using
~$ioxclient service infra logservice --service mw
The log level of the module which was updated should show the same log level In the above example, we set the log level of "system:service:protocolHandler:modbus-async-tcp" to "trace" Hence, the list should be displaying this -
~$ioxclient service infra logservice --service mw
Currently active profile : vm211
Command Name: service-infrastructure-logservice
Sending HTTP request to - https://10.78.106.211:40001/api/v1/mw/logs/mw/modules
-------------HTTP Response----------------
{
"system:service:protocolHandler:modbus-async-tcp": "trace",
"urn:cisco:system:service:data:snapshot": "trace",
"urn:cisco:system:service:provisioning": "error"
}