Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI examples for CloudWatch NetworkFlowMonitor #9127

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions awscli/examples/networkflowmonitor/create-monitor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To create a monitor**

The following ``create-monitor`` example creates a monitor named ``demo`` in the specified account. ::

aws networkflowmonitor create-monitor \
--monitor-name demo \
--local-resources type="AWS::EC2::VPC",identifier="arn:aws:ec2:us-east-1:123456789012:vpc/vpc-03ea55eeda25adbb0" \
--scope-arn arn:aws:networkflowmonitor:us-east-1:123456789012:scope/e21cda79-30a0-4c12-9299-d8629d76d8cf

Output::

{
"monitorArn": "arn:aws:networkflowmonitor:us-east-1:123456789012:monitor/demo",
"monitorName": "demo",
"monitorStatus": "ACTIVE",
"tags": {}
}

For more information, see `Create a monitor in Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-configure-monitors-create.html>`__ in the *Amazon CloudWatch User Guide*.
16 changes: 16 additions & 0 deletions awscli/examples/networkflowmonitor/create-scope.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To create a Scope**

The following ``create-scope`` creates a scope that includes a set of resources for which Network Flow Monitor will generate network traffic metrics. ::

aws networkflowmonitor create-scope \
--targets '[{"targetIdentifier":{"targetId":{"accountId":"123456789012"},"targetType":"ACCOUNT"},"region":"us-east-1"}]'

Output::

{
"scopeId": "97626f8d-8a21-4b5d-813a-1a0962dd4615",
"status": "IN_PROGRESS",
"tags": {}
}

For more information, see `Components and features of Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-components.html>`__ in the *Amazon CloudWatch User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/networkflowmonitor/delete-monitor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a monitor**

The following ``delete-monitor`` example deletes a monitor named ``demo`` in the specified account. ::

aws networkflowmonitor delete-monitor \
--monitor-name demo

This command produces no output.

For more information, see `Delete a monitor in Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-configure-monitors-delete.html>`__ in the *Amazon CloudWatch User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/networkflowmonitor/delete-scope.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a scope**

The following ``delete-scope`` example deletes a specified scope. ::

aws networkflowmonitor delete-scope \
--scope-id fdc20616-6bb4-4242-a24e-a748e65ca7ac

This command produces no output.

For more information, see `Components and features of Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-components.html>`__ in the *Amazon CloudWatch User Guide*.
26 changes: 26 additions & 0 deletions awscli/examples/networkflowmonitor/get-monitor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**To retrieve information about a monitor**

The following ``get-monitor`` example displays information about the monitor named ``demo`` in the specified account. ::

aws networkflowmonitor get-monitor \
--monitor-name Demo

Output::

{
"monitorArn": "arn:aws:networkflowmonitor:us-east-1:123456789012:monitor/Demo",
"monitorName": "Demo",
"monitorStatus": "ACTIVE",
"localResources": [
{
"type": "AWS::EC2::VPC",
"identifier": "arn:aws:ec2:us-east-1:123456789012:vpc/vpc-03ea55eeda25adbb0"
}
],
"remoteResources": [],
"createdAt": "2024-12-09T12:21:51.616000-06:00",
"modifiedAt": "2024-12-09T12:21:55.412000-06:00",
"tags": {}
}

For more information, see `Components and features of Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-components.html>`__ in the *Amazon CloudWatch User Guide*.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**To retrieve the Top Contributor data on Workload insights**

The following ``get-query-results-workload-insights-top-contributors-data`` example returns the data for the specified query. ::

aws networkflowmonitor get-query-results-workload-insights-top-contributors-data \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--query-id cc4f4ab3-3103-33b8-80ff-d6597a0c6cea

Output::

