Skip to content

Commit

Permalink
[chore] lokireceiver. update to use generated header (#21084)
Browse files Browse the repository at this point in the history
Updates lokireceiver to use new generated status header. There are no warnings to list. Updated README a little bit: ports for HTTP and gRPC were mixed up.

Link to tracking Issue: #19172
  • Loading branch information
mar4uk committed Apr 24, 2023
1 parent 95778f2 commit 8268905
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
12 changes: 7 additions & 5 deletions receiver/lokireceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Loki Receiver

<!-- status autogenerated section -->
| Status | |
| ------------------------ |-----------|
| Stability | [alpha] |
| Supported pipeline types | logs |
| Supported pipeline types | logs |
| Distributions | [contrib] |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

The Loki receiver implements the [Loki push api](https://grafana.com/docs/loki/latest/clients/promtail/#loki-push-api) as specified [here](https://grafana.com/docs/loki/latest/api/#push-log-entries-to-loki).
It allows Promtail instances to specify the open telemetry collector as their lokiAddress.

Expand All @@ -15,7 +20,7 @@ This receiver runs HTTP and GRPC servers to ingest log entries in Loki format.

The settings are:

- `endpoint` (required, default = 0.0.0.0:3500 for grpc protocol, 0.0.0.0:3600 http protocol): host:port to which the receiver is going to receive data.
- `endpoint` (required, default = 0.0.0.0:3500 for HTTP protocol, 0.0.0.0:3600 gRPC protocol): host:port to which the receiver is going to receive data.
- `use_incoming_timestamp` (optional, default = false) if set `true` the timestamp from Loki log entry is used

Example:
Expand All @@ -27,6 +32,3 @@ receivers:
grpc:
use_incoming_timestamp: true
```

[alpha]:https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
10 changes: 6 additions & 4 deletions receiver/lokireceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/confmap/confmaptest"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver/internal/metadata"
)

func TestLoadConfig(t *testing.T) {
Expand All @@ -38,7 +40,7 @@ func TestLoadConfig(t *testing.T) {
expected component.Config
}{
{
id: component.NewIDWithName(typeStr, "defaults"),
id: component.NewIDWithName(metadata.Type, "defaults"),
expected: &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
Expand All @@ -54,7 +56,7 @@ func TestLoadConfig(t *testing.T) {
},
},
{
id: component.NewIDWithName(typeStr, "mixed"),
id: component.NewIDWithName(metadata.Type, "mixed"),
expected: &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
Expand Down Expand Up @@ -96,7 +98,7 @@ func TestInvalidConfig(t *testing.T) {
err string
}{
{
id: component.NewIDWithName(typeStr, "empty"),
id: component.NewIDWithName(metadata.Type, "empty"),
err: "must specify at least one protocol when using the Loki receiver",
},
}
Expand Down Expand Up @@ -125,7 +127,7 @@ func TestConfigWithUnknownKeysConfig(t *testing.T) {
err string
}{
{
id: component.NewIDWithName(typeStr, "extra_keys"),
id: component.NewIDWithName(metadata.Type, "extra_keys"),
err: "'' has invalid keys: foo",
},
}
Expand Down
13 changes: 6 additions & 7 deletions receiver/lokireceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate mdatagen metadata.yaml

package lokireceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver"

import (
Expand All @@ -23,24 +25,21 @@ import (
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/lokireceiver/internal/metadata"
)

const (
// The value of "type" key in configuration.
typeStr = "loki"
// The stability level of the receiver.
stability = component.StabilityLevelDevelopment

defaultGRPCBindEndpoint = "0.0.0.0:3600"
defaultHTTPBindEndpoint = "0.0.0.0:3500"
)

// NewFactory return a new receiver.Factory for loki receiver.
func NewFactory() receiver.Factory {
return receiver.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
receiver.WithLogs(createLogsReceiver, stability))
receiver.WithLogs(createLogsReceiver, metadata.Stability))
}

func createDefaultConfig() component.Config {
Expand Down
12 changes: 12 additions & 0 deletions receiver/lokireceiver/internal/metadata/generated_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions receiver/lokireceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: loki

status:
class: receiver
stability: alpha
pipelines: [logs]
distributions: [contrib]

0 comments on commit 8268905

Please sign in to comment.