diff --git a/documentation/examples/remote_storage/example_write_adapter/README.md b/documentation/examples/remote_storage/example_write_adapter/README.md deleted file mode 100644 index 9748c448db..0000000000 --- a/documentation/examples/remote_storage/example_write_adapter/README.md +++ /dev/null @@ -1,24 +0,0 @@ -## Remote Write Adapter Example - -This is a simple example of how to write a server to -receive samples from the remote storage output. - -To use it: - -``` -go build -./example_write_adapter -``` - -...and then add the following to your `prometheus.yml`: - -```yaml -remote_write: - - url: "http://localhost:1234/receive" -``` - -Then start Prometheus: - -``` -./prometheus -``` diff --git a/documentation/examples/remote_storage/example_write_adapter/server.go b/documentation/examples/remote_storage/example_write_adapter/server.go deleted file mode 100644 index dc2bd0e70a..0000000000 --- a/documentation/examples/remote_storage/example_write_adapter/server.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "log" - "net/http" - - "github.com/prometheus/common/model" - - "github.com/prometheus/prometheus/storage/remote" -) - -func main() { - http.HandleFunc("/receive", func(w http.ResponseWriter, r *http.Request) { - req, err := remote.DecodeWriteRequest(r.Body) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - for _, ts := range req.Timeseries { - m := make(model.Metric, len(ts.Labels)) - for _, l := range ts.Labels { - m[model.LabelName(l.Name)] = model.LabelValue(l.Value) - } - fmt.Println(m) - - for _, s := range ts.Samples { - fmt.Printf("\tSample: %f %d\n", s.Value, s.Timestamp) - } - - for _, e := range ts.Exemplars { - m := make(model.Metric, len(e.Labels)) - for _, l := range e.Labels { - m[model.LabelName(l.Name)] = model.LabelValue(l.Value) - } - fmt.Printf("\tExemplar: %+v %f %d\n", m, e.Value, e.Timestamp) - } - } - }) - - log.Fatal(http.ListenAndServe(":1234", nil)) -} diff --git a/documentation/examples/remote_storage/remote_storage_adapter/README.md b/documentation/examples/remote_storage/remote_storage_adapter/README.md deleted file mode 100644 index ce0735bff5..0000000000 --- a/documentation/examples/remote_storage/remote_storage_adapter/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Remote storage adapter - -This is a write adapter that receives samples via Prometheus's remote write -protocol and stores them in Graphite, InfluxDB, or OpenTSDB. It is meant as a -replacement for the built-in specific remote storage implementations that have -been removed from Prometheus. - -For InfluxDB, this binary is also a read adapter that supports reading back -data through Prometheus via Prometheus's remote read protocol. - -## Building - -``` -go build -``` - -## Running - -Graphite example: - -``` -./remote_storage_adapter --graphite-address=localhost:8080 -``` - -OpenTSDB example: - -``` -./remote_storage_adapter --opentsdb-url=http://localhost:8081/ -``` - -InfluxDB example: - -``` -./remote_storage_adapter --influxdb-url=http://localhost:8086/ --influxdb.database=prometheus --influxdb.retention-policy=autogen -``` - -To show all flags: - -``` -./remote_storage_adapter -h -``` - -## Configuring Prometheus - -To configure Prometheus to send samples to this binary, add the following to your `prometheus.yml`: - -```yaml -# Remote write configuration (for Graphite, OpenTSDB, or InfluxDB). -remote_write: - - url: "http://localhost:9201/write" - -# Remote read configuration (for InfluxDB only at the moment). -remote_read: - - url: "http://localhost:9201/read" -``` diff --git a/documentation/examples/remote_storage/remote_storage_adapter/graphite/client.go b/documentation/examples/remote_storage/remote_storage_adapter/graphite/client.go deleted file mode 100644 index 36242a8f4d..0000000000 --- a/documentation/examples/remote_storage/remote_storage_adapter/graphite/client.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2015 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package graphite - -import ( - "bytes" - "fmt" - "math" - "net" - "sort" - "time" - - "github.com/go-kit/log" - "github.com/go-kit/log/level" - "github.com/prometheus/common/model" -) - -// Client allows sending batches of Prometheus samples to Graphite. -type Client struct { - logger log.Logger - - address string - transport string - timeout time.Duration - prefix string -} - -// NewClient creates a new Client. -func NewClient(logger log.Logger, address, transport string, timeout time.Duration, prefix string) *Client { - if logger == nil { - logger = log.NewNopLogger() - } - return &Client{ - logger: logger, - address: address, - transport: transport, - timeout: timeout, - prefix: prefix, - } -} - -func pathFromMetric(m model.Metric, prefix string) string { - var buffer bytes.Buffer - - buffer.WriteString(prefix) - buffer.WriteString(escape(m[model.MetricNameLabel])) - - // We want to sort the labels. - labels := make(model.LabelNames, 0, len(m)) - for l := range m { - labels = append(labels, l) - } - sort.Sort(labels) - - // For each label, in order, add ".