Giter VIP home page Giter VIP logo

graphite_exporter's Introduction

Graphite Exporter

CircleCI Docker Repository on Quay Docker Pulls

An exporter for metrics exported in the Graphite plaintext protocol. It accepts data over both TCP and UDP, and transforms and exposes them for consumption by Prometheus.

This exporter is useful for exporting metrics from existing Graphite setups, as well as for metrics which are not covered by the core Prometheus exporters such as the Node Exporter.

Usage

make
./graphite_exporter

Configure existing monitoring to send Graphite plaintext data to port 9109 on UDP or TCP. As a simple demonstration:

echo "test_tcp 1234 $(date +%s)" | nc localhost 9109
echo "test_udp 1234 $(date +%s)" | nc -u -w1 localhost 9109

Metrics will be available on http://localhost:9108/metrics.

To avoid using unbounded memory, metrics will be garbage collected five minutes after they are last pushed to. This is configurable with the --graphite.sample-expiry flag.

Graphite Tags

The graphite_exporter accepts metrics in the tagged carbon format. In the case where there are valid and invalid tags supplied in one metric, the invalid tags will be dropped and the graphite_tag_parse_failures counter will be incremented. The exporter accepts inconsistent label sets, but this may cause issues querying the data in Prometheus.

By default, labels explicitly specified in configuration take precedence over labels from the metric. To set the label from the metric instead, use honor_labels.

Metric Mapping and Configuration

Please note there has been a breaking change in configuration after version 0.2.0. The YAML style config from statsd_exporter is now used. See conversion instructions below

YAML Config

The graphite_exporter can be configured to translate specific dot-separated graphite metrics into labeled Prometheus metrics via YAML configuration file. This file shares syntax and logic with statsd_exporter. Please follow the statsd_exporter documentation for usage information. However, graphite_exporter does not support all parsing features at this time. Any feature based on the 'timer_type' option will not function. Otherwise, regex matching, groups, match/drop behavior, should work as expected.

Metrics that don't match any mapping in the configuration file are translated into Prometheus metrics without any labels and with names in which every non-alphanumeric character except _ and : is replaced with _.

If you have a very large set of metrics you may want to skip the ones that don't match the mapping configuration. If that is the case you can force this behaviour using the --graphite.mapping-strict-match flag, and it will only store those metrics you really want.

An example mapping configuration:

mappings:
- match: test.dispatcher.*.*.*
  name: dispatcher_events_total
  labels:
    action: $2
    job: test_dispatcher
    outcome: $3
    processor: $1
- match: '*.signup.*.*'
  name: signup_events_total
  labels:
    job: ${1}_server
    outcome: $3
    provider: $2
- match: 'servers\.(.*)\.networking\.subnetworks\.transmissions\.([a-z0-9-]+)\.(.*)'
  match_type: regex
  name: 'servers_networking_transmissions_${3}'
  labels: 
    hostname: ${1}
    device: ${2}

This would transform these example graphite metrics into Prometheus metrics as follows:

test.dispatcher.FooProcessor.send.success
  => dispatcher_events_total{processor="FooProcessor", action="send", outcome="success", job="test_dispatcher"}

foo_product.signup.facebook.failure
  => signup_events_total{provider="facebook", outcome="failure", job="foo_product_server"}

test.web-server.foo.bar
  => test_web__server_foo_bar{}

servers.rack-003-server-c4de.networking.subnetworks.transmissions.eth0.failure.mean_rate
  => servers_networking_transmissions_failure_mean_rate{device="eth0",hostname="rack-003-server-c4de"}

Conversion from legacy configuration

If you have an existing config file using the legacy mapping syntax, you may use statsd-exporter-convert to update to the new YAML based syntax. Here we convert the old example synatx:

$ go get -u github.com/bakins/statsd-exporter-convert

$ cat example.conf
test.dispatcher.*.*.*
name="dispatcher_events_total"
processor="$1"
action="$2"
outcome="$3"
job="test_dispatcher"

*.signup.*.*
name="signup_events_total"
provider="$2"
outcome="$3"
job="${1}_server"

$ statsd-exporter-convert example.conf
mappings:
- match: test.dispatcher.*.*.*
  name: dispatcher_events_total
  labels:
    action: $2
    job: test_dispatcher
    outcome: $3
    processor: $1
- match: '*.signup.*.*'
  name: signup_events_total
  labels:
    job: ${1}_server
    outcome: $3
    provider: $2

Using Docker

You can deploy this exporter using the prom/graphite-exporter Docker image.

For example:

docker pull prom/graphite-exporter

