forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
googlemanagedprometheus exporter initial commit (open-telemetry#10840)
* googlemanagedprometheus exporter initial commit * address comments
- Loading branch information
Showing
13 changed files
with
548 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 @@ | ||
include ../../Makefile.Common |
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,77 @@ | ||
# Google Managed Service for Prometheus Exporter | ||
|
||
| Status | | | ||
| ------------------------ |-----------------------| | ||
| Stability | [in development](https://github.com/open-telemetry/opentelemetry-collector#in-development) | | ||
| Supported pipeline types | metrics | | ||
| Distributions | [] | | ||
|
||
This exporter can be used to send metrics and traces to [Google Cloud Managed Service for Prometheus](https://cloud.google.com/stackdriver/docs/managed-prometheus). The difference between this exporter and the `googlecloud` exporter is that metrics sent with this exporter are queried using [promql](https://prometheus.io/docs/prometheus/latest/querying/basics/#querying-prometheus), rather than standard the standard MQL. | ||
|
||
This exporter is not the standard method of ingesting metrics into Google Cloud Managed Service for Prometheus, which is built on a drop-in replacement for the Prometheus server: https://github.com/GoogleCloudPlatform/prometheus. This exporter does not support the full range of Prometheus functionality, including the UI, recording and alerting rules, and can't be used with the GMP Operator, but does support sending metrics. | ||
|
||
## Example Configuration | ||
|
||
```yaml | ||
receivers: | ||
prometheus: | ||
config: | ||
scrape_configs: | ||
# Add your prometheus scrape configuration here. | ||
# Using kubernetes_sd_configs with namespaced resources | ||
# ensures the namespace is set on your metrics. | ||
- job_name: 'kubernetes-pods' | ||
kubernetes_sd_configs: | ||
- role: pod | ||
relabel_configs: | ||
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] | ||
action: keep | ||
regex: true | ||
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path] | ||
action: replace | ||
target_label: __metrics_path__ | ||
regex: (.+) | ||
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] | ||
action: replace | ||
regex: (.+):(?:\d+);(\d+) | ||
replacement: $$1:$$2 | ||
target_label: __address__ | ||
- action: labelmap | ||
regex: __meta_kubernetes_pod_label_(.+) | ||
processors: | ||
# groupbyattrs promotes labels from metrics to resources, allowing them to | ||
# be added to the prometheus_target monitored resource. | ||
# This allows exporters which monitor multiple namespaces, such as | ||
# kube-state-metrics, to override the namespace in the resource by setting | ||
# metric labels. | ||
groupbyattrs: | ||
keys: | ||
- namespace | ||
- cluster | ||
- location | ||
batch: | ||
# batch metrics before sending to reduce API usage | ||
send_batch_max_size: 200 | ||
send_batch_size: 200 | ||
timeout: 5s | ||
memory_limiter: | ||
# drop metrics if memory usage gets too high | ||
check_interval: 1s | ||
limit_percentage: 65 | ||
spike_limit_percentage: 20 | ||
resourcedetection: | ||
# detect cluster name and location | ||
detectors: [gcp] | ||
timeout: 10s | ||
exporters: | ||
googlemanagedprometheus: | ||
|
||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [prometheus] | ||
processors: [groupbyattrs, batch, memory_limiter, resourcedetection] | ||
exporters: [googlemanagedprometheus] | ||
``` | ||
|
||
|
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,41 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package googlemanagedprometheusexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlemanagedprometheusexporter" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/exporter/exporterhelper" | ||
) | ||
|
||
// Config defines configuration for Google Cloud Managed Service for Prometheus exporter. | ||
type Config struct { | ||
config.ExporterSettings `mapstructure:",squash"` | ||
|
||
// TODO: add config for the GMP exporter | ||
|
||
// Timeout for all API calls. If not set, defaults to 12 seconds. | ||
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct. | ||
exporterhelper.QueueSettings `mapstructure:"sending_queue"` | ||
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"` | ||
} | ||
|
||
func (cfg *Config) Validate() error { | ||
if err := cfg.ExporterSettings.Validate(); err != nil { | ||
return fmt.Errorf("exporter settings are invalid :%w", err) | ||
} | ||
return nil | ||
} |
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 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package googlemanagedprometheusexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlemanagedprometheusexporter" | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/exporter/exporterhelper" | ||
) | ||
|
||
const ( | ||
// The value of "type" key in configuration. | ||
typeStr = "googlemanagedprometheus" | ||
defaultTimeout = 12 * time.Second // Consistent with Cloud Monitoring's timeout | ||
) | ||
|
||
// NewFactory creates a factory for the googlemanagedprometheus exporter | ||
func NewFactory() component.ExporterFactory { | ||
return component.NewExporterFactory( | ||
typeStr, | ||
createDefaultConfig, | ||
component.WithMetricsExporter(createMetricsExporter), | ||
) | ||
} | ||
|
||
// createDefaultConfig creates the default configuration for exporter. | ||
func createDefaultConfig() config.Exporter { | ||
return &Config{ | ||
ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)), | ||
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: defaultTimeout}, | ||
RetrySettings: exporterhelper.NewDefaultRetrySettings(), | ||
QueueSettings: exporterhelper.NewDefaultQueueSettings(), | ||
} | ||
} | ||
|
||
// createMetricsExporter creates a metrics exporter based on this config. | ||
func createMetricsExporter( | ||
ctx context.Context, | ||
params component.ExporterCreateSettings, | ||
cfg config.Exporter) (component.MetricsExporter, error) { | ||
// TODO: implement the metrics exporter | ||
return nil, fmt.Errorf("not implemented") | ||
} |
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,33 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/googlemanagedprometheusexporter | ||
|
||
go 1.17 | ||
|
||
require go.opentelemetry.io/collector v0.53.0 | ||
|
||
require ( | ||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/knadh/koanf v1.4.1 // indirect | ||
github.com/mitchellh/copystructure v1.2.0 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
go.opencensus.io v0.23.0 // indirect | ||
go.opentelemetry.io/collector/pdata v0.53.0 // indirect | ||
go.opentelemetry.io/otel v1.7.0 // indirect | ||
go.opentelemetry.io/otel/metric v0.30.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.7.0 // indirect | ||
go.uber.org/atomic v1.9.0 // indirect | ||
go.uber.org/multierr v1.8.0 // indirect | ||
go.uber.org/zap v1.21.0 // indirect | ||
golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect | ||
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf // indirect | ||
google.golang.org/grpc v1.47.0 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
) |
Oops, something went wrong.