x-pack/metricbeat/module/gcp/DEVELOPMENT.md
GCP Cloud Monitoring API == Cloudwatch :)
(Also known as Stackdriver before)
cpu.usage.pct for example.X points * Y metrics we don't send X*Y number of events but, instead, we group them into as few events as possible by trying to find which of them shares ID. There are implementations for GCP Cloud Monitoring API and compute based metrics.metadata.go3 Interfaces to implement special metadata retrieval for specific metricsets.
contants.goAvoid pieces of code like:
// A value in seconds, right?
d.getMetric("sec")
// Not really... it was something related with security
d.getMetric(constants.FIELD_SECURITY_PATH)
gcp/metadata_services.go: returns a service to fetch metadata from a config structgcp/metrics_requester.go: Knows the logic to request metrics to gcp, parse timestamps, etc.gcp/metricset.go: Good old friend. Also has the logic to create single events for each group of data that matches some common patterns like labels and timestamp.gcp/response_parser.go: Parses the incoming object from GCP Cloud Monitoring API in some in-between KeyValuePoint data that is similar to Elasticsearch events.gcp/timeseries.go: Groups TimeSeries responses into common Elasticsearch friendly eventsgcp/compute/identity.go: implemented by GCP services that can add some short of data to group their metrics (like instance id on Compute or topic in PubSub)gcp/compute/metadata.go: Specific compute metadata logic.metricbeat -> gcp/metricset.go -> metrics_requester.go -> response_parser.go -> metadata_services.go (if labels=true, gcp/compute.metadata.go only compute metricset at the moment) -> timeseries.go (if labels=true gcp/compute/identity.go only compute ATM) -> metricset.go -> elasticsearch
Or in plain words:
KeyValuePoint which are a in-between data structure to work with in the metricset.KeyValuePoint.KeyValuePoint and groping the ones that shares ID.GCP metrics have 5 different stages: GA, BETA, ALPHA, EARLY_ACCESS, or DEPRECATED.
We only support GA metrics. Eventually we support BETA. We do not support ALPHA or EARLY_ACCESS.
DEPRECATED metrics are not removed until after deprecation period expire and they get removed from GCP Monitoring API.
Run make update to update fields.go from each metricset fields.yml
The implementation is within metrics metricset. That metricset allows other metricsets to use it
as a "parent module" and implement the light-weigth module pattern.
Golang integration tests may be run with: TEST_TAGS=gcp MODULE=gcp mage goIntegTest
This command will exclude gcp.billing metricset, as without access to a Billing Account it will always return an empty set of metrics.
TODO: mock data so tests are not coupled with real GCP infrastructure.