Skip to content

Commit 28ebc1c

Browse files
authored
Add show-external-only to network summary reports (#651)
1 parent fbc6e8e commit 28ebc1c

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

cli/cmd/network_report.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,26 @@ func (r *runners) InitNetworkReport(parent *cobra.Command) *cobra.Command {
2121
Short: "Get network report",
2222
Long: `Get a network report showing detailed network activity for a specified network.
2323
24-
The report shows individual network events including source/destination IPs, ports, protocols,
24+
The report shows individual network events including source/destination IPs, ports, protocols,
2525
pods, processes, and DNS queries. Reports must be enabled with 'replicated network update <network-id> --collect-report'.
2626
2727
Output formats:
2828
- Default: Full event details in JSON format
2929
- --summary: Aggregated statistics with top domains and destinations
30-
- --watch: Continuous stream of new events in JSON Lines format`,
31-
Example: `# Get full network traffic report
30+
- --watch: Continuous stream of new events in JSON Lines format
31+
32+
Filtering:
33+
- --show-external-only: Show only external network traffic (default: true)
34+
Set to false to include internal cluster traffic`,
35+
Example: `# Get full network traffic report (external traffic only)
3236
replicated network report <network-id>
3337
3438
# Get aggregated summary with statistics. Only available for networks that have been terminated.
3539
replicated network report <network-id> --summary
3640
41+
# Include internal cluster traffic in the report
42+
replicated network report <network-id> --show-external-only=false
43+
3744
# Watch for new network events in real-time
3845
replicated network report <network-id> --watch`,
3946
RunE: r.getNetworkReport,
@@ -69,11 +76,6 @@ func (r *runners) getNetworkReport(cmd *cobra.Command, args []string) error {
6976

7077
// Don't call getNetworkIDFromArg here. Reporting API supports short IDs and will also work for networks that have been deleted.
7178

72-
// Validate flags
73-
if r.args.networkReportSummary && cmd.Flags().Lookup("show-external-only").Changed {
74-
return fmt.Errorf("cannot use --show-external-only and --summary flags together")
75-
}
76-
7779
// Get the initial network report or summary depending on args provided
7880
if r.args.networkReportSummary {
7981
return r.getNetworkReportSummary(cmd.Context())
@@ -150,7 +152,7 @@ func (r *runners) getNetworkReportSummary(ctx context.Context) error {
150152
return fmt.Errorf("cannot use watch and summary flags together")
151153
}
152154

153-
summary, err := r.kotsAPI.GetNetworkReportSummary(ctx, r.args.networkReportID)
155+
summary, err := r.kotsAPI.GetNetworkReportSummary(ctx, r.args.networkReportID, r.args.networkReportShowExternalOnly)
154156
if errors.Cause(err) == platformclient.ErrForbidden {
155157
return ErrCompatibilityMatrixTermsNotAccepted
156158
} else if errors.Cause(err) == platformclient.ErrNotFound {

pkg/kotsclient/network_report.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ func (c *VendorV3Client) GetNetworkReportAfter(id string, after *time.Time, show
6060
return &types.NetworkReport{Events: events}, nil
6161
}
6262

63-
func (c *VendorV3Client) GetNetworkReportSummary(ctx context.Context, id string) (*types.NetworkReportSummary, error) {
63+
func (c *VendorV3Client) GetNetworkReportSummary(ctx context.Context, id string, showExternalOnly bool) (*types.NetworkReportSummary, error) {
6464
urlPath := fmt.Sprintf("/v3/network/%s/report/summary", id)
65+
v := url.Values{}
66+
v.Set("show-external-only", fmt.Sprintf("%t", showExternalOnly))
67+
if len(v) > 0 {
68+
urlPath = fmt.Sprintf("%s?%s", urlPath, v.Encode())
69+
}
6570
type summaryResp struct {
6671
*types.NetworkReportSummary
6772
Error string `json:"error,omitempty"`

0 commit comments

Comments
 (0)