api - ActiveState ActiveGo 1.8

Package api

import "github.com/prometheus/client_golang/api"

Overview ▾

Package api provides clients for the HTTP APIs.


DefaultRoundTripper is used if no RoundTripper is set in Config.

var DefaultRoundTripper http.RoundTripper = &http.Transport{
    Proxy: http.ProxyFromEnvironment,
    Dial: (&net.Dialer{
        Timeout:   30 * time.Second,
        KeepAlive: 30 * time.Second,
    TLSHandshakeTimeout: 10 * time.Second,

type Client

Client is the interface for an API client.

type Client interface {
    URL(ep string, args map[string]string) *url.URL
    Do(context.Context, *http.Request) (*http.Response, []byte, error)

func NewClient

func NewClient(cfg Config) (Client, error)

NewClient returns a new Client.

It is safe to use the returned Client from multiple goroutines.

type Config

Config defines configuration parameters for a new client.

type Config struct {
    // The address of the Prometheus to connect to.
    Address string

    // RoundTripper is used by the Client to drive HTTP requests. If not
    // provided, DefaultRoundTripper will be used.
    RoundTripper http.RoundTripper


Name Synopsis
v1 Package v1 provides bindings to the Prometheus HTTP API v1: http://prometheus.io/docs/querying/api/