docker run -d -p 9108:9108 -p 9109:9109 -p 9109:9109/udp \
        -v ${PWD}/graphite_mapping.conf:/tmp/graphite_mapping.conf \
        prom/graphite-exporter --graphite.mapping-config=/tmp/graphite_mapping.conf

Experimental: Importing Whisper data

Import data from Graphite using the bundled getool. See getool create-blocks --help for usage.

To import long-term data in a reasonable amount of resources, increase the duration per generated TSDB block. The --block-duration must be a power of two in hours, e.g. 4h, 8h, and so on.

To merge the data into an existing Prometheus storage directory, start Prometheus with the --storage.tsdb.allow-overlapping-blocks flag.

Incompatibility with Graphite bridge

This exporter does not work in combination with the Java client or Python client Graphite bridge. In the transition to the Graphite data model and back, information is lost. Additionally, default metrics conflict between the client libraries and the exporter.

Instead, configure Prometheus to scrape your application directly, without the exporter in the middle. For batch or ephemeral jobs, use the pushgateway integration. If you absolutely must push, consider PushProx or the Grafana agent instead.

TLS and basic authentication

Graphite Exporter supports TLS and basic authentication. This enables better control of the various HTTP endpoints.

To use TLS and/or basic authentication, you need to pass a configuration file using the --web.config.file parameter. The format of the file is described in the exporter-toolkit repository.

graphite_exporter's People

Contributors

beorn7 avatar brian-brazil avatar daawesomep avatar deejay1 avatar dependabot[bot] avatar discordianfish avatar efficks avatar fffonion avatar grobie avatar inosato avatar juliusv avatar l15k4 avatar leetcoder91 avatar lucian-vanghele avatar matthiasr avatar nature1995 avatar pnyheim avatar prombot avatar qsbao avatar roidelapluie avatar sdurrheimer avatar simonpasquier avatar spynode avatar superq avatar travisgroth avatar victorcete avatar vjanelle avatar wndhydrnt avatar xocasdashdash avatar ystein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphite_exporter's Issues

Setup in kubernetes cluster

Hi

I have installed Prometheus in my k8s cluster. Howcan I setup graphite exporter in Kubernetes?

Would like to have via helm ?

Allow substring wildcards

This is, for some reason, an invalid mapping config:

sensu.Foo-*.*.*
name="sensu"
foo="$1"
bar="$2"
baz="$3"

If I remove Foo- it passes the mapping check. Why is the mapping check so "strict" that it doesn't allow the wildcard anywhere but on its own, ie. between dots?

Thanks.

Issue with metric filter on = symbol

Hi,
I am integrating Hadoop metrics with Prometheus using graphite exporter but the problem is metrics published by Hadoop daemons have = symbol and Iam unable to filter it.

For example:
Hadoop.dfs.rpc.rpc.port.Hostname=srver1.abc.com.RpcAvgResponseTime

I want to remove hostname from the metric name and map to metric name as

Hadoop.dfs.rpc.rpc.port.RpcAvgResponseTime{hostname=srver1.abc.com}.

Please help to resolve this

Thank for your help in advance.

Regards
Sidharth

Unexpected mappings behavior

Hey, I'm using graphite_exporter to convert druid metrics to prometheus format. I get a metric like this :

echo "druid_druid_coordinator_musty_bear_druid_coordinator_0_musty_bear_druid_coordinator_default_svc_cluster_local:8081_jvm_gc_mem_capacity 1.79306496e+08" | nc localhost 9109

Applying this mapping :

mappings:
  - match: druid_druid_(.*?)_(.*)_:\d{4}_(.*) (.*)$
    match_type: regex
    name: druid_component_metrics
    labels:
      component: "$1"
      metric: "$3"
      value: "$4"

Probably doesn't match so one would expect the metric to be present in the original form, but it is not present in metrics at all. Not even in the original form.

And there is an error in logs :

time="2018-09-06T15:34:52Z" level=info msg="Invalid part count of 2 in line: druid_druid_coordinator_musty_bear_druid_coordinator_0_musty_bear_druid_coordinator_default_svc_cluster_local:8081_jvm_gc_mem_capacity 1.79306496e+08" source="main.go:108" 

If I understand it correctly, mapping cannot have more regex groups than it is actually used in labels, is that correct ?

Support underscores in metric name components

Break-out from #80:

The exporter's metric parsing currently fails if any component of the Graphite metric name contains underscores, unless there is a mapping that constructs a valid Prometheus name.

Even without a matching mapping, the exporter should handle these metric names and translate them to valid Prometheus metric names. Existing metric names for metrics without underscores should not change when doing this.

Make a new release?

Hi everybody,
first of all, thanks for the great exporter! I'm using it without issues in my environment. The last release is quite old, are you able to publish a new one?

Cheers, Tim

