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

Add otel.receiver.aws_firehose component #6005

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1732e07
Add `otel.receiver.awsfirehose` component
Obito1903 Dec 19, 2023
8b6deaa
Update component/otelcol/receiver/awsfirehose/awsfirehose.go
Obito1903 Dec 19, 2023
dfb3482
Update component/otelcol/receiver/awsfirehose/awsfirehose.go
Obito1903 Dec 19, 2023
afc64f7
Update according pr suggestions
Obito1903 Dec 19, 2023
2b1f5d9
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Dec 20, 2023
d217b03
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Dec 20, 2023
ee32667
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Dec 20, 2023
3158090
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Dec 20, 2023
aaa0b62
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Dec 20, 2023
69bc356
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Dec 20, 2023
8262acb
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Jan 29, 2024
d50287e
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Jan 29, 2024
041d825
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Jan 29, 2024
38a1866
Update docs/sources/flow/reference/components/otelcol.receiver.awsfir…
Obito1903 Jan 29, 2024
4279489
Tidy up, regenerate go.sum, docs
tpaschalis Feb 20, 2024
94d4533
Fix test
tpaschalis Feb 20, 2024
b79ad9d
Add changelog entry
tpaschalis Feb 20, 2024
4fbbae8
Merge branch 'main' into otel-awsfirehose
tpaschalis Feb 20, 2024
486b376
Fix correct docs
tpaschalis Feb 21, 2024
6b061ee
Fix debug metrics docs
tpaschalis Feb 21, 2024
31a2b6f
Remove unused example outputs
tpaschalis Feb 21, 2024
d6181f1
Update docs/sources/flow/reference/components/otelcol.receiver.aws_fi…
tpaschalis Feb 26, 2024
74c3a09
Fix docs, set default high cardinality labels
tpaschalis Feb 26, 2024
ac76d87
Merge branch 'main' into otel-awsfirehose
tpaschalis Feb 29, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Main (unreleased)
- A new `otelcol.processor.resourcedetection` component which inserts resource attributes
to OTLP telemetry based on the host on which Grafana Agent is running. (@ptodev)

- A new `otelcol.receiver.aws_firehose` component which receives log entries
from AWS Firehose. (@Obito1903)

- Expose track_timestamps_staleness on Prometheus scraping, to fix the issue where container metrics live for 5 minutes after the container disappears. (@ptodev)

