-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/envoyals] init new receiver (#37193)
- Loading branch information
Showing
25 changed files
with
1,009 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: new_component | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: envoyalsreceiver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add a new receiver for the Envoy ALS (Access Log Service). | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [36464] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
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
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,44 @@ | ||
# Envoy ALS(access log service) receiver | ||
|
||
<!-- status autogenerated section --> | ||
| Status | | | ||
| ------------- |-----------| | ||
| Stability | [development]: logs | | ||
| Distributions | [] | | ||
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fenvoyals%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fenvoyals) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fenvoyals%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fenvoyals) | | ||
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@evan-bradley](https://www.github.com/evan-bradley) | | ||
|
||
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development | ||
<!-- end autogenerated section --> | ||
|
||
This is a receiver for the [Envoy gRPC ALS](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/access_loggers/grpc/v3/als.proto#envoy-v3-api-msg-extensions-access-loggers-grpc-v3-httpgrpcaccesslogconfig) sink. | ||
|
||
Envoy ALS (Access Log Service) is a feature of Envoy Proxy that allows for the | ||
centralized collection and management of access logs. | ||
|
||
Instead of writing access logs to local files, Envoy can be configured to send these logs to a remote gRPC service. | ||
|
||
This is particularly useful in distributed systems where centralized logging is required for monitoring, auditing, and debugging purposes. | ||
|
||
[Istio](https://istio.io) and [Envoy Gateway](https://gateway.envoyproxy.io) support OTLP and gRPC ALS with first class API. | ||
|
||
## Getting Started | ||
|
||
The settings are: | ||
|
||
- `endpoint` (required, default = localhost:19001 gRPC protocol): host:port to which the receiver is going to receive data. See our [security best practices doc](https://opentelemetry.io/docs/security/config-best-practices/#protect-against-denial-of-service-attacks) to understand how to set the endpoint in different environments. | ||
|
||
Example: | ||
```yaml | ||
receivers: | ||
envoyals: | ||
endpoint: 0.0.0.0:3500 | ||
``` | ||
## Advanced Configuration | ||
Other options can be configured to support more advanced use cases: | ||
- [gRPC settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configgrpc/README.md) including CORS | ||
- [TLS and mTLS settings](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.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,90 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package envoyalsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/envoyalsreceiver" | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
|
||
alsv3 "github.com/envoyproxy/go-control-plane/envoy/service/accesslog/v3" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/component/componentstatus" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/receiver" | ||
"go.opentelemetry.io/collector/receiver/receiverhelper" | ||
"go.uber.org/zap" | ||
"google.golang.org/grpc" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/envoyalsreceiver/internal/als" | ||
) | ||
|
||
type alsReceiver struct { | ||
conf *Config | ||
nextConsumer consumer.Logs | ||
settings receiver.Settings | ||
serverGRPC *grpc.Server | ||
|
||
obsrepGRPC *receiverhelper.ObsReport | ||
} | ||
|
||
func (r *alsReceiver) Start(ctx context.Context, host component.Host) error { | ||
var err error | ||
r.serverGRPC, err = r.conf.ToServer(ctx, host, r.settings.TelemetrySettings) | ||
if err != nil { | ||
return fmt.Errorf("failed create grpc server error: %w", err) | ||
} | ||
|
||
alsv3.RegisterAccessLogServiceServer(r.serverGRPC, als.New(r.nextConsumer, r.obsrepGRPC)) | ||
|
||
err = r.startGRPCServer(ctx, host) | ||
if err != nil { | ||
return fmt.Errorf("failed to start grpc server error: %w", err) | ||
} | ||
|
||
return err | ||
} | ||
|
||
func (r *alsReceiver) startGRPCServer(ctx context.Context, host component.Host) error { | ||
r.settings.Logger.Info("Starting GRPC server", zap.String("endpoint", r.conf.NetAddr.Endpoint)) | ||
listener, err := r.conf.NetAddr.Listen(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
go func() { | ||
if errGRPC := r.serverGRPC.Serve(listener); !errors.Is(errGRPC, grpc.ErrServerStopped) && errGRPC != nil { | ||
componentstatus.ReportStatus(host, componentstatus.NewFatalErrorEvent(errGRPC)) | ||
} | ||
}() | ||
return nil | ||
} | ||
|
||
func (r *alsReceiver) Shutdown(_ context.Context) error { | ||
if r.serverGRPC != nil { | ||
r.serverGRPC.GracefulStop() | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func newALSReceiver(cfg *Config, nextConsumer consumer.Logs, settings receiver.Settings) (*alsReceiver, error) { | ||
r := &alsReceiver{ | ||
conf: cfg, | ||
nextConsumer: nextConsumer, | ||
settings: settings, | ||
} | ||
|
||
var err error | ||
r.obsrepGRPC, err = receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{ | ||
ReceiverID: settings.ID, | ||
Transport: "grpc", | ||
ReceiverCreateSettings: settings, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return r, nil | ||
} |
Oops, something went wrong.