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

[gcp] Migrate some gcp beat metricset to data streams #2707

Merged
merged 22 commits into from
Jul 14, 2022
Merged
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
26 changes: 26 additions & 0 deletions packages/gcp/_dev/build/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,29 @@ The `dns` dataset collects queries that name servers resolve for your Virtual Pr
{{fields "dns"}}

{{event "dns"}}

## Metrics

### Billing

The `billing` dataset collects GCP Billing information from Google Cloud BigQuery daily cost detail table.

{{fields "billing"}}

{{event "billing"}}

### Compute

The `compute` dataset is designed to fetch metrics for [Compute Engine](https://cloud.google.com/compute/) Virtual Machines in Google Cloud Platform.

{{fields "compute"}}

{{event "compute"}}

### Firestore

The `firestore` dataset fetches metrics from [Firestore](https://cloud.google.com/firestore/) in Google Cloud Platform.

{{fields "firestore"}}

{{event "firestore"}}
17 changes: 17 additions & 0 deletions packages/gcp/_dev/build/docs/billing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Billing

## Metrics

The `billing` dataset collects [Cloud Billing Reports](https://cloud.google.com/billing/docs/reports) information from Google Cloud BigQuery daily cost detail table. BigQuery is a fully-managed, serverless data warehouse. Cloud Billing export to BigQuery enables you to export detailed Google Cloud billing data (such as usage, cost estimates, and pricing data) automatically throughout the day to a BigQuery dataset that you specify. Then you can access your Cloud Billing data from BigQuery for detailed analysis.

Please see [export cloud billing data to BigQuery](https://cloud.google.com/billing/docs/how-to/export-data-bigquery) for more details on how to export billing data.

In BigQuery dataset, detailed Google Cloud daily cost data is loaded into a data table named `gcp_billing_export_v1_<BILLING_ACCOUNT_ID>`. There is a defined schema for Google Cloud daily cost data that is exported to BigQuery. Please see [daily cost detail data schema](https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#data-schema) for more details.

## Sample Event

{{event "billing"}}

## Exported fields

{{fields "billing"}}
15 changes: 15 additions & 0 deletions packages/gcp/_dev/build/docs/compute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Compute

## Metrics

The `compute` dataset is designed to fetch metrics for [Compute Engine](https://cloud.google.com/compute/) Virtual Machines in Google Cloud Platform. It contains all metrics exported from the [GCP Cloud Monitoring API](https://cloud.google.com/monitoring/api/metrics_gcp#gcp-compute).

Extra labels and metadata are also extracted using the [Compute API](https://cloud.google.com/compute/docs/reference/rest/v1/instances/get). This is enough to get most of the info associated with a metric like Compute labels and metadata and metric specific Labels.

## Sample Event

{{event "compute"}}

## Exported fields

{{fields "compute"}}
15 changes: 15 additions & 0 deletions packages/gcp/_dev/build/docs/firestore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Firestore

## Metrics

The `firestore` dataset fetches metrics from [Firestore](https://cloud.google.com/firestore/) in Google Cloud Platform. It contains all metrics exported from the [GCP Firestore Monitoring API](https://cloud.google.com/monitoring/api/metrics_gcp#gcp-firestore).

You can specify a single region to fetch metrics like `us-central1`. Be aware that GCP Storage does not use zones so `us-central1-a` will return nothing. If no region is specified, it will return metrics from all buckets.

## Sample Event

{{event "firestore"}}

## Exported fields

{{fields "firestore"}}
23 changes: 23 additions & 0 deletions packages/gcp/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
# newer versions go on top
- version: 2.0.0
changes:
- description: |
Move configurations to support metrics. This change is breaking, as it moves
some configuration from the top level variables to data stream variables.

This change involves `project_id`, `credentials_file` and `credentials_json`
variables that are moved from input level configuration to package level
configuration (as those variables are reused across all inputs/data streams).

Users with GCP integration enabled will need to input values for these
variables again when upgrading the policies to this version.
type: breaking-change
link: https://github.com/elastic/integrations/pull/2707
- description: Add GCP Billing Data Stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there docs for this data stream? (if adding, it would be worth including a link to https://cloud.google.com/billing/docs/reports since there are a lot of details that help understand the documents).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added documentation in dc10062

Thank you for pointing this out!

type: enhancement
link: https://github.com/elastic/integrations/pull/2141
- description: Add GCP Compute Data Stream
type: enhancement
link: https://github.com/elastic/integrations/pull/2301
- description: Add GCP Firestore Data stream
type: enhancement
link: https://github.com/elastic/integrations/pull/2704
- version: "1.10.0"
changes:
- description: Update package to ECS 8.3.0.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
service: gcppubsub-emulator
input: gcp-pubsub
vars:
alternative_host: "{{Hostname}}:{{Port}}"
credentials_json: |-
{
"type": "service_account",
Expand All @@ -18,5 +17,6 @@ vars:
project_id: audit
data_stream:
vars:
alternative_host: "{{Hostname}}:{{Port}}"
subscription_name: subscription
topic: topic
7 changes: 7 additions & 0 deletions packages/gcp/data_stream/audit/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ streams:
required: true
show_user: false
default: false
- name: alternative_host
type: text
title: Alternative host
multi: false
required: false
show_user: false
description: "Overrides the default Pub/Sub service address and disables TLS. For testing."
- name: tags
type: text
title: Tags
Expand Down
12 changes: 12 additions & 0 deletions packages/gcp/data_stream/billing/agent/stream/stream.yml.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
metricsets: ["billing"]
period: {{period}}
project_id: {{project_id}}
{{#if credentials_file}}
credentials_file_path: {{credentials_file}}
{{/if}}
{{#if credentials_json}}
credentials_json: '{{credentials_json}}'
{{/if}}
dataset_id: {{dataset_id}}
table_pattern: {{table_pattern}}
cost_type: {{cost_type}}
198 changes: 198 additions & 0 deletions packages/gcp/data_stream/billing/fields/agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
- name: cloud
title: Cloud
group: 2
description: Fields related to the cloud or infrastructure the events are coming from.
footnote: 'Examples: If Metricbeat is running on an EC2 host and fetches data from its host, the cloud info contains the data about this machine. If Metricbeat runs on a remote machine outside the cloud and fetches data from a service running in the cloud, the field contains cloud data from the machine the service is running on.'
type: group
fields:
- name: account.id
level: extended
type: keyword
ignore_above: 1024
description: 'The cloud account or organization id used to identify different entities in a multi-tenant environment.
Examples: AWS account id, Google Cloud ORG Id, or other unique identifier.'
example: 666777888999
- name: availability_zone
level: extended
type: keyword
ignore_above: 1024
description: Availability zone in which this host is running.
example: us-east-1c
- name: instance.id
level: extended
type: keyword
ignore_above: 1024
description: Instance ID of the host machine.
example: i-1234567890abcdef0
- name: instance.name
level: extended
type: keyword
ignore_above: 1024
description: Instance name of the host machine.
- name: machine.type
level: extended
type: keyword
ignore_above: 1024
description: Machine type of the host machine.
example: t2.medium
- name: provider
level: extended
type: keyword
ignore_above: 1024
description: Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean.
example: aws
- name: region
level: extended
type: keyword
ignore_above: 1024
description: Region in which this host is running.
example: us-east-1
- name: project.id
type: keyword
description: Name of the project in Google Cloud.
- name: image.id
type: keyword
description: Image ID for the cloud instance.
- name: container
title: Container
group: 2
description: 'Container fields are used for meta information about the specific container that is the source of information.
These fields help correlate data based containers from any runtime.'
type: group
fields:
- name: id
level: core
type: keyword
ignore_above: 1024
description: Unique container id.
- name: image.name
level: extended
type: keyword
ignore_above: 1024
description: Name of the image the container was built on.
- name: labels
level: extended
type: object
object_type: keyword
description: Image labels.
- name: name
level: extended
type: keyword
ignore_above: 1024
description: Container name.
- name: host
title: Host
group: 2
description: 'A host is defined as a general computing instance.
ECS host.* fields should be populated with details about the host on which the event happened, or from which the measurement was taken. Host types include hardware, virtual machines, Docker containers, and Kubernetes nodes.'
type: group
fields:
- name: architecture
level: core
type: keyword
ignore_above: 1024
description: Operating system architecture.
example: x86_64
- name: domain
level: extended
type: keyword
ignore_above: 1024
description: 'Name of the domain of which the host is a member.
For example, on Windows this could be the host''s Active Directory domain or NetBIOS domain name. For Linux this could be the domain of the host''s LDAP provider.'
example: CONTOSO
default_field: false
- name: hostname
level: core
type: keyword
ignore_above: 1024
description: 'Hostname of the host.
It normally contains what the `hostname` command returns on the host machine.'
- name: id
level: core
type: keyword
ignore_above: 1024
description: 'Unique host id.
As hostname is not always unique, use values that are meaningful in your environment.
Example: The current usage of `beat.name`.'
- name: ip
level: core
type: ip
description: Host ip addresses.
- name: mac
level: core
type: keyword
ignore_above: 1024
description: Host mac addresses.
- name: name
level: core
type: keyword
ignore_above: 1024
description: 'Name of the host.
It can contain what `hostname` returns on Unix systems, the fully qualified domain name, or a name specified by the user. The sender decides which value to use.'
- name: os.family
level: extended
type: keyword
ignore_above: 1024
description: OS family (such as redhat, debian, freebsd, windows).
example: debian
- name: os.kernel
level: extended
type: keyword
ignore_above: 1024
description: Operating system kernel version as a raw string.
example: 4.4.0-112-generic
- name: os.name
level: extended
type: keyword
ignore_above: 1024
multi_fields:
- name: text
type: text
norms: false
default_field: false
description: Operating system name, without the version.
example: Mac OS X
- name: os.platform
level: extended
type: keyword
ignore_above: 1024
description: Operating system platform (such centos, ubuntu, windows).
example: darwin
- name: os.version
level: extended
type: keyword
ignore_above: 1024
description: Operating system version as a raw string.
example: 10.14.1
- name: type
level: core
type: keyword
ignore_above: 1024
description: 'Type of host.
For Cloud providers this can be the machine type like `t2.medium`. If vm, this could be the container, for example, or other information meaningful in your environment.'
- name: containerized
type: boolean
description: >
If the host is a container.
- name: os.build
type: keyword
example: "18D109"
description: >
OS build information.
- name: os.codename
type: keyword
example: "stretch"
description: >
OS codename, if any.
20 changes: 20 additions & 0 deletions packages/gcp/data_stream/billing/fields/base-fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: data_stream.type
type: constant_keyword
description: Data stream type.
- name: data_stream.dataset
type: constant_keyword
description: Data stream dataset.
- name: data_stream.namespace
type: constant_keyword
description: Data stream namespace.
- name: '@timestamp'
type: date
description: Event timestamp.
- name: event.module
type: constant_keyword
description: Event module
value: gcp
- name: event.dataset
type: constant_keyword
description: Event dataset
value: gcp.billing
24 changes: 24 additions & 0 deletions packages/gcp/data_stream/billing/fields/ecs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- external: ecs
name: cloud
- external: ecs
name: cloud.account.id
- external: ecs
name: cloud.account.name
- external: ecs
name: cloud.availability_zone
- external: ecs
name: cloud.instance.id
- external: ecs
name: cloud.machine.type
- external: ecs
name: cloud.provider
- external: ecs
name: cloud.region
- external: ecs
name: ecs.version
- external: ecs
name: error
- external: ecs
name: error.message
- external: ecs
name: service.type
Loading