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

New Logz.io output #5736

Closed
wants to merge 132 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
3e0b698
update all.go with logz.io output
Apr 15, 2019
9c06444
add logzio output
Apr 15, 2019
bf1d871
update main readme
Apr 15, 2019
14a3967
fix readme
Apr 15, 2019
d548791
renaming methods
Apr 17, 2019
dea08a2
fixing logzio file path
Apr 17, 2019
2aeb4e4
fix readme
Apr 17, 2019
2451b7f
adding deleted rows in the readme file
Apr 17, 2019
49afe64
update Gopkg.lock
Apr 17, 2019
72e7385
update gopkg.lock -- fix make package
Apr 18, 2019
2bc5b12
remove logzio-go use
May 7, 2019
1d073ab
adding tests
May 7, 2019
5de4f6b
fix URL to include token in the request
May 7, 2019
1724c0d
fmt
May 7, 2019
8c0ba42
delete deps from Gopck.lock
May 12, 2019
f734831
fix tests
May 12, 2019
34af6f5
fix readme
May 16, 2019
129a489
changes based on CR
May 19, 2019
5211218
update readme and sampleConfig with tls options
May 21, 2019
903a065
Add logic starlark example (#7864)
sjwang90 Jul 21, 2020
9f6b709
fix issue with execd restart_delay being ignored (#7867)
ssoroka Jul 21, 2020
5efce71
Update docker FAQ (#7868)
danielnelson Jul 21, 2020
b9a7188
Recv next message after send returns EOF (#7872)
danielnelson Jul 21, 2020
6e5c72f
Fix defaults processor readme typos (#7873)
sjwang90 Jul 22, 2020
569584d
shim logger improvements (#7865)
ssoroka Jul 22, 2020
3f15a0f
Set 1.15.0 release date
reimda Jul 22, 2020
72dec1b
Fix arch name in deb/rpm builds (#7877)
danielnelson Jul 22, 2020
af1e8ac
Update changelog
danielnelson Jul 22, 2020
72fdfd8
fixed cgroups docu (#7889)
DEvil0000 Jul 24, 2020
dab07c6
jolokia: add some error message context (#7906)
ssoroka Jul 27, 2020
d233b4c
Fix/extend support of fixed point values on input (modbus plugin) (#7…
sensor-freak Jul 27, 2020
0245431
MongoDB: Added new metric "pages written from cache" (#7870)
vikkyomkar Jul 28, 2020
93a08f8
fixes issue with rpm /var/log/telegraf permissions (#7909)
ssoroka Jul 28, 2020
7ae2403
fix broken link to proc.c (#7918)
matse Jul 29, 2020
c7236eb
Fix tail following on EOF (#7927)
reimda Jul 31, 2020
effe112
Update changelog
reimda Jul 31, 2020
eb162dd
Fixed title on New Relic README.md (#7948)
kidk Aug 6, 2020
198f92b
Add descriptions for measurement & fields (#7902)
kelseiv Aug 6, 2020
2e751d0
JSON does not support values NaN and Inf (#7908)
Aladex Aug 6, 2020
df93825
Add details to connect to InfluxDB OSS 2 and Cloud 2 (#7953)
alsargent Aug 6, 2020
4d11d76
cleanup cloudwatch plugin (#7928)
ssoroka Aug 7, 2020
ab21024
Support for AWS Cloudwatch Alarms #7931 (#7932)
vipinvkmenon Aug 7, 2020
63dde6f
fix cloudwatch tests
ssoroka Aug 7, 2020
211c236
added new counter - Lock Timeouts (timeout > 0)/sec (#7808)
Trovalo Aug 10, 2020
2427142
rabbitmq: remove deprecated healthcheck (#7823) (#7920)
pabigot Aug 10, 2020
75e701c
fix(readmes): adding code block annotations (#7963)
russorat Aug 10, 2020
a6c8f5b
Updated http_response input plugin README.md (#7962)
vikkyomkar Aug 10, 2020
40c6d18
fix(readmes): standarize first line of readmes (#7973)
russorat Aug 11, 2020
2729fe3
chore: extend gitignore to ignore .DS_Store (#7974)
jsteenb2 Aug 12, 2020
786b1b3
fix(ipmi): update link in readme (#7975)
russorat Aug 12, 2020
8878f3f
fix(puppet): update broken link (#7977)
russorat Aug 12, 2020
6c4636b
add pivot example for starlark processor (#7976)
samhld Aug 12, 2020
78811f7
add additional metrics to clickhouse input plugin (#7904)
Slach Aug 12, 2020
780fbfe
Dynatrace output plugin (#7881)
thschue Aug 12, 2020
c0ab965
Proxmox plugin (#7922)
Aug 12, 2020
4ef2b4e
Update Bug_report.md
ssoroka Aug 13, 2020
06a57c8
add label to feature request.
ssoroka Aug 13, 2020
73815a8
Create Support.md
ssoroka Aug 13, 2020
a087cb9
Update Support.md
ssoroka Aug 13, 2020
b8b6f2e
fix(readmes): updates to internal and proxmox readmes (#7982)
russorat Aug 14, 2020
b2eb774
http_listener_v2: make http header tags case insensitive (#7986)
ssoroka Aug 14, 2020
ea1d4d4
Update CHANGELOG.md
ssoroka Aug 14, 2020
6e8255c
Dynatrace Plugin - Updated Documentation (#7994)
thschue Aug 17, 2020
34c8abb
fix flakey ticker test (#7997)
ssoroka Aug 17, 2020
e9d5b1f
fix minor agent race condition around error messages (#7999)
ssoroka Aug 18, 2020
11afd42
fix issue with shim use of config.Duration (#7996)
ssoroka Aug 18, 2020
a03555e
[outputs.application_insights] Added the ability to set the endpoint …
Diabl0Man Aug 19, 2020
073a9be
[agent] Cleanup duplicates in loaded plugins list (#7852)
Hipska Aug 19, 2020
389c538
Fix configuration.md formatting (#7965)
sjwang90 Aug 19, 2020
901e63e
add example input/outputs to starlark examples (#7980)
sjwang90 Aug 19, 2020
7354a44
Fix Ping Input plugin for FreeBSD's ping6 (#7861)
DasSkelett Aug 20, 2020
bf0b376
Fix InsecureSkipVerify in Dynatrace Plugin (#8015)
thschue Aug 21, 2020
bbc2aa6
improve the quality of starlark docs by executing them as tests (#8020)
ssoroka Aug 24, 2020
48bab9d
Fix string to int conversion in eventhub consumer (#8006)
pmalek-sumo Aug 26, 2020
60d402d
vSphere Fixed missing clustername issue 7878 (#8026)
prydin Aug 26, 2020
54f9e33
Add addTag debugging in ifname plugin (#8018)
Hipska Aug 26, 2020
8cc08a6
Create external plugins doc file and update contributing guide (#8001)
sjwang90 Aug 26, 2020
ac809e9
docs fix
ssoroka Aug 27, 2020
4ebb8c7
Add set, and histogram reporting to aerospike telegraf plugin (#8025)
grossjo Aug 28, 2020
5d999f8
fix docker build. update dockerfiles to Go 1.14 (#8051)
ssoroka Aug 28, 2020
3278054
fix bug in shim logger affecting AddError (#8052)
ssoroka Aug 28, 2020
b5fafb4
Fix CI AppVeyor 'make check' errors for go 1.15 on windows (#8061)
srebhan Sep 1, 2020
895d04d
Update gopsutils to v.2.20.7 (#8073)
srebhan Sep 2, 2020
160e1d1
Add OPC UA input plugin (#8009)
chrishayles Sep 2, 2020
843ea4b
Fix docker-image make target (#8005)
pmalek-sumo Sep 3, 2020
45a87a1
add guidelines run to external plugins with execd (#8054)
sjwang90 Sep 3, 2020
b1bce91
add tagpass/tagdrop note in docs (#8053)
sjwang90 Sep 3, 2020
f4e5b0e
update opcua readme (#8075)
sjwang90 Sep 3, 2020
b2ac8b4
Opcua cleanup (#8076)
reimda Sep 4, 2020
4f3325e
Fix external plugin docs links (#8081)
pmalek-sumo Sep 4, 2020
6324b1f
add nsd input plugin (#7822)
gearnode Sep 4, 2020
8c28661
[fix] add missing error check for HTTP req failure (#8071)
jdef Sep 8, 2020
9a06ac1
added force_document_id option to ES output enable resend data and av…
Sep 8, 2020
f0c2c38
Database_type config to Split up sql queries by engine type (#7934)
denzilribeiro Sep 8, 2020
8c3ba65
update influxdb v2 port
sjwang90 Sep 9, 2020
8cd0fe5
Revert "update influxdb v2 port"
ssoroka Sep 9, 2020
e9dcade
Sumo Logic output plugin (#8023)
pmalek-sumo Sep 10, 2020
5534b99
Carbon2 configuration option - include field in metric name (#8094)
pmalek-sumo Sep 10, 2020
55a9d36
SNMP input plugin: document partial table collection (#8104)
hackery Sep 11, 2020
06b8520
update 1.16 changelog with new plugins (#8107)
sjwang90 Sep 11, 2020
77b36e0
Fix bug fix typo in changelog (#8117)
sjwang90 Sep 14, 2020
d764f86
Influxdb v2 listener (#7828)
magichair Sep 14, 2020
0eb6502
Doc update: Fix main.go shim example link (#8123)
sspaink Sep 15, 2020
94481f6
Sort plugin name lists for output (#8127)
Sep 15, 2020
9fddadb
add influxdata slack icon to telegraf readme (#8126)
sjwang90 Sep 15, 2020
341726d
Add octoprint to list (#8131)
sspaink Sep 16, 2020
ce13350
influxdb_v2_listener - add /ready route (#8133)
eraac Sep 17, 2020
191688c
Remove Event field as it is causing issues with pre-trained source ty…
samm-git Sep 18, 2020
39f4c36
Increasing the metric buffer (#8145)
M0rdecay Sep 18, 2020
080e0db
update shim docs to point users in the right direction
ssoroka Sep 18, 2020
5a09735
minor docs cleanup
ssoroka Sep 18, 2020
689b463
Starlark readme url fix
ssoroka Sep 22, 2020
7c42ab2
update all.go with logz.io output
Apr 15, 2019
74f8701
add logzio output
Apr 15, 2019
85e5b5d
update main readme
Apr 15, 2019
8fe26f7
fix readme
Apr 15, 2019
da18f8a
renaming methods
Apr 17, 2019
003244a
fixing logzio file path
Apr 17, 2019
2b04840
fix readme
Apr 17, 2019
d5e039c
adding deleted rows in the readme file
Apr 17, 2019
7e652af
remove logzio-go use
May 7, 2019
eeeac48
adding tests
May 7, 2019
f49c449
fix URL to include token in the request
May 7, 2019
c10af25
fmt
May 7, 2019
3092017
fix tests
May 12, 2019
7e531d4
fix readme
May 16, 2019
b3b29fe
changes based on CR
May 19, 2019
accf06e
update readme and sampleConfig with tls options
May 21, 2019
874e03c
Changing duration condition and rebasing code
Sep 23, 2020
ac721be
git pull
Sep 23, 2020
e621fec
Fixing rebase
Sep 23, 2020
cadf2d0
Change imports to fix test
Sep 23, 2020
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ For documentation on the latest development code see the [documentation index][d
* [instrumental](./plugins/outputs/instrumental)
* [kafka](./plugins/outputs/kafka)
* [librato](./plugins/outputs/librato)
* [logz.io](./plugins/outputs/logzio)
* [mqtt](./plugins/outputs/mqtt)
* [nats](./plugins/outputs/nats)
* [nsq](./plugins/outputs/nsq)
Expand Down
1 change: 1 addition & 0 deletions plugins/outputs/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
_ "github.com/influxdata/telegraf/plugins/outputs/kafka"
_ "github.com/influxdata/telegraf/plugins/outputs/kinesis"
_ "github.com/influxdata/telegraf/plugins/outputs/librato"
_ "github.com/influxdata/telegraf/plugins/outputs/logzio"
_ "github.com/influxdata/telegraf/plugins/outputs/mqtt"
_ "github.com/influxdata/telegraf/plugins/outputs/nats"
_ "github.com/influxdata/telegraf/plugins/outputs/nsq"
Expand Down
43 changes: 43 additions & 0 deletions plugins/outputs/logzio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Logz.io Output Plugin

This plugin sends metrics to Logz.io over HTTPs.

### Configuration:

```toml
# A plugin that can send metrics over HTTPs to Logz.io
[[outputs.http]]
## Set to true if Logz.io sender checks the disk space before adding metrics to the disk queue.
# check_disk_space = true

## The percent of used file system space at which the sender will stop queueing.
## When we will reach that percentage, the file system in which the queue is stored will drop
## all new logs until the percentage of used space drops below that threshold.
# disk_threshold = 98

## How often Logz.io sender should drain the queue.
## Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# drain_duration = "3s"

## Where Logz.io sender should store the queue
## queue_dir = Sprintf("%s%s%s%s%d", os.TempDir(), string(os.PathSeparator),
## "logzio-buffer", string(os.PathSeparator), time.Now().UnixNano())

## Logz.io account token
token = "your Logz.io token" # required

## Use your listener URL for your Logz.io account region.
# url = "https://listener.logz.io:8071"
```

### Required parameters:

* `token`: Your Logz.io token, which can be found under "settings" in your account.

### Optional parameters:

* `check_disk_space`: Set to true if Logz.io sender checks the disk space before adding metrics to the disk queue.
* `disk_threshold`: If the queue_dir space crosses this threshold (in % of disk usage), the plugin will start dropping logs.
* `drain_duration`: Time to sleep between sending attempts.
* `queue_dir`: Metrics disk path. All the unsent metrics are saved to the disk in this location.
* `url`: Logz.io listener URL.
174 changes: 174 additions & 0 deletions plugins/outputs/logzio/logzio.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package logzio

import (
. "bytes"
"compress/gzip"
"crypto/tls"
"encoding/json"
"fmt"
"github.com/influxdata/telegraf/internal"
"io/ioutil"
"log"
"net/http"
"time"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/outputs"
)

const (
defaultLogzioRequestTimeout = time.Second * 5
defaultLogzioURL = "https://listener.logz.io:8071"

logzioDescription = "Send aggregate metrics to Logz.io"
logzioType = "telegraf"
logzioMaxRequestBodySize = 9 * 1024 * 1024 // 9MB
)

var sampleConfig = `
## Logz.io account token
token = "your logz.io token" # required

## Use your listener URL for your Logz.io account region.
# url = "https://listener.logz.io:8071"

## Timeout for HTTP requests
# timeout = "5s"
`

type Logzio struct {
Token string `toml:"token"`
URL string `toml:"url"`
Timeout internal.Duration `toml:"timeout"`

client *http.Client
}

// Connect to the Output
func (l *Logzio) Connect() error {
log.Printf("D! [logzio] Connecting to logz.io output...\n")
if l.Token == "" || l.Token == "your logz.io token" {
return fmt.Errorf("[logzio] token is required")
}

if l.URL == "" {
l.URL = defaultLogzioURL
}

if l.Timeout.Duration == 0 {
l.Timeout.Duration = defaultLogzioRequestTimeout
}

tlsConfig := &tls.Config{}
transport := &http.Transport{
TLSClientConfig: tlsConfig,
}

l.client = &http.Client{
Transport: transport,
Timeout: l.Timeout.Duration,
}

log.Printf("I! [logzio] Successfuly created Logz.io sender: %s\n", l.URL)
return nil
}

// Close any connections to the Output
func (l *Logzio) Close() error {
log.Printf("D! [logzio] Closing logz.io output\n")
return nil
}

// Description returns a one-sentence description on the Output
func (l *Logzio) Description() string {
return logzioDescription
}

// SampleConfig returns the default configuration of the Output
func (l *Logzio) SampleConfig() string {
return sampleConfig
}

// Write takes in group of points to be written to the Output
func (l *Logzio) Write(metrics []telegraf.Metric) error {
if len(metrics) == 0 {
return nil
}

log.Printf("D! [logzio] Recived %d metrics\n", len(metrics))
var body []byte
for _, metric := range metrics {
var name = metric.Name()
m := make(map[string]interface{})

m["@timestamp"] = metric.Time()
m["measurement_name"] = name
if len(metric.Tags()) != 0 {
m["telegraf_tags"] = metric.Tags()
}
m["value_type"] = metric.Type()
m["type"] = logzioType
m[name] = metric.Fields()

serialized, err := json.Marshal(m)
if err != nil {
return fmt.Errorf("E! [logzio] Failed to marshal: %+v\n", m)
}
// Logz.io maximum request body size of 10MB. Send bulks that
// exceed this size (with safety buffer) via separate write requests.
if (len(body) + len(serialized) + 1) > logzioMaxRequestBodySize {
err := l.sendBulk(body)
if err != nil {
return err
}
body = nil
}
log.Printf("D! [logzio] Adding metric to the bulk: %+v\n", m)
body = append(body, serialized...)
body = append(body, '\n')
}

return l.sendBulk(body)
}

func (l *Logzio) sendBulk(body []byte) error {
if len(body) == 0 {
return nil
}

var buf Buffer
g := gzip.NewWriter(&buf)
if _, err := g.Write(body); err != nil {
return err
}
if err := g.Close(); err != nil {
return err
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/?token=%s", l.URL, l.Token), &buf)
if err != nil {
return err
}

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Encoding", "gzip")

resp, err := l.client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()

_, err = ioutil.ReadAll(resp.Body)
if err != nil || resp.StatusCode < 200 || resp.StatusCode > 299 {
return fmt.Errorf("failed to write batch: [%v] %s", resp.StatusCode, resp.Status)
}
log.Printf("D! [logzio] Successfully sent bulk to logz.io\n")

return nil
}

func init() {
outputs.Add("logzio", func() telegraf.Output {
return &Logzio{}
})
}
Loading