• Stars
    star
    330
  • Rank 122,724 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Server that accepts metrics via the Graphite protocol and exports them as Prometheus metrics

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. Labels specified in the mapping configuration take precedence over tags in the metric. 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.

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.

More Repositories

1

prometheus

The Prometheus monitoring system and time series database.
Go
52,273
star
2

node_exporter

Exporter for machine metrics
Go
10,062
star
3

alertmanager

Prometheus Alertmanager
Go
6,196
star
4

client_golang

Prometheus instrumentation library for Go applications
Go
5,113
star
5

blackbox_exporter

Blackbox prober exporter
Go
4,198
star
6

client_python

Prometheus instrumentation library for Python applications
Python
3,726
star
7

jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Java
2,866
star
8

pushgateway

Push acceptor for ephemeral and batch jobs.
Go
2,836
star
9

client_java

Prometheus instrumentation library for JVM applications
Java
2,116
star
10

mysqld_exporter

Exporter for MySQL server metrics
Go
1,976
star
11

snmp_exporter

SNMP Exporter for Prometheus
Go
1,489
star
12

statsd_exporter

StatsD to Prometheus metrics exporter
Go
884
star
13

cloudwatch_exporter

Metrics exporter for Amazon AWS CloudWatch
Java
854
star
14

procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Go
732
star
15

docs

Prometheus documentation: content and static site generator
SCSS
619
star
16

haproxy_exporter

Simple server that scrapes HAProxy stats and exports them via HTTP for Prometheus consumption
Go
607
star
17

promlens

PromLens – The query builder, analyzer, and explainer for PromQL
TypeScript
507
star
18

client_ruby

Prometheus instrumentation library for Ruby applications
Ruby
499
star
19

consul_exporter

Exporter for Consul metrics
Go
419
star
20

client_rust

Prometheus / OpenMetrics client library in Rust
Rust
407
star
21

prom2json

A tool to scrape a Prometheus client and dump the result as JSON.
Go
336
star
22

promu

Prometheus Utility Tool
Go
255
star
23

collectd_exporter

A server that accepts collectd stats via HTTP POST and exports them via HTTP for Prometheus consumption
Go
251
star
24

common

Go libraries shared across Prometheus components and libraries.
Go
250
star
25

influxdb_exporter

A server that accepts InfluxDB metrics via the HTTP API and exports them via HTTP for Prometheus consumption
Go
248
star
26

exporter-toolkit

Utility package to build exporters
Go
237
star
27

memcached_exporter

Exports metrics from memcached servers for consumption by Prometheus.
Go
176
star
28

test-infra

Prometheus E2E benchmarking tool
Go
147
star
29

compliance

A set of tests to check compliance with various Prometheus interfaces
Go
120
star
30

nagios_plugins

Nagios plugins for alerting on Prometheus query results
Shell
103
star
31

demo-site

Demo site auto-deployed with Ansible and Travis CI.
HTML
93
star
32

client_model

Data model artifacts for Prometheus.
Makefile
70
star
33

golang-builder

Prometheus Golang builder Docker images
Shell
69
star
34

codemirror-promql

PromQL support for the CodeMirror code editor
TypeScript
37
star
35

busybox

Prometheus Busybox Docker base images
Makefile
37
star
36

prometheus_api_client_ruby

A Ruby library for reading metrics stored on a Prometheus server
Ruby
34
star
37

talks

Track Prometheus talks
20
star
38

lezer-promql

A lezer-based PromQL grammar
JavaScript
11
star
39

circleci

8
star
40

host_exporter

See the "node_exporter" repository instead!
8
star
41

proposals

Design documents for Prometheus Ecosystem
Makefile
7
star
42

snmp_exporter_mibs

4
star
43

promci

GitHub Actions repository
4
star
44

kube-demo-site

Kubernetes Demo Site
Go
1
star