-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add default HTTP log receiver (#1330)
* add default HTTP log receiver * keiths feedback * replace interface{} with any * keiths feedback p2 * brandons feedback & docs update * corbins feedback * update config struct
- Loading branch information
1 parent
6fbf4e4
commit e1fa864
Showing
15 changed files
with
1,210 additions
and
33 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
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,61 @@ | ||
# HTTP Receiver | ||
This receiver is capable of collecting logs for a variety of services, serving as a default HTTP log receiver. Anything that is able to send JSON structured logs to an endpoint using HTTP will be able to utilize this receiver. | ||
|
||
## Minimum Agent Versions | ||
- Introduced: [v1.39.0](https://github.com/observIQ/bindplane-agent/releases/tag/v1.39.0) | ||
|
||
## Supported Pipelines | ||
- Logs | ||
|
||
## How It Works | ||
1. The user configures this receiver in a pipeline. | ||
2. The user configures a supported component to route telemetry from this receiver. | ||
|
||
## Prerequisites | ||
- The log source can be configured to send logs to an endpoint using HTTP | ||
- The logs sent by the log source are JSON structured | ||
|
||
## Configuration | ||
| Field | Type | Default | Required | Description | | ||
|----------------------|-----------|------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| endpoint | string | | `true` | The hostname and port the receiver should listen on for logs being sent as HTTP POST requests. | | ||
| path | string | | `false` | Specifies a path the receiver should be listening to for logs. Useful when the log source also sends other data to the endpoint, such as metrics. | | ||
| tls.key_file | string | | `false` | Configure the receiver to use TLS. | | ||
| tls.cert_file | string | | `false` | Configure the receiver to use TLS. | | ||
|
||
### Example Configuration | ||
```yaml | ||
receivers: | ||
http: | ||
endpoint: "localhost:12345" | ||
path: "/api/v2/logs" | ||
exporters: | ||
googlecloud: | ||
project: my-gcp-project | ||
|
||
service: | ||
pipelines: | ||
logs: | ||
receivers: [http] | ||
exporters: [googlecloud] | ||
``` | ||
### Example Configuration With TLS | ||
```yaml | ||
receivers: | ||
http: | ||
endpoint: "0.0.0.0:12345" | ||
path: "/logs" | ||
tls: | ||
key_file: "certs/server.key" | ||
cert_file: "certs/server.crt" | ||
exporters: | ||
googlecloud: | ||
project: my-gcp-project | ||
|
||
service: | ||
pipelines: | ||
logs: | ||
receivers: [http] | ||
exporters: [googlecloud] | ||
``` |
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,65 @@ | ||
// Copyright observIQ, Inc. | ||
// | ||
// 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 httpreceiver is a default HTTP receiver for log ingestion | ||
package httpreceiver | ||
|
||
import ( | ||
"errors" | ||
"net" | ||
"path" | ||
|
||
"go.opentelemetry.io/collector/config/confighttp" | ||
) | ||
|
||
// Config defines the configuration for an HTTP receiver | ||
type Config struct { | ||
Path string `mapstructure:"path"` | ||
confighttp.HTTPServerSettings `mapstructure:",squash"` | ||
} | ||
|
||
var ( | ||
errNoEndpoint = errors.New("an endpoint must be specified") | ||
errBadEndpoint = errors.New("unable to split endpoint into 'host:port' pair") | ||
errBadPath = errors.New("given path is malformed") | ||
errNoCert = errors.New("tls was configured, but no cert file was specified") | ||
errNoKey = errors.New("tls was configured, but no key file was specified") | ||
) | ||
|
||
// Validate ensures an HTTP receiver config is correct | ||
func (c *Config) Validate() error { | ||
if c.Endpoint == "" { | ||
return errNoEndpoint | ||
} | ||
|
||
if _, _, err := net.SplitHostPort(c.Endpoint); err != nil { | ||
return errBadEndpoint | ||
} | ||
if c.TLSSetting != nil { | ||
if c.TLSSetting.CertFile == "" && c.TLSSetting.CertPem == "" { | ||
return errNoCert | ||
} | ||
if c.TLSSetting.KeyFile == "" && c.TLSSetting.KeyPem == "" { | ||
return errNoKey | ||
} | ||
} | ||
if c.Path != "" { | ||
clean := path.Clean(c.Path) | ||
if c.Path != clean { | ||
return errBadPath | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.