logger: remove logentries driver

The Logentries service will be discontinued next week:

> Dear Logentries user,
>
> We have identified you as the owner of, or collaborator of, a Logentries account.
>
> The Logentries service will be discontinued on November 15th, 2022. This means that your Logentries account access will be removed and all your log data will be permanently deleted on this date.
>
> Next Steps
> If you are interested in an alternative Rapid7 log management solution, InsightOps will be available for purchase through December 16th, 2022. Please note, there is no support to migrate your existing Logentries account to InsightOps.
>
> Thank you for being a valued user of Logentries.
>
> Thank you,
> Rapid7 Customer Success

There is no reason to preserve this code in Moby as a result.

Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Bjorn Neergaard 2022-11-03 12:21:44 -05:00 committed by Sebastiaan van Stijn
parent 92884c25b3
commit cd41f655f9
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
11 changed files with 0 additions and 438 deletions

View file

@ -10,7 +10,6 @@ import (
_ "github.com/docker/docker/daemon/logger/journald"
_ "github.com/docker/docker/daemon/logger/jsonfilelog"
_ "github.com/docker/docker/daemon/logger/local"
_ "github.com/docker/docker/daemon/logger/logentries"
_ "github.com/docker/docker/daemon/logger/loggerutils/cache"
_ "github.com/docker/docker/daemon/logger/splunk"
_ "github.com/docker/docker/daemon/logger/syslog"

View file

@ -9,7 +9,6 @@ import (
_ "github.com/docker/docker/daemon/logger/gcplogs"
_ "github.com/docker/docker/daemon/logger/gelf"
_ "github.com/docker/docker/daemon/logger/jsonfilelog"
_ "github.com/docker/docker/daemon/logger/logentries"
_ "github.com/docker/docker/daemon/logger/loggerutils/cache"
_ "github.com/docker/docker/daemon/logger/splunk"
_ "github.com/docker/docker/daemon/logger/syslog"

View file

@ -1,117 +0,0 @@
// Package logentries provides the log driver for forwarding server logs
// to logentries endpoints.
package logentries // import "github.com/docker/docker/daemon/logger/logentries"
import (
"context"
"fmt"
"strconv"
"github.com/bsphere/le_go"
"github.com/containerd/log"
"github.com/docker/docker/daemon/logger"
"github.com/pkg/errors"
)
type logentries struct {
tag string
containerID string
containerName string
writer *le_go.Logger
extra map[string]string
lineOnly bool
}
const (
name = "logentries"
token = "logentries-token"
lineonly = "line-only"
)
func init() {
if err := logger.RegisterLogDriver(name, New); err != nil {
panic(err)
}
if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil {
panic(err)
}
}
// New creates a logentries logger using the configuration passed in on
// the context. The supported context configuration variable is
// logentries-token.
func New(info logger.Info) (logger.Logger, error) {
log.G(context.TODO()).WithField("container", info.ContainerID).
WithField("token", info.Config[token]).
WithField("line-only", info.Config[lineonly]).
Debug("logging driver logentries configured")
log, err := le_go.Connect(info.Config[token])
if err != nil {
return nil, errors.Wrap(err, "error connecting to logentries")
}
var lineOnly bool
if info.Config[lineonly] != "" {
if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); err != nil {
return nil, errors.Wrap(err, "error parsing lineonly option")
}
}
return &logentries{
containerID: info.ContainerID,
containerName: info.ContainerName,
writer: log,
lineOnly: lineOnly,
}, nil
}
func (f *logentries) Log(msg *logger.Message) error {
if !f.lineOnly {
data := map[string]string{
"container_id": f.containerID,
"container_name": f.containerName,
"source": msg.Source,
"log": string(msg.Line),
}
for k, v := range f.extra {
data[k] = v
}
ts := msg.Timestamp
logger.PutMessage(msg)
f.writer.Println(f.tag, ts, data)
} else {
line := string(msg.Line)
logger.PutMessage(msg)
f.writer.Println(line)
}
return nil
}
func (f *logentries) Close() error {
return f.writer.Close()
}
func (f *logentries) Name() string {
return name
}
// ValidateLogOpt looks for logentries specific log option logentries-address.
func ValidateLogOpt(cfg map[string]string) error {
for key := range cfg {
switch key {
case "env":
case "env-regex":
case "labels":
case "labels-regex":
case "tag":
case key:
default:
return fmt.Errorf("unknown log opt '%s' for logentries log driver", key)
}
}
if cfg[token] == "" {
return fmt.Errorf("Missing logentries token")
}
return nil
}

View file

@ -22,7 +22,6 @@ require (
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.24
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.17
github.com/aws/smithy-go v1.13.5
github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8
github.com/cloudflare/cfssl v1.6.4
github.com/containerd/cgroups/v3 v3.0.2
github.com/containerd/containerd v1.7.11

View file

@ -236,8 +236,6 @@ github.com/bombsimon/wsl/v3 v3.0.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2
github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8 h1:fcONpniVVbh9+duVZYYbJuc+yGGdLRxTqpk7pTTz/qI=
github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8/go.mod h1:GrjfimWtH8h8EqJSfbO+sTQYV/fAjL/VN7dMeU8XP2Y=
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=

View file

@ -1,23 +0,0 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test

View file

@ -1,4 +0,0 @@
language: go
go:
- 1.12.x

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2017 Gal Ben-Haim
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,37 +0,0 @@
le_go
=====
Golang client library for logentries.com
It is compatible with http://golang.org/pkg/log/#Logger
and also implements http://golang.org/pkg/io/#Writer
[![GoDoc](https://godoc.org/github.com/bsphere/le_go?status.png)](https://godoc.org/github.com/bsphere/le_go)
[![Build Status](https://travis-ci.org/bsphere/le_go.svg)](https://travis-ci.org/bsphere/le_go)
Usage
-----
Add a new manual TCP token log at [logentries.com](https://logentries.com/quick-start/) and copy the [token](https://logentries.com/doc/input-token/).
Installation: `go get github.com/bsphere/le_go`
**Note:** The Logger is blocking, it can be easily run in a goroutine by calling `go le.Println(...)`
```go
package main
import "github.com/bsphere/le_go"
func main() {
le, err := le_go.Connect("XXXX-XXXX-XXXX-XXXX") // replace with token
if err != nil {
panic(err)
}
defer le.Close()
le.Println("another test message")
}
```

228
vendor/github.com/bsphere/le_go/le.go generated vendored
View file

@ -1,228 +0,0 @@
// Package le_go provides a Golang client library for logging to
// logentries.com over a TCP connection.
//
// it uses an access token for sending log events.
package le_go
import (
"crypto/tls"
"fmt"
"net"
"os"
"strings"
"sync"
"time"
)
// Logger represents a Logentries logger,
// it holds the open TCP connection, access token, prefix and flags.
//
// all Logger operations are thread safe and blocking,
// log operations can be invoked in a non-blocking way by calling them from
// a goroutine.
type Logger struct {
conn net.Conn
flag int
mu sync.Mutex
prefix string
token string
buf []byte
}
const lineSep = "\n"
// Connect creates a new Logger instance and opens a TCP connection to
// logentries.com,
// The token can be generated at logentries.com by adding a new log,
// choosing manual configuration and token based TCP connection.
func Connect(token string) (*Logger, error) {
logger := Logger{
token: token,
}
if err := logger.openConnection(); err != nil {
return nil, err
}
return &logger, nil
}
// Close closes the TCP connection to logentries.com
func (logger *Logger) Close() error {
if logger.conn != nil {
return logger.conn.Close()
}
return nil
}
// Opens a TCP connection to logentries.com
func (logger *Logger) openConnection() error {
conn, err := tls.Dial("tcp", "data.logentries.com:443", &tls.Config{})
if err != nil {
return err
}
logger.conn = conn
return nil
}
// It returns if the TCP connection to logentries.com is open
func (logger *Logger) isOpenConnection() bool {
if logger.conn == nil {
return false
}
buf := make([]byte, 1)
logger.conn.SetReadDeadline(time.Now())
_, err := logger.conn.Read(buf)
switch err.(type) {
case net.Error:
if err.(net.Error).Timeout() == true {
logger.conn.SetReadDeadline(time.Time{})
return true
}
}
return false
}
// It ensures that the TCP connection to logentries.com is open.
// If the connection is closed, a new one is opened.
func (logger *Logger) ensureOpenConnection() error {
if !logger.isOpenConnection() {
if err := logger.openConnection(); err != nil {
return err
}
}
return nil
}
// Fatal is same as Print() but calls to os.Exit(1)
func (logger *Logger) Fatal(v ...interface{}) {
logger.Output(2, fmt.Sprint(v...))
os.Exit(1)
}
// Fatalf is same as Printf() but calls to os.Exit(1)
func (logger *Logger) Fatalf(format string, v ...interface{}) {
logger.Output(2, fmt.Sprintf(format, v...))
os.Exit(1)
}
// Fatalln is same as Println() but calls to os.Exit(1)
func (logger *Logger) Fatalln(v ...interface{}) {
logger.Output(2, fmt.Sprintln(v...))
os.Exit(1)
}
// Flags returns the logger flags
func (logger *Logger) Flags() int {
return logger.flag
}
// Output does the actual writing to the TCP connection
func (logger *Logger) Output(calldepth int, s string) error {
var (
err error
waitPeriod = time.Millisecond
)
for {
_, err = logger.Write([]byte(s))
if err != nil {
if connectionErr := logger.openConnection(); connectionErr != nil {
return connectionErr
}
waitPeriod *= 2
time.Sleep(waitPeriod)
continue
}
return err
}
}
// Panic is same as Print() but calls to panic
func (logger *Logger) Panic(v ...interface{}) {
s := fmt.Sprint(v...)
logger.Output(2, s)
panic(s)
}
// Panicf is same as Printf() but calls to panic
func (logger *Logger) Panicf(format string, v ...interface{}) {
s := fmt.Sprintf(format, v...)
logger.Output(2, s)
panic(s)
}
// Panicln is same as Println() but calls to panic
func (logger *Logger) Panicln(v ...interface{}) {
s := fmt.Sprintln(v...)
logger.Output(2, s)
panic(s)
}
// Prefix returns the logger prefix
func (logger *Logger) Prefix() string {
return logger.prefix
}
// Print logs a message
func (logger *Logger) Print(v ...interface{}) error {
return logger.Output(2, fmt.Sprint(v...))
}
// Printf logs a formatted message
func (logger *Logger) Printf(format string, v ...interface{}) error {
return logger.Output(2, fmt.Sprintf(format, v...))
}
// Println logs a message with a linebreak
func (logger *Logger) Println(v ...interface{}) error {
return logger.Output(2, fmt.Sprintln(v...))
}
// SetFlags sets the logger flags
func (logger *Logger) SetFlags(flag int) {
logger.flag = flag
}
// SetPrefix sets the logger prefix
func (logger *Logger) SetPrefix(prefix string) {
logger.prefix = prefix
}
// Write writes a bytes array to the Logentries TCP connection,
// it adds the access token and prefix and also replaces
// line breaks with the unicode \u2028 character
func (logger *Logger) Write(p []byte) (n int, err error) {
logger.mu.Lock()
if err := logger.ensureOpenConnection(); err != nil {
return 0, err
}
defer logger.mu.Unlock()
logger.makeBuf(p)
return logger.conn.Write(logger.buf)
}
// makeBuf constructs the logger buffer
// it is not safe to be used from within multiple concurrent goroutines
func (logger *Logger) makeBuf(p []byte) {
count := strings.Count(string(p), lineSep)
p = []byte(strings.Replace(string(p), lineSep, "\u2028", count-1))
logger.buf = logger.buf[:0]
logger.buf = append(logger.buf, (logger.token + " ")...)
logger.buf = append(logger.buf, (logger.prefix + " ")...)
logger.buf = append(logger.buf, p...)
if !strings.HasSuffix(string(logger.buf), lineSep) {
logger.buf = append(logger.buf, (lineSep)...)
}
}

3
vendor/modules.txt vendored
View file

@ -186,9 +186,6 @@ github.com/aws/smithy-go/transport/http/internal/io
# github.com/beorn7/perks v1.0.1
## explicit; go 1.11
github.com/beorn7/perks/quantile
# github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8
## explicit; go 1.12
github.com/bsphere/le_go
# github.com/cenkalti/backoff/v4 v4.2.1
## explicit; go 1.18
github.com/cenkalti/backoff/v4