Skip to content

Commit

Permalink
[Metricbeat] gcp.compute: uniform metricset's fields (#28367) (#28451)
Browse files Browse the repository at this point in the history
* gcp.compute: flatten fields

* gcp.compute: fix firewall docs

* gcp.compute: sort fields

* gcp.compute: add TestFetch

* gcp.compute: fix undocumented field

* gcp: update fields

* metricbeat: mage update

(cherry picked from commit 3db67f6)

Co-authored-by: endorama <[email protected]>
  • Loading branch information
mergify[bot] and endorama authored Oct 15, 2021
1 parent 24de193 commit 5687806
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 103 deletions.
61 changes: 32 additions & 29 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27793,9 +27793,7 @@ type: float
Google Cloud Compute metrics




*`gcp.compute.instance.firewall.dropped_bytes_count.value`*::
*`gcp.compute.firewall.dropped_bytes_count.value`*::
+
--
Incoming bytes dropped by the firewall
Expand All @@ -27804,7 +27802,7 @@ type: long

--

*`gcp.compute.instance.firewall.dropped_packets_count.value`*::
*`gcp.compute.firewall.dropped_packets_count.value`*::
+
--
Incoming packets dropped by the firewall
Expand All @@ -27813,7 +27811,6 @@ type: long

--


*`gcp.compute.instance.cpu.reserved_cores.value`*::
+
--
Expand All @@ -27823,25 +27820,24 @@ type: double

--

*`gcp.compute.instance.cpu.utilization.value`*::
*`gcp.compute.instance.cpu.usage_time.value`*::
+
--
The fraction of the allocated CPU that is currently in use on the instance
Usage for all cores in seconds

type: double

--

*`gcp.compute.instance.cpu.usage_time.value`*::
*`gcp.compute.instance.cpu.utilization.value`*::
+
--
Usage for all cores in seconds
The fraction of the allocated CPU that is currently in use on the instance

type: double

--


*`gcp.compute.instance.disk.read_bytes_count.value`*::
+
--
Expand Down Expand Up @@ -27878,84 +27874,91 @@ type: long

--

*`gcp.compute.instance.uptime.value`*::
*`gcp.compute.instance.memory.balloon.ram_size.value`*::
+
--
How long the VM has been running, in seconds
The total amount of memory in the VM. This metric is only available for VMs that belong to the e2 family.

type: long

--


*`gcp.compute.instance.network.received_bytes_count.value`*::
*`gcp.compute.instance.memory.balloon.ram_used.value`*::
+
--
Count of bytes received from the network
Memory currently used in the VM. This metric is only available for VMs that belong to the e2 family.

type: long

--

*`gcp.compute.instance.network.received_packets_count.value`*::
*`gcp.compute.instance.memory.balloon.swap_in_bytes_count.value`*::
+
--
Count of packets received from the network
The amount of memory read into the guest from its own swap space. This metric is only available for VMs that belong to the e2 family.

type: long

--

*`gcp.compute.instance.network.sent_bytes_count.value`*::
*`gcp.compute.instance.memory.balloon.swap_out_bytes_count.value`*::
+
--
Count of bytes sent over the network
The amount of memory written from the guest to its own swap space. This metric is only available for VMs that belong to the e2 family.

type: long

--

*`gcp.compute.instance.network.sent_packets_count.value`*::
*`gcp.compute.instance.network.received_bytes_count.value`*::
+
--
Count of packets sent over the network
Count of bytes received from the network

type: long

--

*`gcp.compute.instance.network.received_packets_count.value`*::
+
--
Count of packets received from the network

*`gcp.compute.instance.memory.balloon.ram_size.value`*::
type: long

--

*`gcp.compute.instance.network.sent_bytes_count.value`*::
+
--
The total amount of memory in the VM. This metric is only available for VMs that belong to the e2 family.
Count of bytes sent over the network

type: long

--

*`gcp.compute.instance.memory.balloon.ram_used.value`*::
*`gcp.compute.instance.network.sent_packets_count.value`*::
+
--
Memory currently used in the VM. This metric is only available for VMs that belong to the e2 family.
Count of packets sent over the network

type: long

--

*`gcp.compute.instance.memory.balloon.swap_in_bytes_count.value`*::
*`gcp.compute.instance.uptime.value`*::
+
--
The amount of memory read into the guest from its own swap space. This metric is only available for VMs that belong to the e2 family.
Number of seconds the VM has been running.

type: long

--

*`gcp.compute.instance.memory.balloon.swap_out_bytes_count.value`*::
*`gcp.compute.instance.uptime_total.value`*::
+
--
The amount of memory written from the guest to its own swap space. This metric is only available for VMs that belong to the e2 family.
Elapsed time since the VM was started, in seconds. Sampled every 60 seconds. After sampling, data is not visible for up to 120 seconds.

type: long

