Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit fca36f0

Browse files
jpeddicordmm318
authored andcommitted
Initial commit
0 parents  commit fca36f0

16 files changed

+1213
-0
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*Issue #, if available:*
2+
3+
*Description of changes:*
4+
5+
6+
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
install:
2+
- git clone https://github.com/ros-industrial/industrial_ci.git .ros_ci
3+
script:
4+
- .ros_ci/travis.sh

README.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# cloudwatch_metrics_collector
2+
3+
4+
## Overview
5+
The `cloudwatch_metrics_collector` ROS Node publishes your robot's metrics to the cloud to enable you to easily track the health of a fleet with the use of automated monitoring and actions for when a robot's metrics show abnormalities. You can easily track historic trends and profile behavior such as resource usage. Out of the box it provides a ROS interface to take a ROS message defining a metric and publish it to Amazon CloudWatch Metrics. The only configuration required to get started is setting up AWS Credentials and Permissions for your robot.The CloudWatch Metrics Node can be used with existing ROS Nodes that publish metric messages or with your own nodes if you instrument them to publish your own custom metrics.
6+
7+
**Amazon CloudWatch Metrics Summary**: Amazon CloudWatch is a monitoring and management service built for developers, system operators, site reliability engineers (SRE), and IT managers. CloudWatch provides you with data and actionable insights to monitor your applications, understand and respond to system-wide performance changes, optimize resource utilization, and get a unified view of operational health. CloudWatch collects monitoring and operational data in the form of logs, metrics, and events, providing you with a unified view of AWS resources, applications and services that run on AWS, and on-premises servers. You can use CloudWatch to set high resolution alarms, visualize logs and metrics side by side, take automated actions, troubleshoot issues, and discover insights to optimize your applications, and ensure they are running smoothly.
8+
9+
**Keywords**: ROS, AWS, CloudWatch, Metrics
10+
11+
### License
12+
The source code is released under an [Apache 2.0].
13+
14+
**Author**: AWS RoboMaker<br/>
15+
**Affiliation**: [Amazon Web Services (AWS)]<br/>
16+
**Maintainer**: AWS RoboMaker, [email protected]
17+
18+
### Supported ROS Distributions
19+
- Kinetic
20+
- Lunar
21+
- Melodic
22+
23+
24+
## Installation
25+
26+
### AWS Credentials
27+
You will need to create an AWS Account and configure the credentials to be able to communicate with AWS services. You may find [AWS Configuration and Credential Files] helpful. Specifying AWS [credentials by setting environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html) is not supported.
28+
29+
This node will require the following AWS account IAM role permissions:
30+
- `cloudwatch:PutMetricData`
31+
32+
### Building from Source
33+
Create a ROS workspace and a source directory
34+
35+
mkdir -p ~/ros-workspace/src
36+
37+
To build from source, clone the latest version from master branch and compile the package
38+
39+
- Clone the package into the source directory
40+
41+
cd ~/ros-workspace/src
42+
git clone https://github.com/aws-robotics/utils-common.git
43+
git clone https://github.com/aws-robotics/utils-ros1.git
44+
git clone https://github.com/aws-robotics/monitoringmessages-ros1.git
45+
git clone https://github.com/aws-robotics/cloudwatch-common.git
46+
git clone https://github.com/aws-robotics/cloudwatchmetrics-ros1.git
47+
48+
- Install dependencies
49+
50+
cd ~/ros-workspace && sudo apt-get update
51+
rosdep install --from-paths src --ignore-src -r -y
52+
53+
- Build the packages
54+
55+
cd ~/ros-workspace && colcon build
56+
57+
- Configure ROS library Path
58+
59+
source ~/ros-workspace/install/setup.bash
60+
61+
- Build and run the unit tests
62+
63+
colcon build --packages-select cloudwatch_metrics_collector --cmake-target tests
64+
colcon test --packages-select cloudwatch_metrics_collector cloudwatch_metrics_common && colcon test-result --all
65+
66+
67+
## Launch Files
68+
In order to include a `cloudwatch_metrics_collector` in your launch file, you should add `<include file="$(find cloudwatch_metrics_collector)/launch/cloudwatch_metrics_collector.launch" />` to your launch file. The launch file uses the following arguments:
69+
70+
| Arg Name | Description |
71+
| --------- | ------------ |
72+
| node_name | (optional) The name the metrics node should be launched with. If not provided the node will default to "cloudwatch_metrics_collector" |
73+
| config_file | (optional) A path to a posparam config file. If provided the launch file will use rosparam to load the configuration into the private namespace of the node. |
74+
75+
An example launch file called `sample_application.launch` is included in this project that gives an example of how you can include this node in your project and provide it with arguments.
76+
77+
78+
## Usage
79+
80+
### Run the node
81+
- **With** launch file using parameters in .yaml format (example provided)
82+
- ROS: `roslaunch cloudwatch_metrics_collector sample_application.launch --screen`
83+
84+
### Send a test metric
85+
- `rostopic pub /metrics ros_monitoring_msgs/MetricList '[{header: auto, metric_name: "ExampleMetric", unit: "sec", value: 42, time_stamp: now, dimensions: []}, {header: auto, metric_name: "ExampleMetric2", unit: "count", value: 22, time_stamp: now, dimensions: [{name: "ExampleDimension", value: "1"}]}]'`
86+
87+
88+
## Configuration File and Parameters
89+
An example configuration file named `sample_configuration.yaml` is provided that contains a detailed example configuration for the Node.
90+
91+
All parameters to the Node are provided via the parameter server when the node is started. When loading configuration the Node will start looking for each setting inside of its private namespace and then search up the namespace heirarchy to the global namespace for the parameters.
92+
93+
| Parameter Name | Description | Type |
94+
| ------------- | -----------------------------------------------------------| ------------- |
95+
| aws_metrics_namespace | (optional) If provided it will set the namespace for all metrics provided by this node to the provided value. If the node is running on AWS RoboMaker then the provided launch file will ignore this parameter in favor of the namespace specified by the AWS RoboMaker ecosystem | *string* |
96+
| aws_monitored_metric_topics | (optional) An optional list of topics to listen to. If not provided or is empty the node will just listen on the global "metrics" topic. If this list is not empty then the node will not subscribe to the "metrics" topic and will only subscribe to the topics in the list. | *array of strings* |
97+
| aws_client_configuration | (optional) If given the node will load the provided configuration when initializing the client. If a specific configuration setting is not included in the map then it will search up the namespace hierarchy for an 'aws_client_configuration' map that contains the field. In this way, a global configuration can be provided for all AWS nodes with only specific values overridden for a specific Node instance if needed | *map* |
98+
| storage_resolution | (optional) The storage resolution level for presenting metrics in CloudWatch. For more information, see [high-resolution-metrics]. | *int* |
99+
100+
101+
## Performance and Benchmark Results
102+
We evaluated the performance of this node by runnning the followning scenario on a Raspberry Pi 3 Model B:
103+
- Launch a baseline graph containing the talker and listener nodes from the [roscpp_tutorials package](https://wiki.ros.org/roscpp_tutorials), plus two additional nodes that collect CPU and memory usage statistics. Allow the nodes to run for 60 seconds.
104+
- Launch the CloudWatch Metrics node using the launch file `sample_application.launch` as described above. At the same time, send messages to the to the `/metrics` topic by running the following script in the background:
105+
106+
```bash
107+
function metric {
108+
echo "{header: auto, metric_name: 'ExampleMetric', unit: 'sec', value: "${i}", time_stamp: now, dimensions: []}";
109+
}
110+
111+
for i in {1..10}
112+
do
113+
rostopic pub -1 /metrics ros_monitoring_msgs/MetricList "[$(metric $i)]"
114+
done
115+
```
116+
117+
- Allow the nodes to run for 180 seconds.
118+
- Terminate the CloudWatch Metrics node, and allow the remaining nodes to run for 60 seconds.
119+
120+
The graph below shows the CPU usage during that scenario. We can see how the 1 minute average CPU usage increases when we launch the `cloudwatch_metrics_collector` node around second 60, and the node starts processing messagess, with a peak of 18.5% showing an increase of 15.25% with respect to the initial usage of 3.25%. After we stop sending messages to the `cloudwatch_metrics_collector` node around second 120, the 1 minute average CPU usage decreases to around 12.5, and then goes down to around the initial value as the node finishes sending the metrics to Amazon CloudWatch. The CPU usage goes back to around the original value when we stop the node at the end of the scenario.
121+
122+
![cpu](wiki/images/cpu.svg)
123+
124+
The graph below shows the memory usage during that scenario. We start with a memory usage of 368 MB that increases to 417 MB (+13.3%) when the `cloudwatch_metrics_collector` node starts running, and decreases to 394 MB (+7% wrt. initial value) when the node is not processing messages. The memory usage goes back to 368 MB after stopping the node.
125+
126+
![memory](wiki/images/memory.svg)
127+
128+
129+
## Node
130+
131+
### cloudwatch_metrics_collector
132+
Sends metrics in a ROS system to AWS CloudWatch Metrics service.
133+
134+
#### Subscribed Topics
135+
- **`Configurable (default="/metrics")`**
136+
137+
The node can subscribe to a configurable list of topic names. If no list in provided then it will default to subscribing to a global topic names `/metrics`.<br/>
138+
Message Type: `ros_monitoring_msgs/MetricList`
139+
140+
#### Published Topics
141+
None
142+
143+
#### Services
144+
None
145+
146+
147+
## Bugs & Feature Requests
148+
Please contact the team directly if you would like to request a feature.
149+
150+
Please report bugs in [Issue Tracker].
151+
152+
153+
[Amazon Web Services (AWS)]: https://aws.amazon.com/
154+
[Apache 2.0]: https://aws.amazon.com/apache-2-0/
155+
[AWS Configuration and Credential Files]: https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
156+
[high-resolution-metrics]: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics
157+
[Issue Tracker]: https://github.com/aws-robotics/cloudwatchmetrics-ros1/issues
158+
[ROS]: http://www.ros.org
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(cloudwatch_metrics_collector)
3+
4+
## Compile as C++11, supported in ROS Kinetic and newer
5+
#add_compile_options(-std=c++17)
6+
set(CMAKE_CXX_STANDARD 14)
7+
8+
## Find catkin macros and libraries
9+
find_package(catkin REQUIRED COMPONENTS
10+
roscpp
11+
cloudwatch_metrics_common
12+
ros_monitoring_msgs
13+
aws_common
14+
aws_ros1_common
15+
)
16+
17+
###################################
18+
## catkin specific configuration ##
19+
###################################
20+
catkin_package()
21+
22+
###########
23+
## Build ##
24+
###########
25+
26+
## Specify additional locations of header files
27+
include_directories(${catkin_INCLUDE_DIRS})
28+
29+
## Declare a C++ executable
30+
set(CW_METRICS_COLLECTOR_SRC src/cloudwatch_metrics_collector.cpp)
31+
add_executable(${PROJECT_NAME} ${CW_METRICS_COLLECTOR_SRC})
32+
add_library(${PROJECT_NAME}_lib ${CW_METRICS_COLLECTOR_SRC})
33+
target_include_directories(${PROJECT_NAME} PRIVATE include ${catkin_INCLUDE_DIRS} ${cloudwatch_metrics_collector_INCLUDE_DIRS})
34+
target_include_directories(${PROJECT_NAME}_lib PUBLIC include ${catkin_INCLUDE_DIRS} ${cloudwatch_metrics_collector_INCLUDE_DIRS})
35+
## Specify libraries to link a library or executable target against
36+
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
37+
target_link_libraries(${PROJECT_NAME}_lib ${catkin_LIBRARIES})
38+
39+
40+
#############
41+
## Install ##
42+
#############
43+
44+
## Mark executables and/or libraries for installation
45+
install(TARGETS ${PROJECT_NAME}
46+
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
47+
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
48+
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
49+
)
50+
51+
install(DIRECTORY
52+
config
53+
launch
54+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
55+
56+
#############
57+
## Testing ##
58+
#############
59+
60+
## Add gtest based cpp test target and link libraries
61+
if(CATKIN_ENABLE_TESTING)
62+
find_package(rostest REQUIRED)
63+
include_directories(/usr/include/gmock /usr/src/gmock)
64+
add_library(libgmock /usr/src/gmock/src/gmock-all.cc)
65+
66+
SET(CW_METRICS_COLLECTOR_TEST test_cloudwatch_metrics_collector)
67+
add_rostest_gtest(${CW_METRICS_COLLECTOR_TEST}
68+
test/test_cloudwatch_metrics_collector.test
69+
test/cloudwatch_metrics_collector_test.cpp)
70+
target_include_directories(${CW_METRICS_COLLECTOR_TEST} PRIVATE include ${catkin_INCLUDE_DIRS}
71+
${cloudwatch_metrics_collector_INCLUDE_DIRS})
72+
target_link_libraries(${CW_METRICS_COLLECTOR_TEST} ${PROJECT_NAME}_lib libgmock ${catkin_LIBRARIES})
73+
endif()

0 commit comments

Comments
 (0)