{
"datapoints": [
{
"timestamps": [
"2024-12-09T19:00:00+00:00",
"2024-12-09T19:05:00+00:00",
"2024-12-09T19:10:00+00:00"
],
"values": [
259943.0,
194856.0,
216432.0
],
"label": "use1-az6"
}
],
"unit": "Bytes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**To retrieve the Top Contributors on Workload insights**

The following ``get-query-results-workload-insights-top-contributors`` example returns the data for the specified query. ::

aws networkflowmonitor get-query-results-workload-insights-top-contributors \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--query-id 1fc423d3-b144-37a6-80e6-e2c7d26eea0c

Output::

{
"topContributors": [
{
"accountId": "123456789012",
"localSubnetId": "subnet-0a5b30fb95dca2c14",
"localAz": "use1-az6",
"localVpcId": "vpc-03ea55eeda25adbb0",
"localRegion": "us-east-1",
"remoteIdentifier": "",
"value": 908443,
"localSubnetArn": "arn:aws:ec2:us-east-1:123456789012:subnet/subnet-0a5b30fb95dca2c14",
"localVpcArn": "arn:aws:ec2:us-east-1:123456789012:vpc/vpc-03ea55eeda25adbb0"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**To retrieve the status of the query**

The following ``get-query-status-monitor-top-contributors`` example displays the current status of the query in the specified account. ::

aws networkflowmonitor get-query-status-monitor-top-contributors \
--monitor-name Demo \
--query-id 5398eabd-bc40-3f5f-aba3-bcb639d3c7ca

Output::

{
"status": "SUCCEEDED"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**To retrieve the status of the query**

The following ``get-query-status-workload-insights-top-contributors-data`` example displays the current status of the query in the specified account. ::

aws networkflowmonitor get-query-status-workload-insights-top-contributors-data \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--query-id 4333754d-8ae1-3f29-b6b7-c36db2e7f8ac

Output::

{
"status": "SUCCEEDED"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
**To retrieve the status of the query**

The following ``get-query-status-workload-insights-top-contributors`` example displays the current status of the query in the specified account. ::

aws networkflowmonitor get-query-status-workload-insights-top-contributors \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--query-id f2a87c70-3e5a-362e-8beb-4747d13d8419

Output::

{
"status": "SUCCEEDED"
}
28 changes: 28 additions & 0 deletions awscli/examples/networkflowmonitor/get-scope.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**To retrieve information about a scope**

The following ``get-scope`` example displays information about a scope, such as status, tags, name and target details. ::

aws networkflowmonitor get-scope \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf

Output::

{
"scopeId": "e21cda79-30a0-4c12-9299-d8629d76d8cf",
"status": "SUCCEEDED",
"scopeArn": "arn:aws:networkflowmonitor:us-east-1:123456789012:scope/e21cda79-30a0-4c12-9299-d8629d76d8cf",
"targets": [
{
"targetIdentifier": {
"targetId": {
"accountId": "123456789012"
},
"targetType": "ACCOUNT"
},
"region": "us-east-1"
}
],
"tags": {}
}

For more information, see `Components and features of Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-components.html>`__ in the *Amazon CloudWatch User Guide*.
19 changes: 19 additions & 0 deletions awscli/examples/networkflowmonitor/list-monitors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To retrieve a list of monitors**

The following ``list-monitors`` example returns returns all the monitors in the specified account. ::

aws networkflowmonitor list-monitors

Output::

{
"monitors": [
{
"monitorArn": "arn:aws:networkflowmonitor:us-east-1:123456789012:monitor/Demo",
"monitorName": "Demo",
"monitorStatus": "ACTIVE"
}
]
}

For more information, see `Components and features of Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-components.html>`__ in the *Amazon CloudWatch User Guide*.
19 changes: 19 additions & 0 deletions awscli/examples/networkflowmonitor/list-scopes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To retrieve a list of scopes**

The following ``list-scopes`` example lists all scopes in the specified account. ::

aws networkflowmonitor list-scopes

Output::

{
"scopes": [
{
"scopeId": "fdc20616-6bb4-4242-a24e-a748e65ca7ac",
"status": "SUCCEEDED",
"scopeArn": "arn:aws:networkflowmonitor:us-east-1:123456789012:scope/fdc20616-6bb4-4242-a24e-a748e65ca7ac"
}
]
}

For more information, see `Components and features of Network Flow Monitor <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-NetworkFlowMonitor-components.html>`__ in the *Amazon CloudWatch User Guide*.
15 changes: 15 additions & 0 deletions awscli/examples/networkflowmonitor/list-tags-for-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**To list the tags**

The following ``list-tags-for-resource`` example returns all the tags associated with the specified resource. ::

aws networkflowmonitor list-tags-for-resource \
--resource-arn arn:aws:networkflowmonitor:us-east-1:123456789012:monitor/Demo

Output::

{
"tags": {
"Value": "Production",
"Key": "stack"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To start a query**

The following ``start-query-monitor-top-contributors`` example starts the query which returns a queryId to retrieve the top contributors. ::

aws networkflowmonitor start-query-monitor-top-contributors \
--monitor-name Demo \
--start-time 2024-12-09T19:00:00Z \
--end-time 2024-12-09T19:15:00Z \
--metric-name DATA_TRANSFERRED \
--destination-category UNCLASSIFIED

Output::

{
"queryId": "aecd3a88-0283-35b0-a17d-6e944dc8531d"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To start a query**

The following ``start-query-workload-insights-top-contributors-data`` example starts the query which returns a queryId to retrieve the top contributors. ::

aws networkflowmonitor start-query-workload-insights-top-contributors-data \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--start-time 2024-12-09T19:00:00Z \
--end-time 2024-12-09T19:15:00Z \
--metric-name DATA_TRANSFERRED \
--destination-category UNCLASSIFIED

Output::

{
"queryId": "cc4f4ab3-3103-33b8-80ff-d6597a0c6cea"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To start a query**

The following ``start-query-workload-insights-top-contributors`` example starts the query which returns a queryId to retrieve the top contributors. ::

aws networkflowmonitor start-query-workload-insights-top-contributors \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--start-time 2024-12-09T19:00:00Z \
--end-time 2024-12-09T19:15:00Z \
--metric-name DATA_TRANSFERRED \
--destination-category UNCLASSIFIED

Output::

{
"queryId": "1fc423d3-b144-37a6-80e6-e2c7d26eea0c"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**To stop a query**

The following ``stop-query-monitor-top-contributors`` example stops the query in the specified account. ::

aws networkflowmonitor stop-query-monitor-top-contributors \
--monitor-name Demo \
--query-id aecd3a88-0283-35b0-a17d-6e944dc8531d

This command produces no output.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**To stop a query**

The following ``stop-query-workload-insights-top-contributors-data`` example stops the query in the specified account. ::

aws networkflowmonitor stop-query-workload-insights-top-contributors-data \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--query-id cc4f4ab3-3103-33b8-80ff-d6597a0c6cea

This command produces no output.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**To stop a query**

The following ``stop-query-workload-insights-top-contributors`` example stops the query in the specified account. ::

aws networkflowmonitor stop-query-workload-insights-top-contributors \
--scope-id e21cda79-30a0-4c12-9299-d8629d76d8cf \
--query-id 1fc423d3-b144-37a6-80e6-e2c7d26eea0c

This command produces no output.
9 changes: 9 additions & 0 deletions awscli/examples/networkflowmonitor/tag-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**To add a tag to the specified resource**

The following ``tag-resource`` example adds a tag to the monitor in the specified account. ::

aws networkflowmonitor tag-resource \
--resource-arn arn:aws:networkflowmonitor:us-east-1:123456789012:monitor/Demo \
--tags Key=stack,Value=Production

This command produces no output.
9 changes: 9 additions & 0 deletions awscli/examples/networkflowmonitor/untag-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**To remove a tag to the specified resource**

The following ``untag-resource`` example removes a tag to the monitor in the specified account. ::

aws networkflowmonitor untag-resource \
--resource-arn arn:aws:networkflowmonitor:us-east-1:123456789012:monitor/Demo \
--tag-keys stack

This command produces no output.
Loading