Expand Down
131 changes: 58 additions & 73 deletions x-pack/metricbeat/module/gcp/compute/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,62 @@
- name: compute
description: Google Cloud Compute metrics
release: beta
type: group
description: Google Cloud Compute metrics
fields:
- name: instance
type: group
fields:
- name: firewall
type: group
fields:
- name: dropped_bytes_count.value
type: long
description: Incoming bytes dropped by the firewall
- name: dropped_packets_count.value
type: long
description: Incoming packets dropped by the firewall
- name: cpu
type: group
fields:
- name: reserved_cores.value
type: double
description: Number of cores reserved on the host of the instance
- name: utilization.value
type: double
description: The fraction of the allocated CPU that is currently in use on the instance
- name: usage_time.value
type: double
description: Usage for all cores in seconds
- name: disk
type: group
fields:
- name: read_bytes_count.value
type: long
description: Count of bytes read from disk
- name: read_ops_count.value
type: long
description: Count of disk read IO operations
- name: write_bytes_count.value
type: long
description: Count of bytes written to disk
- name: write_ops_count.value
type: long
description: Count of disk write IO operations
- name: uptime.value
type: long
description: How long the VM has been running, in seconds
- name: network
type: group
fields:
- name: received_bytes_count.value
type: long
description: Count of bytes received from the network
- name: received_packets_count.value
type: long
description: Count of packets received from the network
- name: sent_bytes_count.value
type: long
description: Count of bytes sent over the network
- name: sent_packets_count.value
type: long
description: Count of packets sent over the network
- name: memory.balloon
type: group
fields:
- name: ram_size.value
type: long
description: The total amount of memory in the VM. This metric is only available for VMs that belong to the e2 family.
- name: ram_used.value
type: long
description: Memory currently used in the VM. This metric is only available for VMs that belong to the e2 family.
- name: swap_in_bytes_count.value
type: long
description: The amount of memory read into the guest from its own swap space. This metric is only available for VMs that belong to the e2 family.
- name: swap_out_bytes_count.value
type: long
description: The amount of memory written from the guest to its own swap space. This metric is only available for VMs that belong to the e2 family.
- name: firewall.dropped_bytes_count.value
type: long
description: Incoming bytes dropped by the firewall
- name: firewall.dropped_packets_count.value
type: long
description: Incoming packets dropped by the firewall
- name: instance.cpu.reserved_cores.value
type: double
description: Number of cores reserved on the host of the instance
- name: instance.cpu.usage_time.value
type: double
description: Usage for all cores in seconds
- name: instance.cpu.utilization.value
type: double
description: The fraction of the allocated CPU that is currently in use on the instance
- name: instance.disk.read_bytes_count.value
type: long
description: Count of bytes read from disk
- name: instance.disk.read_ops_count.value
type: long
description: Count of disk read IO operations
- name: instance.disk.write_bytes_count.value
type: long
description: Count of bytes written to disk
- name: instance.disk.write_ops_count.value
type: long
description: Count of disk write IO operations
- name: instance.memory.balloon.ram_size.value
type: long
description: The total amount of memory in the VM. This metric is only available for VMs that belong to the e2 family.
- name: instance.memory.balloon.ram_used.value
type: long
description: Memory currently used in the VM. This metric is only available for VMs that belong to the e2 family.
- name: instance.memory.balloon.swap_in_bytes_count.value
type: long
description: The amount of memory read into the guest from its own swap space. This metric is only available for VMs that belong to the e2 family.
- name: instance.memory.balloon.swap_out_bytes_count.value
type: long
description: The amount of memory written from the guest to its own swap space. This metric is only available for VMs that belong to the e2 family.
- name: instance.network.received_bytes_count.value
type: long
description: Count of bytes received from the network
- name: instance.network.received_packets_count.value
type: long
description: Count of packets received from the network
- name: instance.network.sent_bytes_count.value
type: long
description: Count of bytes sent over the network
- name: instance.network.sent_packets_count.value
type: long
description: Count of packets sent over the network
- name: instance.uptime.value
type: long
description: Number of seconds the VM has been running.
- name: instance.uptime_total.value
type: long
description: Elapsed time since the VM was started, in seconds. Sampled every 60 seconds. After sampling, data is not visible for up to 120 seconds.
16 changes: 16 additions & 0 deletions x-pack/metricbeat/module/gcp/compute/compute_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,27 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"

"github.com/elastic/beats/v7/libbeat/common"
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
"github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp/metrics"
)

func TestFetch(t *testing.T) {
config := metrics.GetConfigForTest(t, "compute")
fmt.Printf("%+v\n", config)

metricSet := mbtest.NewReportingMetricSetV2WithContext(t, config)
events, errs := mbtest.ReportingFetchV2WithContext(metricSet)
if len(errs) > 0 {
t.Fatalf("Expected 0 error, had %d. %v\n", len(errs), errs)
}

assert.NotEmpty(t, events)
mbtest.TestMetricsetFieldsDocumented(t, metricSet, events)
}

func TestData(t *testing.T) {
metricPrefixIs := func(metricPrefix string) func(e common.MapStr) bool {
return func(e common.MapStr) bool {
Expand Down
1 change: 1 addition & 0 deletions x-pack/metricbeat/module/gcp/compute/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ input:
- "instance/network/sent_bytes_count"
- "instance/network/sent_packets_count"
- "instance/uptime"
- "instance/uptime_total"
Loading

0 comments on commit 5687806

Please sign in to comment.