-
Notifications
You must be signed in to change notification settings - Fork 487
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
Add otel.receiver.aws_firehose
component
#6005
Open
Obito1903
wants to merge
24
commits into
grafana:main
Choose a base branch
from
Obito1903:otel-awsfirehose
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1732e07
Add `otel.receiver.awsfirehose` component
Obito1903 8b6deaa
Update component/otelcol/receiver/awsfirehose/awsfirehose.go
Obito1903 dfb3482
Update component/otelcol/receiver/awsfirehose/awsfirehose.go
Obito1903 afc64f7
Update according pr suggestions
Obito1903 2b1f5d9
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 d217b03
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 ee32667
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 3158090
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 aaa0b62
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 69bc356
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 8262acb
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 d50287e
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 041d825
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 38a1866
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 4279489
Tidy up, regenerate go.sum, docs
tpaschalis 94d4533
Fix test
tpaschalis b79ad9d
Add changelog entry
tpaschalis 4fbbae8
Merge branch 'main' into otel-awsfirehose
tpaschalis 486b376
Fix correct docs
tpaschalis 6b061ee
Fix debug metrics docs
tpaschalis 31a2b6f
Remove unused example outputs
tpaschalis d6181f1
Update docs/sources/flow/reference/components/otelcol.receiver.aws_fi…
tpaschalis 74c3a09
Fix docs, set default high cardinality labels
tpaschalis ac76d87
Merge branch 'main' into otel-awsfirehose
tpaschalis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Package awsfirehose provides an otelcol.receiver.aws_firehose component. | ||
package awsfirehose | ||
|
||
import ( | ||
"github.com/grafana/agent/component" | ||
"github.com/grafana/agent/component/otelcol" | ||
"github.com/grafana/agent/component/otelcol/receiver" | ||
"github.com/grafana/river/rivertypes" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver" | ||
otelcomponent "go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config/configopaque" | ||
otelextension "go.opentelemetry.io/collector/extension" | ||
) | ||
|
||
func init() { | ||
component.Register(component.Registration{ | ||
Name: "otelcol.receiver.aws_firehose", | ||
Args: Arguments{}, | ||
|
||
Build: func(opts component.Options, args component.Arguments) (component.Component, error) { | ||
fact := awsfirehosereceiver.NewFactory() | ||
return receiver.New(opts, fact, args.(Arguments)) | ||
}, | ||
}) | ||
} | ||
|
||
// Arguments configures the otelcol.receiver.awsfirehose component. | ||
type Arguments struct { | ||
// The type of record being received from the delivery stream. | ||
// Each unmarshaler handles a specific type, | ||
// so the field allows the receiver to use the correct one. | ||
RecordType string `river:"record_type,attr,optional"` | ||
|
||
// The access key to be checked on each request received. | ||
AccessKey rivertypes.Secret `river:"access_key,attr,optional"` | ||
|
||
HTTPServer otelcol.HTTPServerArguments `river:",squash"` | ||
|
||
// DebugMetrics configures component internal metrics. Optional. | ||
DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"` | ||
|
||
// Output configures where to send received data. Required. | ||
Output *otelcol.ConsumerArguments `river:"output,block"` | ||
} | ||
|
||
var _ receiver.Arguments = Arguments{} | ||
|
||
// DefaultArguments holds default settings for otelcol.receiver.awsfirehose. | ||
var DefaultArguments = Arguments{ | ||
RecordType: "cwmetrics", | ||
HTTPServer: otelcol.HTTPServerArguments{ | ||
Endpoint: "0.0.0.0:4433", | ||
}, | ||
} | ||
|
||
// SetToDefault implements river.Defaulter. | ||
func (args *Arguments) SetToDefault() { | ||
*args = DefaultArguments | ||
} | ||
|
||
// Convert implements receiver.Arguments. | ||
func (args Arguments) Convert() (otelcomponent.Config, error) { | ||
return &awsfirehosereceiver.Config{ | ||
RecordType: args.RecordType, | ||
AccessKey: configopaque.String(args.AccessKey), | ||
HTTPServerSettings: *args.HTTPServer.Convert(), | ||
}, nil | ||
} | ||
|
||
// Extensions implements receiver.Arguments. | ||
func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension { | ||
return nil | ||
} | ||
|
||
// Exporters implements receiver.Arguments. | ||
func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component { | ||
return nil | ||
} | ||
|
||
// NextConsumers implements receiver.Arguments. | ||
func (args Arguments) NextConsumers() *otelcol.ConsumerArguments { | ||
return args.Output | ||
} | ||
|
||
// DebugMetricsConfig implements receiver.Arguments. | ||
func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments { | ||
return args.DebugMetrics | ||
} |
86 changes: 86 additions & 0 deletions
86
component/otelcol/receiver/awsfirehose/awsfirehose_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,86 @@ | ||
package awsfirehose_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/grafana/agent/component/otelcol/receiver/awsfirehose" | ||
"github.com/grafana/agent/pkg/flow/componenttest" | ||
"github.com/grafana/agent/pkg/util" | ||
"github.com/grafana/river" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsfirehosereceiver" | ||
"github.com/phayes/freeport" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRun(t *testing.T) { | ||
httpAddr := getFreeAddr(t) | ||
|
||
ctx := componenttest.TestContext(t) | ||
l := util.TestLogger(t) | ||
|
||
ctrl, err := componenttest.NewControllerFromID(l, "otelcol.receiver.aws_firehose") | ||
require.NoError(t, err) | ||
|
||
cfg := fmt.Sprintf(` | ||
endpoint = "%s" | ||
|
||
output { /* no-op */ } | ||
`, httpAddr) | ||
|
||
var args awsfirehose.Arguments | ||
require.NoError(t, river.Unmarshal([]byte(cfg), &args)) | ||
|
||
go func() { | ||
err := ctrl.Run(ctx, args) | ||
require.NoError(t, err) | ||
}() | ||
|
||
require.NoError(t, ctrl.WaitRunning(time.Second)) | ||
} | ||
|
||
func TestArguments_UnmarshalRiver(t *testing.T) { | ||
t.Run("grpc", func(t *testing.T) { | ||
httpAddr := getFreeAddr(t) | ||
in := fmt.Sprintf(` | ||
endpoint = "%s" | ||
cors { | ||
allowed_origins = ["https://*.test.com", "https://test.com"] | ||
} | ||
|
||
record_type = "cwmetrics" | ||
|
||
debug_metrics { | ||
disable_high_cardinality_metrics = true | ||
} | ||
|
||
output { /* no-op */ } | ||
`, httpAddr) | ||
|
||
var args awsfirehose.Arguments | ||
require.NoError(t, river.Unmarshal([]byte(in), &args)) | ||
require.Equal(t, args.DebugMetricsConfig().DisableHighCardinalityMetrics, true) | ||
ext, err := args.Convert() | ||
require.NoError(t, err) | ||
otelArgs, ok := (ext).(*awsfirehosereceiver.Config) | ||
|
||
require.True(t, ok) | ||
|
||
// Check the arguments | ||
require.Equal(t, otelArgs.HTTPServerSettings.Endpoint, httpAddr) | ||
require.Equal(t, len(otelArgs.HTTPServerSettings.CORS.AllowedOrigins), 2) | ||
require.Equal(t, otelArgs.HTTPServerSettings.CORS.AllowedOrigins[0], "https://*.test.com") | ||
require.Equal(t, otelArgs.HTTPServerSettings.CORS.AllowedOrigins[1], "https://test.com") | ||
require.Equal(t, otelArgs.RecordType, "cwmetrics") | ||
}) | ||
} | ||
|
||
func getFreeAddr(t *testing.T) string { | ||
t.Helper() | ||
|
||
portNumber, err := freeport.GetFreePort() | ||
require.NoError(t, err) | ||
|
||
return fmt.Sprintf("localhost:%d", portNumber) | ||
} |
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
165 changes: 165 additions & 0 deletions
165
docs/sources/flow/reference/components/otelcol.receiver.aws_firehose.md
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,165 @@ | ||
--- | ||
aliases: | ||
- /docs/grafana-cloud/agent/flow/reference/components/otelcol.receiver.aws_firehose/ | ||
- /docs/grafana-cloud/monitor-infrastructure/agent/flow/reference/components/otelcol.receiver.aws_firehose/ | ||
- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/otelcol.receiver.aws_firehose/ | ||
- /docs/grafana-cloud/send-data/agent/flow/reference/components/otelcol.receiver.aws_firehose/ | ||
canonical: https://grafana.com/docs/agent/latest/flow/reference/components/otelcol.receiver.aws_firehose/ | ||
description: Learn about otelcol.receiver.aws_firehose | ||
label: | ||
stage: experimental | ||
title: otelcol.receiver.aws_firehose | ||
--- | ||
|
||
# otelcol.receiver.aws_firehose | ||
|
||
`otelcol.receiver.aws_firehose` receives metrics from [Cloudwatch Metrics Streams](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Metric-Streams.html) using AWS Kinesis Data Firehose and forwards it to other `otelcol.*` components. | ||
|
||
Set the output format of the Metrics Stream to JSON. Make sure the receiver is accessible by AWS on port 443. You can set the output format with a load balancer. | ||
|
||
{{% admonition type="note" %}} | ||
`otelcol.receiver.aws_firehose` is a wrapper over the upstream OpenTelemetry Collector `awsfirehose` receiver. If necessary, bug reports or feature requests are redirected to the upstream repository. | ||
{{% /admonition %}} | ||
|
||
You can specify multiple `otelcol.receiver.aws_firehose` components by giving them different labels. | ||
|
||
## Usage | ||
|
||
```river | ||
otelcol.receiver.aws_firehose "LABEL" { | ||
endpoint = "HOST:PORT" | ||
output { | ||
metrics = [...] | ||
} | ||
} | ||
``` | ||
|
||
## Arguments | ||
|
||
`otelcol.receiver.aws_firehose` supports the following arguments: | ||
|
||
Name | Type | Description | Default | Required | ||
---- | ---- | ----------- | ------- | -------- | ||
`record_type` | `string` | The type of record received from the delivery stream. | `cwmetrics` | no | ||
`access_key` | `secret` | The access key to be checked on each request received. | | no | ||
`endpoint` | `string` | `host:port` to listen for traffic on. | `"0.0.0.0:4433"` | no | ||
`max_request_body_size` | `string` | Maximum request body size the HTTP server will allow. No limit when unset. | | no | ||
`include_metadata` | `boolean` | Propagate incoming connection metadata to downstream consumers. | | no | ||
|
||
`access_key` can be set when creating or updating the delivery stream. See the [AWS Firehose documentation](https://docs.aws.amazon.com/firehose/latest/dev/create-destination.html#create-destination-http) for more details. | ||
|
||
The supported values for `record_type` are: | ||
* `cwmetrics`: The record type for the CloudWatch metric stream. Expects the format for the records to be JSON. See the [CloudWatch documentation][cloudwatch-metric-streams] for details. | ||
[cloudwatch-metric-streams]: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Metric-Streams.html | ||
|
||
## Blocks | ||
|
||
The following blocks are supported inside the definition of | ||
`otelcol.receiver.aws_firehose`: | ||
|
||
Hierarchy | Block | Description | Required | ||
--------- | ----- | ----------- | -------- | ||
tls | [tls][] | Configures TLS for the HTTP server. | no | ||
cors | [cors][] | Configures CORS for the HTTP server. | no | ||
debug_metrics | [debug_metrics][] | Configures the metrics that this component generates to monitor its state. | no | ||
output | [output][] | Configures where to send received traces. | yes | ||
|
||
The `>` symbol indicates deeper levels of nesting. For example, `grpc > tls` | ||
refers to a `tls` block defined inside a `grpc` block. | ||
|
||
[tls]: #tls-block | ||
[cors]: #cors-block | ||
[debug_metrics]: #debug_metrics-block | ||
[output]: #output-block | ||
|
||
### tls block | ||
|
||
The `tls` block configures TLS settings used for a server. If the `tls` block | ||
isn't provided, TLS won't be used for connections to the server. | ||
|
||
{{< docs/shared lookup="flow/reference/components/otelcol-tls-config-block.md" source="agent" version="<AGENT_VERSION>" >}} | ||
|
||
### cors block | ||
|
||
The `cors` block configures CORS settings for an HTTP server. | ||
|
||
The following arguments are supported: | ||
|
||
Name | Type | Description | Default | Required | ||
---- | ---- | ----------- | ------- | -------- | ||
`allowed_origins` | `list(string)` | Allowed values for the `Origin` header. | | no | ||
`allowed_headers` | `list(string)` | Accepted headers from CORS requests. | `["X-Requested-With"]` | no | ||
`max_age` | `number` | Configures the `Access-Control-Max-Age` response header. | | no | ||
|
||
The `allowed_headers` argument specifies which headers are acceptable from a | ||
CORS request. The following headers are always implicitly allowed: | ||
|
||
* `Accept` | ||
* `Accept-Language` | ||
* `Content-Type` | ||
* `Content-Language` | ||
|
||
If `allowed_headers` includes `"*"`, all headers are permitted. | ||
|
||
### debug_metrics block | ||
|
||
{{< docs/shared lookup="flow/reference/components/otelcol-debug-metrics-block.md" source="agent" version="<AGENT_VERSION>" >}} | ||
|
||
### output block | ||
|
||
{{< docs/shared lookup="flow/reference/components/output-block.md" source="agent" version="<AGENT_VERSION>" >}} | ||
tpaschalis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Exported fields | ||
|
||
`otelcol.receiver.aws_firehose` does not export any fields. | ||
|
||
## Component health | ||
|
||
`otelcol.receiver.aws_firehose` is only reported as unhealthy if given an invalid | ||
configuration. | ||
|
||
## Debug information | ||
|
||
`otelcol.receiver.aws_firehose` does not expose any component-specific debug | ||
information. | ||
|
||
## Example | ||
|
||
This example forwards received metrics through a batch processor before finally | ||
sending it to an OTLP-capable endpoint: | ||
|
||
```river | ||
otelcol.receiver.aws_firehose "default" { | ||
endpoint = "0.0.0.0:4433" | ||
output { | ||
metrics = [otelcol.processor.batch.default.input] | ||
} | ||
} | ||
|
||
otelcol.processor.batch "default" { | ||
output { | ||
metrics = [otelcol.exporter.otlp.default.input] | ||
} | ||
} | ||
|
||
otelcol.exporter.otlp "default" { | ||
client { | ||
endpoint = env("OTLP_ENDPOINT") | ||
} | ||
} | ||
``` | ||
<!-- START GENERATED COMPATIBLE COMPONENTS --> | ||
|
||
## Compatible components | ||
|
||
`otelcol.receiver.aws_firehose` can accept arguments from the following components: | ||
|
||
- Components that export [OpenTelemetry `otelcol.Consumer`]({{< relref "../compatibility/#opentelemetry-otelcolconsumer-exporters" >}}) | ||
|
||
|
||
{{< admonition type="note" >}} | ||
Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. | ||
Refer to the linked documentation for more details. | ||
{{< /admonition >}} | ||
|
||
<!-- END GENERATED COMPATIBLE COMPONENTS --> |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New topic? We don't really need to add all these aliases. We only need them if the topic moves or is renamed after it has been published at least once. It's not hurting anything to add them, but they aren't necessary.