Giter VIP home page Giter VIP logo

prometheus_remote_client_golang's Introduction

promremote

promremote is a Prometheus remote write client written in Go.

Installation

go get -u github.com/m3db/prometheus_remote_client_golang

Use

promremote is used to send metrics to a Prometheus remote write endpoint such as supported by m3coordinator. It can be pulled into an existing codebase as a client library or used as a cli tool (cmd/main.go) for ad hoc testing purposes.

IMPORTANT: A running program or application that has a Prometheus remote write endpoint is required.

Client library

To use promremote as a client library, the client must be constructed manually using structs.

// create config and client
cfg := promremote.NewConfig(
  promremote.WriteURLOption(writeURLFlag),
  promremote.HTTPClientTimeoutOption(60 * time.Second),
  promremote.UserAgent(userAgent),
)

client, err := promremote.NewClient(cfg)
if err != nil {
  log.Fatal(fmt.Errorf("unable to construct client: %v", err))
}


timeSeriesList := []promremote.TimeSeries{
		promremote.TimeSeries{
			Labels: []promremote.Label{
				{
					Name:  "__name__",
					Value: "foo_bar",
				},
				{
					Name:  "biz",
					Value: "baz",
				},
			},
			Datapoint: promremote.Datapoint{
				Timestamp: time.Now(),
				Value:     1415.92,
			},
		},
	}

if err := client.WriteTimeSeries(timeSeriesList); err != nil {
	log.Fatal(err)
}

CLI

If one wants to use promremote as a CLI, he or she can utilize the tool located in the cmd/ directory. The tool takes in a series of labels and a datapoint then writes them to a Prometheus remote write endpoint. Below is an example showing a metric with two labels (__name__:foo_bar and biz:baz) and a datapoint (timestamp:now value:1415.92).

Note: One can either specify a Unix timestamp (e.g. 1556026725) or the keyword now as the first parameter in the -d flag.

go run cmd/promremotecli/main.go -t=__name__:foo_bar -t=biz:baz -d=now,1415.92

prometheus_remote_client_golang's People

Contributors

robskillington avatar benraskin92 avatar

Watchers

 avatar

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.