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

added aws prometheus remote write exporter #1

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cbf82a4
Bump google.golang.org/grpc in /processor/routingprocessor (#1461)
dependabot[bot] Nov 2, 2020
a57ca78
Bump google.golang.org/grpc in /exporter/honeycombexporter (#1459)
dependabot[bot] Nov 2, 2020
f1c65b4
Bump github.com/golang/protobuf (#1460)
dependabot[bot] Nov 2, 2020
e6fa612
Bump go.opencensus.io in /receiver/signalfxreceiver (#1458)
dependabot[bot] Nov 2, 2020
d1f0791
Bump go.opencensus.io from 0.22.4 to 0.22.5 in /receiver/sapmreceiver…
dependabot[bot] Nov 2, 2020
1edd086
Bump github.com/klauspost/compress in /exporter/honeycombexporter (#1…
dependabot[bot] Nov 2, 2020
81acd56
Bump k8s.io/client-go in /receiver/simpleprometheusreceiver (#1463)
dependabot[bot] Nov 2, 2020
96ae0ad
Bump gopkg.in/DataDog/dd-trace-go.v1 in /exporter/datadogexporter (#1…
dependabot[bot] Nov 2, 2020
652f6a8
Bump github.com/aws/aws-sdk-go in /exporter/awsemfexporter (#1469)
dependabot[bot] Nov 2, 2020
a4a6eed
Bump google.golang.org/api in /exporter/stackdriverexporter (#1473)
dependabot[bot] Nov 2, 2020
4bd9b24
Bump github.com/aws/aws-sdk-go in /exporter/awsxrayexporter (#1466)
dependabot[bot] Nov 2, 2020
5aa38e6
Bump github.com/aws/aws-sdk-go in /receiver/awsxrayreceiver (#1462)
dependabot[bot] Nov 2, 2020
1438a7b
Bump github.com/aws/aws-sdk-go in /processor/resourcedetectionprocess…
dependabot[bot] Nov 2, 2020
2570f3c
Bump github.com/aws/aws-sdk-go in /internal/awsxray/testdata/sampleap…
dependabot[bot] Nov 3, 2020
a744d33
Bump go.opencensus.io from 0.22.4 to 0.22.5 in /exporter/datadogexpor…
dependabot[bot] Nov 3, 2020
1f66966
Bump github.com/golang/protobuf in /exporter/awsemfexporter (#1471)
dependabot[bot] Nov 3, 2020
e07994f
Bump github.com/aws/aws-sdk-go in /exporter/datadogexporter (#1476)
dependabot[bot] Nov 3, 2020
aae1eee
Bump google.golang.org/grpc in /exporter/azuremonitorexporter (#1470)
dependabot[bot] Nov 3, 2020
dc445c4
Bump google.golang.org/grpc in /exporter/stackdriverexporter (#1474)
dependabot[bot] Nov 3, 2020
9321514
Run Auto Assign workflow once draft PRs are ready for review (#1481)
bogdandrutu Nov 3, 2020
06833c8
Bump github.com/hashicorp/go-hclog in /exporter/logzioexporter (#1467)
dependabot[bot] Nov 3, 2020
507fac5
Bump go.opencensus.io in /receiver/splunkhecreceiver (#1455)
dependabot[bot] Nov 3, 2020
2318c3f
[datadog exporter] Remove option to change the namespace prefix (#1483)
albertvaka Nov 3, 2020
e3e304a
Add metric filter option to metrics transform processor (#1447)
james-bebbington Nov 3, 2020
c2f0ce4
Remove unnecessary dependencies from tracegen (#1480)
bogdandrutu Nov 3, 2020
4be0f7c
Increase memory limits for TestLog10kDPS/OTLP to avoid failures on Ci…
tigrannajaryan Nov 3, 2020
60de58c
Upgrade otel collector core, fix remove of the Set Array/Map values (…
bogdandrutu Nov 3, 2020
db507b3
[datadog exporter] Move ProcessMetrics test to metrics package (#1488)
albertvaka Nov 3, 2020
3b7afff
Update aws xray receiver readme (#1485)
JohnWu20 Nov 4, 2020
59a1114
Add @kbrockhoff as an Approver (#1492)
tigrannajaryan Nov 4, 2020
95011c7
Add @andrewhsu as triager to the collector (#1496)
bogdandrutu Nov 5, 2020
507ad41
Skip processing empty metric slice in Stackdriver exporter (#1494)
nilebox Nov 5, 2020
86af421
Improved ECS attribute and origin translation in awsxrayexporter (#1428)
willarmiros Nov 5, 2020
5485adb
added aws prometheus remote write exporter
Nov 3, 2020
a124c20
added copyrights
Nov 4, 2020
66682ed
updated documentation
Nov 5, 2020
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
1 change: 1 addition & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ assigneeGroups:
- james-bebbington
- jrcamp
- jpkrohling
- kbrockhoff
- nilebox
- owais
- tigrannajaryan
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-assign-owners.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Auto Assign'
on:
pull_request_target:
types: [opened]
types: [opened, ready_for_review]

jobs:
add-owner:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ might be a good starting point.
See [CONTRIBUTING.md](CONTRIBUTING.md).

Triagers ([@open-telemetry/collector-contrib-triagers](https://github.com/orgs/open-telemetry/teams/collector-contrib-triagers))
- [Andrew Hsu](https://github.com/andrewhsu), Lightstep
- [Steve Flanders](https://github.com/flands), Splunk

Approvers ([@open-telemetry/collector-contrib-approvers](https://github.com/orgs/open-telemetry/teams/collector-contrib-approvers)):
Expand All @@ -77,6 +78,7 @@ Approvers ([@open-telemetry/collector-contrib-approvers](https://github.com/orgs
- [James Bebbington](https://github.com/james-bebbington), Google
- [Jay Camp](https://github.com/jrcamp), Splunk
- [Juraci Paixão Kröhling](https://github.com/jpkrohling), Red Hat
- [Kevin Brockhoff](https://github.com/kbrockhoff), Daugherty Business Solutions
- [Nail Islamov](https://github.com/nilebox), Google
- [Owais Lone](https://github.com/owais), Splunk

Expand Down
2 changes: 2 additions & 0 deletions cmd/otelcontribcol/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsprometheusremotewriteexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuremonitorexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter"
Expand Down Expand Up @@ -117,6 +118,7 @@ func components() (component.Factories, error) {

exporters := []component.ExporterFactory{
alibabacloudlogserviceexporter.NewFactory(),
awsprometheusremotewriteexporter.NewFactory(),
awsemfexporter.NewFactory(),
awsxrayexporter.NewFactory(),
azuremonitorexporter.NewFactory(),
Expand Down
2 changes: 1 addition & 1 deletion exporter/alibabacloudlogserviceexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/gogo/protobuf v1.3.1
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.13.1-0.20201101004512-f4e4382d0e0e
go.opentelemetry.io/collector v0.13.1-0.20201103180041-ab843b20c2fb
go.uber.org/zap v1.16.0
google.golang.org/protobuf v1.25.0
)
4 changes: 2 additions & 2 deletions exporter/alibabacloudlogserviceexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/collector v0.13.1-0.20201101004512-f4e4382d0e0e h1:rQyA+iPCbebK4DoBWW2YpvUyvnbXkvOctMkyCNcNDJw=
go.opentelemetry.io/collector v0.13.1-0.20201101004512-f4e4382d0e0e/go.mod h1:itblxiZ5r454TNNQVvcAp7vj7LbwCdeNRtodo2t+lGM=
go.opentelemetry.io/collector v0.13.1-0.20201103180041-ab843b20c2fb h1:3M71pl4LBA6t3cEenTRvB9i0W7BAwoO7u5eE6C1LMds=
go.opentelemetry.io/collector v0.13.1-0.20201103180041-ab843b20c2fb/go.mod h1:itblxiZ5r454TNNQVvcAp7vj7LbwCdeNRtodo2t+lGM=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand Down
6 changes: 3 additions & 3 deletions exporter/awsemfexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemf
go 1.14

require (
github.com/aws/aws-sdk-go v1.34.9
github.com/aws/aws-sdk-go v1.35.20
github.com/census-instrumentation/opencensus-proto v0.3.0
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.2
github.com/stretchr/testify v1.6.1
go.opentelemetry.io/collector v0.13.1-0.20201101004512-f4e4382d0e0e
go.opentelemetry.io/collector v0.13.1-0.20201103180041-ab843b20c2fb
go.uber.org/zap v1.16.0
)
15 changes: 10 additions & 5 deletions exporter/awsemfexporter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:l
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.34.9 h1:cUGBW9CVdi0mS7K1hDzxIqTpfeWhpoQiguq81M1tjK0=
github.com/aws/aws-sdk-go v1.34.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.35.20 h1:Hs7x9Czh+MMPnZLQqHhsuZKeNFA3Vuf7pdy2r5QlVb0=
github.com/aws/aws-sdk-go v1.35.20/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down Expand Up @@ -438,8 +439,9 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
Expand Down Expand Up @@ -638,8 +640,11 @@ github.com/jingyugao/rowserrcheck v0.0.0-20191204022205-72ab7603b68a/go.mod h1:x
github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3 h1:jNYPNLe3d8smommaoQlK7LOA5ESyUJJ+Wf79ZtA7Vp4=
github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/jmoiron/sqlx v1.2.1-0.20190826204134-d7d95172beb5/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
Expand Down Expand Up @@ -1130,8 +1135,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/collector v0.13.1-0.20201101004512-f4e4382d0e0e h1:rQyA+iPCbebK4DoBWW2YpvUyvnbXkvOctMkyCNcNDJw=
go.opentelemetry.io/collector v0.13.1-0.20201101004512-f4e4382d0e0e/go.mod h1:itblxiZ5r454TNNQVvcAp7vj7LbwCdeNRtodo2t+lGM=
go.opentelemetry.io/collector v0.13.1-0.20201103180041-ab843b20c2fb h1:3M71pl4LBA6t3cEenTRvB9i0W7BAwoO7u5eE6C1LMds=
go.opentelemetry.io/collector v0.13.1-0.20201103180041-ab843b20c2fb/go.mod h1:itblxiZ5r454TNNQVvcAp7vj7LbwCdeNRtodo2t+lGM=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand Down
1 change: 1 addition & 0 deletions exporter/awsprometheusremotewriteexporter/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
44 changes: 44 additions & 0 deletions exporter/awsprometheusremotewriteexporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# AWS Prometheus Remote Write Exporter

This Exporter sends metrics data in Prometheus TimeSeries format to a Prometheus Remote Write Backend and signs each outgoing HTTP request following
the AWS Signature Version 4 signing process. AWS region and service must be provided in the configuration file, and AWS
credentials are retrieved from the [default credential chain](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials)
of the AWS SDK for Go.

Note: this exporter imports and uses the [Prometheus remote write exporter](https://github.com/open-telemetry/opentelemetry-collector/tree/master/exporter/prometheusremotewriteexporter)
from upstream, and simply wraps it in Sigv4 authentication logic

Same as the Prometheus remote write exporter, this exporter checks the temporality and the type of each incoming metric
and only exports the following combination:

- Int64 or Double type with any temporality
- MonotonicInt64, MonotonicDouble, Histogram, or Summary with only Cumulative temporality.

## Configuration
The following settings are required:
- `endpoint`: protocol:host:port to which the exporter is going to send traces or metrics, using the HTTP/HTTPS protocol.

The following settings can be optionally configured:
- `namespace`: prefix attached to each exported metric name.
- `headers`: additional headers attached to each HTTP request. If `X-Prometheus-Remote-Write-Version` is set by user, its value must be `0.1.0`
- `insecure` (default = false): whether to enable client transport security for the exporter's connection.
- `ca_file`: path to the CA cert. For a client this verifies the server certificate. Should only be used if `insecure` is set to true.
- `cert_file`: path to the TLS cert to use for TLS required connections. Should only be used if `insecure` is set to true.
- `key_file`: path to the TLS key to use for TLS required connections. Should only be used if `insecure` is set to true.
- `timeout` (default = 5s): How long to wait until the connection is close.
- `read_buffer_size` (default = 0): ReadBufferSize for HTTP client.
- `write_buffer_size` (default = 512 * 1024): WriteBufferSize for HTTP client.
- `aws_auth`: whether each request should be signed with AWS Sig v4. The following settings must be configured:
- `region`: region of the AWS service being exported to.
- `service`: AWS service being exported to.


Example:

```yaml
exporters:
awsprometheusremotewrite:
endpoint: "http://some.url:9411/api/prom/push"
```
The full list of settings exposed for this exporter are documented [here](./config.go)
with detailed sample configurations [here](./testdata/config.yaml).
96 changes: 96 additions & 0 deletions exporter/awsprometheusremotewriteexporter/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright The OpenTelemetry Authors
//
// 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
//
// http://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 awsprometheusremotewriteexporter

import (
"bytes"
"io/ioutil"
"log"
"net/http"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
)

// SigningRoundTripper is a Custom RoundTripper that performs AWS Sig V4
type SigningRoundTripper struct {
transport http.RoundTripper
signer *v4.Signer
cfg *aws.Config
params AuthSettings
}

// RoundTrip signs each outgoing request
func (si *SigningRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
reqBody, err := req.GetBody()
if err != nil {
return nil, err
}

// Get the body
content, err := ioutil.ReadAll(reqBody)
if err != nil {
return nil, err
}

body := bytes.NewReader(content)

// Sign the request
_, err = si.signer.Sign(req, body, si.params.Service, *si.cfg.Region, time.Now())
if err != nil {
return nil, err
}

// Send the request to Prometheus Remote Write Backend
resp, err := si.transport.RoundTrip(req)
if err != nil {
log.Fatal(err)
return nil, err
}

return resp, err
}

// NewAuth takes a map of strings as parameters and return a http.RoundTripper that perform Sig V4 signing on each
// request.
func NewAuth(params AuthSettings, origClient *http.Client) (http.RoundTripper, error) {
// Initialize session with default credential chain
// https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html
sess, err := session.NewSession(&aws.Config{
Region: aws.String(params.Region)},
aws.NewConfig().WithLogLevel(aws.LogDebugWithSigning),
)
if err != nil {
return nil, err
}

if _, err = sess.Config.Credentials.Get(); err != nil {
return nil, err
}

// Get Credentials, either from ./aws or from environmental variables
creds := sess.Config.Credentials
signer := v4.NewSigner(creds)
rtp := SigningRoundTripper{
transport: origClient.Transport,
signer: signer,
cfg: sess.Config,
params: params,
}
// return a RoundTripper
return &rtp, nil
}
47 changes: 47 additions & 0 deletions exporter/awsprometheusremotewriteexporter/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright The OpenTelemetry Authors
//
// 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
//
// http://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 awsprometheusremotewriteexporter

import (
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

// Config defines configuration for Remote Write exporter.
type Config struct {
// squash ensures fields are correctly decoded in embedded struct.
configmodels.ExporterSettings `mapstructure:",squash"`
exporterhelper.TimeoutSettings `mapstructure:",squash"`
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`

// prefix attached to each exported metric name
// See: https://prometheus.io/docs/practices/naming/#metric-names
Namespace string `mapstructure:"namespace"`

// AWS Sig V4 configuration options
AuthSettings AuthSettings `mapstructure:"aws_auth"`

HTTPClientSettings confighttp.HTTPClientSettings `mapstructure:",squash"`
}

// AuthSettings defines AWS authentication configurations for SigningRoundTripper
type AuthSettings struct {
// region string for AWS Sig V4
Region string `mapstructure:"region"`
// service string for AWS Sig V4
Service string `mapstructure:"service"`
}
Loading