-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metricbeat] gcp: add firestore metricset (#29918)
* Add firestore metricset * Add firestore metricset reference * Add firestore metricset metrics mapping * Add firestore filter logic * Update gcp fields & module * Update gcp module & metricbeat docs * Add changelog entry * Add changelog entry in developer.next
- Loading branch information
Showing
21 changed files
with
274 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//// | ||
This file is generated! See scripts/mage/docs_collector.go | ||
//// | ||
|
||
[[metricbeat-metricset-gcp-firestore]] | ||
[role="xpack"] | ||
=== Google Cloud Platform firestore metricset | ||
|
||
beta[] | ||
|
||
include::../../../../x-pack/metricbeat/module/gcp/firestore/_meta/docs.asciidoc[] | ||
|
||
|
||
==== Fields | ||
|
||
For a description of each field in the metricset, see the | ||
<<exported-fields-gcp,exported fields>> section. | ||
|
||
Here is an example document generated by this metricset: | ||
|
||
[source,json] | ||
---- | ||
include::../../../../x-pack/metricbeat/module/gcp/firestore/_meta/data.json[] | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"@timestamp": "2016-05-23T08:05:34.853Z", | ||
"cloud": { | ||
"account": { | ||
"id": "elastic-apm" | ||
}, | ||
"provider": "gcp" | ||
}, | ||
"event": { | ||
"dataset": "gcp.firestore", | ||
"duration": 115000, | ||
"module": "gcp" | ||
}, | ||
"gcp": { | ||
"labels": { | ||
"metrics": { | ||
"storage_class": "MULTI_REGIONAL" | ||
}, | ||
"resource": { | ||
"bucket_name": "artifacts.elastic-apm.appspot.com", | ||
"location": "us" | ||
} | ||
}, | ||
"firestore": { | ||
"document": { | ||
"delete_count": { | ||
"value": 15 | ||
} | ||
} | ||
} | ||
}, | ||
"metricset": { | ||
"name": "firestore", | ||
"period": 10000 | ||
}, | ||
"service": { | ||
"type": "gcp" | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
x-pack/metricbeat/module/gcp/firestore/_meta/data_document.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"@timestamp": "2016-05-23T08:05:34.853Z", | ||
"cloud": { | ||
"account": { | ||
"id": "elastic-apm" | ||
}, | ||
"provider": "gcp" | ||
}, | ||
"event": { | ||
"dataset": "gcp.firestore", | ||
"duration": 115000, | ||
"module": "gcp" | ||
}, | ||
"gcp": { | ||
"labels": { | ||
"metrics": { | ||
"storage_class": "MULTI_REGIONAL" | ||
}, | ||
"resource": { | ||
"bucket_name": "artifacts.elastic-apm.appspot.com", | ||
"location": "us" | ||
} | ||
}, | ||
"firestore": { | ||
"document": { | ||
"delete_count": { | ||
"value": 15 | ||
} | ||
} | ||
} | ||
}, | ||
"metricset": { | ||
"name": "firestore", | ||
"period": 10000 | ||
}, | ||
"service": { | ||
"type": "gcp" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
x-pack/metricbeat/module/gcp/firestore/_meta/docs.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Firestore metricset fetches metrics from https://cloud.google.com/firestore/[Firestore] in Google Cloud Platform. | ||
|
||
The `firestore` metricset contains all metrics exported from the https://cloud.google.com/monitoring/api/metrics_gcp#gcp-firestore[GCP Firestore Monitoring API]. The field names have been left untouched for people already familiar with them. | ||
|
||
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. | ||
|
||
[float] | ||
=== Metrics | ||
Here is a list of metrics collected by `firestore` metricset: | ||
|
||
- `firestore.document.delete_count`: The number of successful document deletes. | ||
- `firestore.document.read_count`: The number of successful document reads from queries or lookups. | ||
- `firestore.document.write_count`: The number of successful document writes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- name: firestore | ||
description: Google Cloud Firestore metrics | ||
release: beta | ||
type: group | ||
fields: | ||
- name: document.delete.count | ||
type: long | ||
description: The number of successful document deletes. | ||
- name: document.read.count | ||
type: long | ||
description: The number of successful document reads from queries or lookups. | ||
- name: document.write.count | ||
type: long | ||
description: The number of successful document writes. |
59 changes: 59 additions & 0 deletions
59
x-pack/metricbeat/module/gcp/firestore/firestore_integration_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build integration && gcp | ||
// +build integration,gcp | ||
|
||
package firestore | ||
|
||
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, "firestore") | ||
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 { | ||
v, err := e.GetValue(metricPrefix) | ||
return err == nil && v != nil | ||
} | ||
} | ||
|
||
dataFiles := []struct { | ||
metricPrefix string | ||
path string | ||
}{ | ||
{"gcp.firestore", "./_meta/data.json"}, | ||
{"gcp.firestore.document", "./_meta/data_document.json"}, | ||
} | ||
|
||
config := metrics.GetConfigForTest(t, "firestore") | ||
|
||
for _, df := range dataFiles { | ||
metricSet := mbtest.NewFetcher(t, config) | ||
t.Run(fmt.Sprintf("metric prefix: %s", df.metricPrefix), func(t *testing.T) { | ||
metricSet.WriteEventsCond(t, df.path, metricPrefixIs(df.metricPrefix)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package firestore | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/elastic/beats/v7/metricbeat/mb" | ||
|
||
// Register input module and metricset | ||
_ "github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp" | ||
_ "github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp/metrics" | ||
) | ||
|
||
func init() { | ||
// To be moved to some kind of helper | ||
os.Setenv("BEAT_STRICT_PERMS", "false") | ||
mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
default: false | ||
input: | ||
module: gcp | ||
metricset: metrics | ||
defaults: | ||
metrics: | ||
- service: firestore | ||
metric_types: | ||
- "document/delete_count" | ||
- "document/read_count" | ||
- "document/write_count" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.