graphite_exporter issue

Hi Team,

I am trying to use graphite_exporter on RHEL (6/7). i am configuring this to monitor spark metrics.
When i start graphite service, i am getting below error message.
Please let me know the fix.

graphite_exporter[3551]: time="2018-04-26T11:30:43+08:00" level=info msg="Invalid part count of 2 in line: Accept-Encoding: gzip" source="main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:43+08:00" level=info msg="Invalid part count of 2 in line: X-Prometheus-Scrape-Timeout-Seconds: ...main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:43+08:00" level=info msg="Invalid part count of 1 in line: " source="main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid value in line: GET /metrics HTTP/1.1" source="main.go:112"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid part count of 2 in line: Host: localhost:9109" source="main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid part count of 2 in line: User-Agent: Prometheus/2.2.1" source="main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid part count of 2 in line: Accept: text/plain;version=0.0.4;q=1,...main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid part count of 2 in line: Accept-Encoding: gzip" source="main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid part count of 2 in line: X-Prometheus-Scrape-Timeout-Seconds: ...main.go:94"
graphite_exporter[3551]: time="2018-04-26T11:30:48+08:00" level=info msg="Invalid part count of 1 in line: " source="main.go:94"

Improve scrape performance with a lot of metrics

I am performing some load tests with the Graphite exporter and once the metrics count passes a certain threshold, the performance becomes really bad. For example, while pushing metrics with banno/graphite-tester with this command: docker run -it banno/graphite-stresser:0.1 my.graphite.exporter.com 9109 50 650 10 false (650 timers from 50 hosts which means 487500 metrics), the downloading of all metrics from /metrics sometimes takes around 30 seconds with curl. As I can see from curl, it takes a very long time until the download starts at all but when it starts it finishes immediately. The node metrics from that machine show that load isn't so high and there is plenty of RAM - it is a 64GB and 16 vCPUs Openstack machine on KVM. Thus, it seems that something is wrong with the code.

Afterward, looking at the code it seems that for each small sample that comes in or for any access whatsoever, the whole map which holds the samples gets locked by using a sync.Mutex. My theory is that there a lot of different writers because of the huge number of metrics and the one sole reader gets starved.

My small suggestion would be to switch to a https://golang.org/pkg/sync/#Map and not lock the whole map on any single access. Or please let me know how I could debug this problem further :)

GetMapping => SIGSEGV: segmentation violation

Hi, i was using the latest tag and got the 0.4.1 image after i restarted the exporter, which suddenly started throwings SIGSEGV:

time="2018-11-25T15:36:31Z" level=info msg="Starting graphite_exporter (version=0.4.1, branch=HEAD, revision=f0d0670ab0e3b0e80876d0cd6b9c16dde6646dc3)" source="main.go:236"
time="2018-11-25T15:36:31Z" level=info msg="Build context (go=go1.11.2, user=root@c61ff3ba6d26, date=20181123-23:08:58)" source="main.go:237"
time="2018-11-25T15:36:31Z" level=info msg="Listening on :9108" source="main.go:308"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7c1102]

goroutine 135 [running]:
github.com/prometheus/graphite_exporter/vendor/github.com/prometheus/statsd_exporter/pkg/mapper/fsm.(*FSM).GetMapping(0xc000159aa0, 0xc00018c8a0, 0x19, 0x8e35aa, 0x8, 0xc0001b1b18, 0x1, 0xfad171d600000003, 0xc0001b1a90)
        /go/src/github.com/prometheus/graphite_exporter/vendor/github.com/prometheus/statsd_exporter/pkg/mapper/fsm/fsm.go:152 +0x282
github.com/prometheus/graphite_exporter/vendor/github.com/prometheus/statsd_exporter/pkg/mapper.(*MetricMapper).GetMapping(0xc00017ca00, 0xc00018c8a0, 0x19, 0x8e35aa, 0x8, 0x0, 0x0, 0xc0002c4000)
        /go/src/github.com/prometheus/graphite_exporter/vendor/github.com/prometheus/statsd_exporter/pkg/mapper/mapper.go:219 +0x605
main.(*graphiteCollector).processLine(0xc000159800, 0xc00018c8a0, 0x26)
        /go/src/github.com/prometheus/graphite_exporter/main.go:117 +0x18a
main.(*graphiteCollector).processReader(0xc000159800, 0x95fcc0, 0xc0005fa060)
        /go/src/github.com/prometheus/graphite_exporter/main.go:103 +0xe3
main.main.func1.1(0x966b80, 0xc0005fa060, 0xc000159800)
        /go/src/github.com/prometheus/graphite_exporter/main.go:271 +0x91