- Introduce the `remotecfg` service that enables loading configuration from a
Expand Down
1 change: 1 addition & 0 deletions component/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import (
_ "github.com/grafana/agent/component/otelcol/processor/span" // Import otelcol.processor.span
_ "github.com/grafana/agent/component/otelcol/processor/tail_sampling" // Import otelcol.processor.tail_sampling
_ "github.com/grafana/agent/component/otelcol/processor/transform" // Import otelcol.processor.transform
_ "github.com/grafana/agent/component/otelcol/receiver/awsfirehose" // Import otelcol.receiver.awsfirehose
_ "github.com/grafana/agent/component/otelcol/receiver/jaeger" // Import otelcol.receiver.jaeger
_ "github.com/grafana/agent/component/otelcol/receiver/kafka" // Import otelcol.receiver.kafka
_ "github.com/grafana/agent/component/otelcol/receiver/loki" // Import otelcol.receiver.loki
Expand Down
88 changes: 88 additions & 0 deletions component/otelcol/receiver/awsfirehose/awsfirehose.go
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 component/otelcol/receiver/awsfirehose/awsfirehose_test.go
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)
}
1 change: 1 addition & 0 deletions docs/sources/flow/reference/compatibility/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ The following components, grouped by namespace, _consume_ OpenTelemetry `otelcol
- [otelcol.processor.span]({{< relref "../components/otelcol.processor.span.md" >}})
- [otelcol.processor.tail_sampling]({{< relref "../components/otelcol.processor.tail_sampling.md" >}})
- [otelcol.processor.transform]({{< relref "../components/otelcol.processor.transform.md" >}})
- [otelcol.receiver.aws_firehose]({{< relref "../components/otelcol.receiver.aws_firehose.md" >}})
- [otelcol.receiver.jaeger]({{< relref "../components/otelcol.receiver.jaeger.md" >}})
- [otelcol.receiver.kafka]({{< relref "../components/otelcol.receiver.kafka.md" >}})
- [otelcol.receiver.loki]({{< relref "../components/otelcol.receiver.loki.md" >}})
Expand Down
42 changes: 21 additions & 21 deletions docs/sources/flow/reference/components/loki.source.awsfirehose.md
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this PR change the loki.source component docs? It's probably by accident?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I accidentally did this as I was trying to make the check for compatible components pass, I'll revert.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
aliases:
- /docs/grafana-cloud/agent/flow/reference/components/loki.source.awsfirehose/
- /docs/grafana-cloud/monitor-infrastructure/agent/flow/reference/components/loki.source.awsfirehose/
- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/loki.source.awsfirehose/
- /docs/grafana-cloud/send-data/agent/flow/reference/components/loki.source.awsfirehose/
canonical: https://grafana.com/docs/agent/latest/flow/reference/components/loki.source.awsfirehose/
description: Learn about loki.source.awsfirehose
title: loki.source.awsfirehose
- /docs/grafana-cloud/agent/flow/reference/components/loki.source.aws_firehose/
- /docs/grafana-cloud/monitor-infrastructure/agent/flow/reference/components/loki.source.aws_firehose/
- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/loki.source.aws_firehose/
- /docs/grafana-cloud/send-data/agent/flow/reference/components/loki.source.aws_firehose/
canonical: https://grafana.com/docs/agent/latest/flow/reference/components/loki.source.aws_firehose/
description: Learn about loki.source.aws_firehose
title: loki.source.aws_firehose
---

# loki.source.awsfirehose
# loki.source.aws_firehose

`loki.source.awsfirehose` receives log entries over HTTP
`loki.source.aws_firehose` receives log entries over HTTP
from [AWS Firehose](https://docs.aws.amazon.com/firehose/latest/dev/what-is-this-service.html)
and forwards them to other `loki.*` components.

Expand Down Expand Up @@ -57,7 +57,7 @@ See [Examples](#example) for a full example configuration showing how to enrich
## Usage

```river
loki.source.awsfirehose "LABEL" {
loki.source.aws_firehose "LABEL" {
http {
listen_address = "LISTEN_ADDRESS"
listen_port = PORT
Expand All @@ -68,12 +68,12 @@ loki.source.awsfirehose "LABEL" {

The component will start an HTTP server on the configured port and address with the following endpoints:

- `/awsfirehose/api/v1/push` - accepting `POST` requests compatible
- `/aws_firehose/api/v1/push` - accepting `POST` requests compatible
with [AWS Firehose HTTP Specifications](https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html).

## Arguments

`loki.source.awsfirehose` supports the following arguments:
`loki.source.aws_firehose` supports the following arguments:

| Name | Type | Description | Default | Required |
| ------------------------ | -------------------- | -------------------------------------------------------------- | ------- | -------- |
Expand All @@ -90,7 +90,7 @@ to the list of receivers in `forward_to`.

## Blocks

The following blocks are supported inside the definition of `loki.source.awsfirehose`:
The following blocks are supported inside the definition of `loki.source.aws_firehose`:

| Hierarchy | Name | Description | Required |
|-----------|----------|----------------------------------------------------|----------|
Expand All @@ -111,11 +111,11 @@ The following blocks are supported inside the definition of `loki.source.awsfire

## Exported fields

`loki.source.awsfirehose` does not export any fields.
`loki.source.aws_firehose` does not export any fields.

## Component health

`loki.source.awsfirehose` is only reported as unhealthy if given an invalid configuration.
`loki.source.aws_firehose` is only reported as unhealthy if given an invalid configuration.

## Debug metrics

Expand All @@ -124,10 +124,10 @@ The following are some of the metrics that are exposed when this component is us
The metrics include labels such as `status_code` where relevant, which you can use to measure request success rates.
{{< /admonition >}}

- `loki_source_awsfirehose_request_errors` (counter): Count of errors while receiving a request.
- `loki_source_awsfirehose_record_errors` (counter): Count of errors while decoding an individual record.
- `loki_source_awsfirehose_records_received` (counter): Count of records received.
- `loki_source_awsfirehose_batch_size` (histogram): Size (in units) of the number of records received per request.
- `loki_source_aws_firehose_request_errors` (counter): Count of errors while receiving a request.
- `loki_source_aws_firehose_record_errors` (counter): Count of errors while decoding an individual record.
- `loki_source_aws_firehose_records_received` (counter): Count of records received.
- `loki_source_aws_firehose_batch_size` (histogram): Size (in units) of the number of records received per request.

## Example

Expand All @@ -146,7 +146,7 @@ loki.write "local" {
}
}

loki.source.awsfirehose "loki_fh_receiver" {
loki.source.aws_firehose "loki_fh_receiver" {
http {
listen_address = "0.0.0.0"
listen_port = 9999
Expand All @@ -172,7 +172,7 @@ loki.write "local" {
}
}

loki.source.awsfirehose "loki_fh_receiver" {
loki.source.aws_firehose "loki_fh_receiver" {
http {
listen_address = "0.0.0.0"
listen_port = 9999
Expand Down
Loading
Loading