vrischmann / go-metrics-influxdb Goto Github PK
View Code? Open in Web Editor NEWThis is a reporter for the go-metrics library which will post the metrics to InfluxDB
License: MIT License
This is a reporter for the go-metrics library which will post the metrics to InfluxDB
License: MIT License
Thanks for your hard work on this lib.
I just want to ask if you have plans to support the new v2 client as the old one is deprecated: https://github.com/influxdata/influxdb/tree/master/client
Also the new client supports udp connections, but apparently there is no way to set this up with go-metrics-influxdb.
in InfluxDB , the client use Default config , the client don't support timeout
InfluxDB will now panic on sending metrics because it defaults tags to nil and then tries to assign an entry in the nil map.
Default to nil is influxdb.go#L30 and assignment to nil map: influxdb.go#L152.
When creating tags for the purpose of bucketing histogram, meter, and timer metrics, the library improperly modifies the global tag set:
https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L151
https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L173
https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L207
I'm sure the intent here was to copy the existing tag set, but maps are a reference type. The result is that the bucket
tag that is added for histogram, meter, and timer metrics is also applied to counter and gauge metrics.
The correct way to handle this is to explicitly copy the existing map:
these_tags := map[string]string{}
for tk, tv := range r.tags {
these_tags[tk] = tv
}
I'll open a PR with the fix.
Hi,
is support for InfluxDB 2.x planned?
Authentication has changed so older clients can't connect anymore.
There is an official influxdb client for 1.8+ and 2.x:
https://github.com/influxdata/influxdb-client-go
Thanks
Jochen
@vrischmann If you don't mind, I can create a PR to add go modules to this project. Which version should I give it? v0.1.0
?
InfluxDB function should expose errors
Do you have any example queries or a grafana dashboard that worked for you?
Hi,
It looks like when reporting histogram values - all percentiles will be set to same value.
Here's how go-metrics logger fetches the percentiles:
ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
Here's influxdb.go:
"p999": m.Percentile(99.9),
"p9999": m.Percentile(99.99),
From traffic capture. Note the pNN values:
count=481999i,m1=999.9992707686223,m15=998.8201711297105,m5=999.589420684841,max=1181835i,mean=127654.4280155642,meanrate=999.9936221298891,min=81662i,p50=1181835,p75=1181835,p95=1181835,p99=1181835,p999=1181835,p9999=1181835,stddev=76492.17168321775,variance=5851052328.814858 1445863754555784700
according to https://community.influxdata.com/t/how-to-solve-type-conflicts/8473, one field under the same measurement (regardless of the different buckets) needs to have same field type.
otherwise, we might have errors as shown below
2020/01/21 12:28:10 unable to send metrics to InfluxDB. err={"error":"partial write: field type conflict: input field \"process-time.histogram\" on measurement \"item-pipeline\" is type float, already exists as type integer dropped=10"}
The fix would be to unify the same data type for each field. For example, for Histogram, we could do the following:
fields := map[string]interface{}{
"count": float64(ms.Count()),
"m1": ms.Rate1(),
"m5": ms.Rate5(),
"m15": ms.Rate15(),
"mean": ms.RateMean(),
}
Please approve the problem and solution and I can create the MR for it.
when i use metrics.Histogram
总数一直相加,count 一直直线增长。 应该调用metrics.clear() 清除一下吧?
我可否提一个pr,合并一下?
Error:
"partial write: field type conflict: input field "total.request.meter" on measurement "table" is type integer, already exists as type float
https://github.com/vrischmann/go-metrics-influxdb/blob/master/influxdb.go#L164-L175
this repo still being maintained?
hello,i find if i get server info.after long time.linux show too many ESTABLISHED.
package main
import (
"time"
"github.com/rcrowley/go-metrics"
"github.com/vrischmann/go-metrics-influxdb"
)
func main() {
r := metrics.NewRegistry()
metrics.RegisterDebugGCStats(r)
metrics.RegisterRuntimeMemStats(r)
go metrics.CaptureDebugGCStats(r, time.Second *5)
go metrics.CaptureRuntimeMemStats(r, time.Second *5)
for {
go influxdb.InfluxDB(
r, // metrics registry
time.Second * 5, // how often
"***", // InfluxDB url
"***", // InfluxDB database name
"", // InfluxDB user
"", // InfluxDB password
)
time.Sleep(time.Second * 3)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.