created by main.main.func1
        /go/src/github.com/prometheus/graphite_exporter/main.go:269 +0xce

My mapping file:

mappings:
- match: rspamd.actions.*
  name: rspamd_actions
  labels:
    action: $1
- match: rspamd.*
  name: rspamd_${1}

Example data sent (which triggers the SIGSEGV):

rspamd.actions.add_header 2 1543160310
rspamd.actions.greylist 0 1543160310
rspamd.actions.no_action 24 1543160310
rspamd.actions.reject 1 1543160310
rspamd.actions.rewrite_subject 0 1543160310
rspamd.actions.soft_reject 0 1543160310
rspamd.bytes_allocated 4165268944 1543160310
rspamd.chunks_allocated 4294966730 1543160310
rspamd.chunks_freed 0 1543160310
rspamd.chunks_oversized 1 1543160310
rspamd.connections 1 1543160310
rspamd.control_connections 1 1543160310
rspamd.ham_count 24 1543160310
rspamd.learned 2 1543160310
rspamd.pools_allocated 59 1543160310
rspamd.pools_freed 171 1543160310
rspamd.scanned 27 1543160310
rspamd.shared_chunks_allocated 34 1543160310
rspamd.spam_count 3 1543160310

superfluous response.WriteHeader call

We got graphite_exporter as a sidecar container in k8s pod, the app sends metrics in graphite format to the graphite_exporter sidecar. Unfortunately the sidecar is sometimes crashing with messages as below (notice the start messages, because pod was restarted):

E 2020-03-26T08:30:46.433181765Z 2020/03/26 08:30:46 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:30:47.290749036Z 2020/03/26 08:30:47 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:30:47.471443864Z 2020/03/26 08:30:47 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:30:48.251203872Z 2020/03/26 08:30:48 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:30:56.142616995Z 2020/03/26 08:30:56 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:06.131707428Z 2020/03/26 08:31:06 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:16.130500694Z 2020/03/26 08:31:16 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:26.137004953Z 2020/03/26 08:31:26 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:36.128960391Z 2020/03/26 08:31:36 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:46.216874310Z 2020/03/26 08:31:46 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:56.170481822Z 2020/03/26 08:31:56 http: superfluous response.WriteHeader call from github.com/prometheus/client_golang/prometheus/promhttp.(*responseWriterDelegator).WriteHeader (delegator.go:59)
E 2020-03-26T08:31:59.369481547Z time="2020-03-26T08:31:59Z" level=info msg="Starting graphite_exporter (version=0.6.0, branch=HEAD, revision=66c1c5e4eea14cf7f22080afcb9740ce4d874ffc)" source="main.go:245"
E 2020-03-26T08:31:59.369552488Z time="2020-03-26T08:31:59Z" level=info msg="Build context (go=go1.12.5, user=root@5cd57e93a5e2, date=20190531-17:44:40)" source="main.go:246"
E 2020-03-26T08:31:59.369562624Z time="2020-03-26T08:31:59Z" level=info msg="Listening on :9108" source="main.go:321"

related issues:

Fix:

  • probably bump prometheus/client_golang to version 1.5.1 in the graphite_exporter, adjust code and so on...

New glob matcher report invalid values.

We're testing both 0.5.0 and 0.4.2 and getting errors with the new glob matcher.

With 0.5.0, graphite exporter error out with duplicated metrics error

collected metric "flink_assigned_partitions" { label:<name:"job" value:"ebs-dumper" > label:<name:"operator" value:"Source:-kafka:-ebs-umts" > label:<name:"subtask" value:"0" > label:<name:"task" value:"Source:-kafka:-ebs-umts-->-Process-ebs-umts-events" > gauge:<value:487941.72 > } was collected before with the same name and label values

The weird part is we don't know where the value 487941.72 comes from. We never sent that value and it didn't show up in the debug log either.

With version 0.4.2, the graphite_exporter doesn't error, but reports both valid and invalid values, which screws up the monitoring process.

flink_assigned_partitions{job="ebs-dumper",operator="Source:-kafka:-ebs-lte",subtask="2",task="Source:-kafka:-ebs-lte-->-Process-ebs-lte-events"} 5
flink_assigned_partitions{job="ebs-dumper",operator="Source:-kafka:-ebs-lte",subtask="2",task="Source:-kafka:-ebs-lte-->-Process-ebs-lte-events"} 1.80102799e+06

Reverting back to 0.3.0 or using the regex matcher will avoid this issue.

This might relate to issues #79

Graphite_exporter: Writing metric on port 9109 over TCP failing

My application is sending metrics over tcp on port 9109 in plaintext protocol format :

I am using method writeBytes() of class DataOutputStream to write data on graphite_exporter's 9109 port. There is writing successfully but can not see data on http://localhost:9108/metrics.

Before sending data I have started graphite_exporter to listen on port 9108.
Can someone has any idea why I can not see my metrics on http://localhost:9108/metrics?

Document scenarios for sending graphite metrics to graphite_exporter

Hi all:
I tried graphite_exporter for the first time. I have graphite and graphite_exporter running on different hosts already, but how can i send the metrics which graphite received to the graphite_exporter? Is there a way to config this or must i write codes to achieve this goal ? In graphite , I only run carbon-cache. should I run carbon-relay or carbon-agg to send metrics to graphite_exporter?

can someone tell me how to do it ? appreciate it

Update to use common makefile & Go 1.10

I cloned this into a new vagrant environment and

>> formatting code
can't load package: package _/home/vagrant/graphite_exporter: cannot find package "_/home/vagrant/graphite_exporter" in any of:
	/usr/local/go/src/_/home/vagrant/graphite_exporter (from $GOROOT)
	/home/vagrant/go/src/_/home/vagrant/graphite_exporter (from $GOPATH)
make: *** [format] Error 1```

I've got ```go version go1.10.1 linux/amd64```

Handle duplicated metrics gracefully

Summary:

The exporter remembers metrics by Graphite name. It is possible to get into situations where multiple samples (graphite metrics) result in the same Prometheus metric.

At the moment, this makes the exporter catastrophically fail (return error 500 on /metrics). Instead, it should discard the older sample and use the new sample's value.

Original issue description:


We tried using v0.5.0 in our dev env today, upgrading from 0.4.2.
After the upgrade, metrics seem to be dropping out regularly, as can be clearly seen in this grafana dashboard.
image

So something is definitively wrong here.
There are no changes to the environment or config between 0.4.2 and 0.5.0, and we can not see anything abnormal in the graphite_exporter logfiles.

This looks like a critical bug to us.

It should be noted that we have seen similar behavior before where we had UDP packet drops, but this was resolved by tuning the UDP receive buffer as explained here: https://nav.uninett.no/doc/4.3/howto/tuning_graphite.html

Log level flag not picked up - "-log.level=debug" - in 1.4

I noticed this issue has been reported in #7 but was closed. But anyway it is still there in my env.

Here is my container version

docker run --rm -it prom/prometheus:latest -version
prometheus, version 1.4.1 (branch: master, revision: 2a89e8733f240d3cd57a6520b52c36ac4744ce12)
  build user:       root@e685d23d8809
  build date:       20161128-09:59:22
  go version:       go1.7.3

and here is the configure parameters

docker exec 15d62608f236 ps -ef
PID   USER     TIME   COMMAND
    1 root       0:00 /bin/prometheus -log.level debug -config.file /etc/prometheus/prometheus.yml
   35 root       0:00 ps -ef

Here is my command line output

docker run --net=host -it --rm -v /srv:/srv -e KUBERNETES_SERVICE_HOST=http://9.123.102.90 -e KUBERNETES_SERVICE_PORT=8080 -v /root/init_scripts/prometheus/prometheus-kubernetes.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest -- -log.level debug  -config.file /etc/prometheus/prometheus.yml
ERRO[0000] Invalid command line arguments. Help: /bin/prometheus -h  source=config.go:258
ERRO[0000] Non-flag argument on command line: "-log.level"  source=main.go:68
[root@tivsun03 ~]# docker run --net=host -it --rm -v /srv:/srv -e KUBERNETES_SERVICE_HOST=http://9.123.102.90 -e KUBERNETES_SERVICE_PORT=8080 -v /root/init_scripts/prometheus/prometheus-kubernetes.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest  -log.level debug  -config.file /etc/prometheus/prometheus.yml
INFO[0000] Starting prometheus (version=1.4.1, branch=master, revision=2a89e8733f240d3cd57a6520b52c36ac4744ce12)  source=main.go:77
INFO[0000] Build context (go=go1.7.3, user=root@e685d23d8809, date=20161128-09:59:22)  source=main.go:78
INFO[0000] Loading configuration file /etc/prometheus/prometheus.yml  source=main.go:250
INFO[0000] Loading series map and head chunks...         source=storage.go:354
INFO[0000] 0 series loaded.                              source=storage.go:359
INFO[0000] Listening on :9090                            source=web.go:248
INFO[0000] Starting target manager...                    source=targetmanager.go:63
ERRO[0000] Cannot create Kubernetes discovery: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory  source=discovery.go:84
ERRO[0000] Cannot create Kubernetes discovery: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory  source=discovery.go:84
ERRO[0000] Cannot create Kubernetes discovery: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory  source=discovery.go:84
ERRO[0000] Cannot create Kubernetes discovery: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory  source=discovery.go:84
ERRO[0000] Cannot create Kubernetes discovery: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory  source=discovery.go:84
INFO[0300] Checkpointing in-memory metrics and chunks...  source=persistence.go:549
INFO[0300] Done checkpointing in-memory metrics and chunks in 822.807µs.  source=persistence.go:573

And in the command line flags page, the log.level is still 'info'

log.level "info"

Create Benchmarks for Exporter Performance

In order to ensure that changes don't have a negative effect on performance, we should have a benchmark similar to the statsd_exporter package to measure parsing performance and performance accepting metrics on UDP

Upgrade client_golang to v0.8.0 or newer

statsd_exporter is already using it, and with Go modules this prevents us from bringing in a newer version of the mapper.

There are also performance improvements in client_golang, so this will probably help with #66 as well.

Mapping configuration check

Hi, it would be nice if graphite_exporter would allow for checking the correctness of the mapping file as a runtime switch, so it could be used like promtool in a CI/CD flow.

allow setting the metrics type

What about e.g. __type__=counter or similar?

It would also be nice to allow histograms, etc, but that might take more thought.

[bug] mappings is not working

Hi,
Possibly this is user error - but no matter what I try I cant seem to get the mappings to work.
For example:

# HELP _jvm_uptime Graphite metric .jvm.uptime
# TYPE _jvm_uptime gauge
_jvm_uptime 526

No, matter what I try for mappings it just doesnt get matched. I have tried

*.*
name="catchall"
first="$1"
second="$2"
third="$3"
job="$1-$2-$3"
jvm.*
name="jvm"
type="$1"
jvm.uptime
name="jvm_uptime"
type="$1"

Any help is appreciated.

I have tried this with the latest master code and the docker images.

The config file is definitely getting picked up (as it breaks if the syntax is invalid)

advice for mapping rule

I think this is tricky (7 lines):

- match:  '*.*.jvm.*.*'
  name: 'jvm_memory_usage'
  labels:
    application: $1
    executor_id: $2
    mem_type: $3
    qty: $4

And this is simpler (2 lines) and more intuitive. In below case {} can be omitted:

-   name: 'jvm_memory_usage'
    match: '${application}.${executor_id}.jvm.${mem_type}.${qty}'

Cut a new release & binaries

It has been a while since the last (and only) release, and I'm interested in some commits (specifically f9d4f11). Can you please cut a new release and publish the binaries? Thanks!

Expand documentation of mapping

Breakout from #80:

  • Provide examples using regex not just glob in the documentation
  • Provide an example using a catch-all regex for metrics not matching an existing regex.
  • Explain the difference between using the configuration for dropping all non match metrics versus using a catch all regex to provide an indication that metrics are not matching and would have been dropped.

The mapping is closely related to that of the statsd exporter – the main difference is that all Graphite metrics are considered a gauge.

Maybe it makes sense to have a unified mapping documentation, but for now, the statsd exporter readme can serve as an inspiration for this one.

"Too many files" - TCP connection exhaustion

Hi -

Our graphite-exporter is throwing:
ERRO[669315] Error accepting TCP connection: accept tcp [::]:9109: accept4: too many open files source=main.go:219

lsof shows that the exporter has more than 1000 open TCP connections - from 20 servers.

This seems like it's probably the same issue seen in prometheus/prometheus#2238. I'm looking into updating our grafana version, but would it be practical to port the limiter from that issue to the graphite exporter?

Thanks!

new release cause configmap doesn't work any more

Hi

We found that your new release 0.3.0 is causing the graphite-config no longer works. Even I covert to your new format, the metrics are not exported successfully.

But when I want to use your tag, unlucky, you didn't put any tag in docker repository. Can you please help to tag your 0.2.0 and 0.3.0 into docker repository?

Thank you very much

Exporter panics on invalid/unexpected metric names

The results from this issue were broken up into several issues. The part that remains here is:

  • graphite_exporter should implement a counter of rejected metrics and expose it as parts of its own metrics.
  • graphite_exporter should not panic and exit when an invalid metric is received.
  • Graphite_exporter in debug mode should log the offending metrics in a log file (or in the debug output of the web page for simplicity sake)

Original investigation:

==========

The majority of our metrics contain the field _ in the various parts of the metric.

labels.go has a validation function, validateLabelValues, that checks if the expected number of labels is consistent with the original number of dot delimited fields.

with a metric like:
hostname_function.source.description.metric_blah.count 2.0 timestamp

The exporter will get confused between hostname_function and hostname function. Due to the splitting the underscores.
_ is a valid Graphite AND Prometheus value and should be handled.
UPDATE:When using matching this problem can be bypassed by assigning parts of the graphite metric name to labels and extracting a good metric name. See comment below. Issue is still valid as it should not panic when encountering an unexpected/unsupported/supported_but_problematic metric name.

Suggested fix: A temporary token should be used to treat initial underscores detected and restoring them when creating the label names to be exposed to Prometheus.

0.5 Panics
0.4.2 Drops the offending metrics and only exposes the "valid" metrics. But it considers the graphite_Exporter as Down and throws errors in the syslog metric after HELP is INVALID.

func validateLabelValues(vals []string, expectedNumberOfValues int) error {
	if len(vals) != expectedNumberOfValues {
		return fmt.Errorf(
			"%s: expected %d label values but got %d in %#v",
			errInconsistentCardinality, expectedNumberOfValues,
			len(vals), vals,
		)
	}

	for _, val := range vals {
		if !utf8.ValidString(val) {
			return fmt.Errorf("label value %q is not valid UTF-8", val)
		}
	}

	return nil
}

Graphite Exporter on kubernetes cluster

Hi,

Can you help me with setting up graphite exporter in a kubernetes cluster ?

I dont see any yaml file or helm chart for deploying the same .

Regards
Vishnu

Add timestamp to exported metrics

The graphite exporter keeps the metrics for up to 5 minutes. It even records the time in Timestamp. But it doesn't export the time it received the metrics to Prometheus.

I would like the graphite_exporter to export the time when it received a metrics like the push gateway.

This would help a setup where Prometheus scrapes the graphite_exporter every 10 seconds, but new data is pushed to graphite in a different timing (i.e. 30 or 60 seconds).

Update dependencies

The graphite exporter is a few versions behind, especially on the mapper package and the Prometheus client.

name label clashes with series name

Currently it is not possible to set a label 'name', as this keyword is reserved for the series name. However it would be useful to be able to set this label to be compatible with other exporters:

Telegraf inputs.net exporter:
diskio_read_bytes{host="kronos",instance="192.168.x.x.xxxx",job="linux-server",name="vda"}

To be backwards-compatible some kind of escaping could be used.

Setup issues

Hi!

I'm having issues setting up.
I first tried the binaries found here:
https://prometheus.io/download/#graphite_exporter

Seemed to be working fine, until I tried to send some test data to it.

Startup:

root@MONIT-01:/opt/prometheus/graphite_exporter_0# ./graphite_exporter 
level=info ts=2020-02-16T10:02:30.856Z caller=main.go:260 msg="Starting graphite_exporter" version_info="(version=0.7.0-rc1, branch=HEAD, revision=b11c8a66bb01034aacadff5bcc6bf073b7803340)"
level=info ts=2020-02-16T10:02:30.857Z caller=main.go:261 build_context="(go=go1.13.6, user=root@5b94ccd60948, date=20200121-10:31:27)"
level=info ts=2020-02-16T10:02:30.859Z caller=main.go:341 msg="Listening on :9108"

Then, from another SSH session:

root@MONIT-01:~# echo "test_tcp 1234 $(date +%s)" | nc localhost 9109
root@MONIT-01:~# 

I immediately got pinged by the first session, which had now printed the following error before quitting:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x8a7df9]

goroutine 26 [running]:
github.com/prometheus/statsd_exporter/pkg/mapper.(*MetricMapper).GetMapping(0xc000136180, 0xc0000c8400, 0x8, 0x9d0091, 0x5, 0x0, 0x0, 0x0)
        /app/vendor/github.com/prometheus/statsd_exporter/pkg/mapper/mapper.go:240 +0xc9
main.(*graphiteCollector).processLine(0xc000100280, 0xc0000c8400, 0x18)
        /app/main.go:137 +0x478
main.(*graphiteCollector).processLines(0xc000100280)
        /app/main.go:123 +0x5f
created by main.newGraphiteCollector
        /app/main.go:107 +0x150

After fiddling for awhile (mostly reinstalling graphite_exporter and go) I thought maybe the issue was with the precompiled binary.

So I attempted to compile from source, with no luck.
This is the error I got (and keep getting): http://paste.ubuntu.com/p/NZNhdkzBkD/

Any ideas?

Hadoop metrics with space in them

I am trying to use graphite exporter to get Cloudera Hadoop metrics into prometheus.
The issue I am having is with spaces in the metric name.

This is my rule:

- match: 'cdh\.dfs\.FSNamesystem\.Context=([a-zA-Z]+)\.(?:EnabledEcPolicies=(?:[A-Za-z0-9-]+)\.)?(?:HAState=(?:\S+)\.)?(?:TotalSyncTimes=(?:[\d ]+)\.)?Hostname=([0-9a-z._]+com)\.(\S+)'
  name: "cdh_dfs_FSNamesystem_${3}"
  match_type: regex
  labels:
    context: "$1"
    hostname: "$2"

But I am getting multiple errors like this:

Dec 17 14:36:39 <redacted hostname> graphite_exporter[2994459]: time="2019-12-17T14:36:39+01:00" level=info msg="Invalid part count of 5 in line: cdh.dfs.FSNamesystem.Context=dfs.EnabledEcPolicies=RS-6-3-1024k.HAState=active.TotalSyncTimes=3 3 .Hostname=<redacted hostname>.TotalSyncCount 1 1576589798" source="main.go:122"
Dec 17 14:36:49 r<redacted hostname> graphite_exporter[2994459]: time="2019-12-17T14:36:48+01:00" level=info msg="Invalid part count of 5 in line: cdh.dfs.FSNamesystem.Context=dfs.EnabledEcPolicies=RS-6-3-1024k.HAState=active.TotalSyncTimes=18 41 .Hostname=r<redacted hostname>.TotalSyncCount 6 1576589808" source="main.go:122"
Dec 17 14:36:59 <redacted hostname> graphite_exporter[2994459]: time="2019-12-17T14:36:58+01:00" level=info msg="Invalid part count of 5 in line: cdh.dfs.FSNamesystem.Context=dfs.EnabledEcPolicies=RS-6-3-1024k.HAState=active.TotalSyncTimes=18 41 .Hostname=<redacted hostname>.TotalSyncCount 6 1576589818" source="main.go:122"

Is there any way to remove those whitespaces while processing before regexp? As this seems to happen before remapping is done.

Dash and underscore character escaping

Documentation mentions that -,_ in metric names are escaped into __, but I do not see this happening. All symbols in metric names are replaced with single _. I skimmed through the code but could not locate where this is implemented. Should this documented functionality be in place for 0.1.0 release?

Use metrics mapping from statsd_exporter

The statsd exporter gets more attention thanks this one, and its mapping had evolved and diverged from the one in this exporter. Fundamentally, the two map from the same domain (dot-separated hierarchical names with optional key/value tags) into the Prometheus model.

Metric remains after `graphite.sample-expiry` flag expires

I'm experiencing an issue where a metric is still visible on the output side of the exporter after the graphite.sample-expiry timeout expires. Any suggestions as to what may be going on?

graphite_exporter_build_info{branch="HEAD",goversion="go1.12.5",revision="32fbcbc7ef1316b35401927ce34daa6001accd5e",version="0.6.2"}

Metric on the Prometheus side of the exporter and the appropriate mapping:

# TYPE Business_Transaction_Time gauge
Business_Transaction_Time{dc="dc1",host="ip-"} 23
Business_Transaction_Time{dc="dc2",host="ip-"} 45

mappings:
  - match: gatling.*.*.business.transaction.time
    name: Business_Transaction_Time
    labels:
      host: $2
      dc: $1

Log level flag not picked up - "-log.level=debug"

Seeing issues with the graphite exporter, but cannot increase log level to debug.

ps aufx

# root
root     26891  0.2  0.4 1509540 35768 pts/0   Sl   Jul27  11:40 /usr/bin/docker -d
100      21292  0.1  0.1  45888 11096 ?        Ssl  10:59   0:04  \_ /bin/graphite_exporter -log.level=debug -graphite.mapping-config=/etc/graphite/graphite_mapping.conf

# container
docker exec -it 6869f5dde41e ps aufx
PID   USER     TIME   COMMAND
    1 golang     0:04 /bin/graphite_exporter -log.level=debug -graphite.mapping-config=/etc/graphite/graphite_mapping.conf

Container logs

docker logs f0d4533b7560
time="2015-07-30T12:07:02Z" level=info msg="Starting Server: :9108" file=main.go line=240 

docker compose

graphiteexporter:
  command: -log.level=debug -graphite.mapping-config=/etc/graphite/graphite_mapping.conf
  image: prom/graphite-exporter
  ports:
  - "9108:9108"
  - "9109:9109"
  - "9109/udp:9109/udp"
  volumes:
  - "graphiteexporter/conf:/etc/graphite"

Levels

docker run -it prom/graphite-exporter -h
Usage of /bin/graphite_exporter:
  -graphite.listen-address=":9109": TCP and UDP address on which to accept samples.
  -graphite.mapping-config="": Metric mapping configuration file name.
  -graphite.sample-expiry=5m0s: How long a sample is valid for.
  -log.level=info: Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal, panic].
  -web.listen-address=":9108": Address on which to expose metrics.
  -web.telemetry-path="/metrics": Path under which to expose Prometheus metrics.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.